at 17.09-beta 1.8 kB view raw
1{ config, lib, pkgs, ...}: 2with lib; 3let 4 cfg = config.services.gateone; 5in 6{ 7options = { 8 services.gateone = { 9 enable = mkEnableOption "GateOne server"; 10 pidDir = mkOption { 11 default = "/run/gateone"; 12 type = types.path; 13 description = ''Path of pid files for GateOne.''; 14 }; 15 settingsDir = mkOption { 16 default = "/var/lib/gateone"; 17 type = types.path; 18 description = ''Path of configuration files for GateOne.''; 19 }; 20 }; 21}; 22config = mkIf cfg.enable { 23 environment.systemPackages = with pkgs.pythonPackages; [ 24 gateone pkgs.openssh pkgs.procps pkgs.coreutils pkgs.cacert]; 25 26 users.extraUsers.gateone = { 27 description = "GateOne privilege separation user"; 28 uid = config.ids.uids.gateone; 29 home = cfg.settingsDir; 30 }; 31 users.extraGroups.gateone.gid = config.ids.gids.gateone; 32 33 systemd.services.gateone = with pkgs; { 34 description = "GateOne web-based terminal"; 35 path = [ pythonPackages.gateone nix openssh procps coreutils ]; 36 preStart = '' 37 if [ ! -d ${cfg.settingsDir} ] ; then 38 mkdir -m 0750 -p ${cfg.settingsDir} 39 chown -R gateone.gateone ${cfg.settingsDir} 40 fi 41 if [ ! -d ${cfg.pidDir} ] ; then 42 mkdir -m 0750 -p ${cfg.pidDir} 43 chown -R gateone.gateone ${cfg.pidDir} 44 fi 45 ''; 46 #unitConfig.RequiresMountsFor = "${cfg.settingsDir}"; 47 serviceConfig = { 48 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}''; 49 User = "gateone"; 50 Group = "gateone"; 51 WorkingDirectory = cfg.settingsDir; 52 }; 53 54 wantedBy = [ "multi-user.target" ]; 55 requires = [ "network.target" ]; 56 }; 57}; 58} 59