2015-07-31 00:22:44 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
cfg = config.services.gateone;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.gateone = {
|
2024-08-28 21:19:08 +02:00
|
|
|
enable = lib.mkEnableOption "GateOne server";
|
|
|
|
pidDir = lib.mkOption {
|
2015-07-31 00:22:44 -04:00
|
|
|
default = "/run/gateone";
|
2024-08-28 21:19:08 +02:00
|
|
|
type = lib.types.path;
|
2021-01-24 09:19:10 +00:00
|
|
|
description = "Path of pid files for GateOne.";
|
2015-07-31 00:22:44 -04:00
|
|
|
};
|
2024-08-28 21:19:08 +02:00
|
|
|
settingsDir = lib.mkOption {
|
2015-07-31 00:22:44 -04:00
|
|
|
default = "/var/lib/gateone";
|
2024-08-28 21:19:08 +02:00
|
|
|
type = lib.types.path;
|
2021-01-24 09:19:10 +00:00
|
|
|
description = "Path of configuration files for GateOne.";
|
2015-07-31 00:22:44 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2018-06-30 01:58:35 +02:00
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
environment.systemPackages = with pkgs.pythonPackages; [
|
|
|
|
gateone
|
|
|
|
pkgs.openssh
|
|
|
|
pkgs.procps
|
2015-12-17 13:17:49 -05:00
|
|
|
pkgs.coreutils
|
2018-06-30 01:58:35 +02:00
|
|
|
pkgs.cacert
|
2024-12-10 20:26:33 +01:00
|
|
|
];
|
2015-07-31 00:22:44 -04:00
|
|
|
|
|
|
|
users.users.gateone = {
|
|
|
|
description = "GateOne privilege separation user";
|
|
|
|
uid = config.ids.uids.gateone;
|
|
|
|
home = cfg.settingsDir;
|
|
|
|
};
|
|
|
|
users.groups.gateone.gid = config.ids.gids.gateone;
|
2024-12-10 20:26:33 +01:00
|
|
|
|
2015-07-31 00:22:44 -04:00
|
|
|
systemd.services.gateone = with pkgs; {
|
|
|
|
description = "GateOne web-based terminal";
|
2024-12-10 20:26:33 +01:00
|
|
|
path = [
|
2015-07-31 00:22:44 -04:00
|
|
|
pythonPackages.gateone
|
2024-12-10 20:26:33 +01:00
|
|
|
nix
|
|
|
|
openssh
|
|
|
|
procps
|
2015-07-31 00:22:44 -04:00
|
|
|
coreutils
|
2024-12-10 20:26:33 +01:00
|
|
|
];
|
2015-07-31 00:22:44 -04:00
|
|
|
preStart = ''
|
|
|
|
if [ ! -d ${cfg.settingsDir} ] ; then
|
|
|
|
mkdir -m 0750 -p ${cfg.settingsDir}
|
2022-05-05 20:09:00 +00:00
|
|
|
chown -R gateone:gateone ${cfg.settingsDir}
|
2024-12-10 20:26:33 +01:00
|
|
|
fi
|
2015-08-07 00:43:29 -04:00
|
|
|
if [ ! -d ${cfg.pidDir} ] ; then
|
|
|
|
mkdir -m 0750 -p ${cfg.pidDir}
|
2022-05-05 20:09:00 +00:00
|
|
|
chown -R gateone:gateone ${cfg.pidDir}
|
2024-12-10 20:26:33 +01:00
|
|
|
fi
|
|
|
|
'';
|
2015-07-31 00:22:44 -04:00
|
|
|
#unitConfig.RequiresMountsFor = "${cfg.settingsDir}";
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = ''${pythonPackages.gateone}/bin/gateone --settings_dir=${cfg.settingsDir} --pid_file=${cfg.pidDir}/gateone.pid --gid=${toString config.ids.gids.gateone} --uid=${toString config.ids.uids.gateone}'';
|
|
|
|
User = "gateone";
|
|
|
|
Group = "gateone";
|
|
|
|
WorkingDirectory = cfg.settingsDir;
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2015-07-31 00:22:44 -04:00
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
requires = [ "network.target" ];
|
2024-12-10 20:26:33 +01:00
|
|
|
};
|
2015-07-31 00:22:44 -04:00
|
|
|
};
|
|
|
|
}
|