1{ config, pkgs, lib, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.torque.mom; 8 torque = pkgs.torque; 9 10 momConfig = pkgs.writeText "torque-mom-config" '' 11 $pbsserver ${cfg.serverNode} 12 $logevent 225 13 ''; 14 15in 16{ 17 options = { 18 19 services.torque.mom = { 20 enable = mkEnableOption "torque computing node"; 21 22 serverNode = mkOption { 23 type = types.str; 24 description = "Hostname running pbs server."; 25 }; 26 27 }; 28 29 }; 30 31 config = mkIf cfg.enable { 32 environment.systemPackages = [ pkgs.torque ]; 33 34 systemd.services.torque-mom-init = { 35 path = with pkgs; [ torque utillinux procps inetutils ]; 36 37 script = '' 38 pbs_mkdirs -v aux 39 pbs_mkdirs -v mom 40 hostname > /var/spool/torque/server_name 41 cp -v ${momConfig} /var/spool/torque/mom_priv/config 42 ''; 43 44 serviceConfig.Type = "oneshot"; 45 unitConfig.ConditionPathExists = "!/var/spool/torque"; 46 }; 47 48 systemd.services.torque-mom = { 49 path = [ torque ]; 50 51 wantedBy = [ "multi-user.target" ]; 52 requires = [ "torque-mom-init.service" ]; 53 after = [ "torque-mom-init.service" "network.target" ]; 54 55 serviceConfig = { 56 Type = "forking"; 57 ExecStart = "${torque}/bin/pbs_mom"; 58 PIDFile = "/var/spool/torque/mom_priv/mom.lock"; 59 }; 60 }; 61 62 }; 63}