@@ -34,6 +34,15 @@ in
3434
3535 };
3636
37+ package = mkOption {
38+ type = types.package;
39+ default = pkgs.slurm-llnl;
40+ example = literalExample "pkgs.slurm-llnl-full";
41+ description = ''
42+ The packge to use for slurm binaries.
43+ '';
44+ };
45+
3746 controlMachine = mkOption {
3847 type = types.nullOr types.str;
3948 default = null;
@@ -91,38 +100,69 @@ in
91100
92101 ###### implementation
93102
94− config = mkIf (cfg.client.enable || cfg.server.enable) {
103+ config =
104+ let
105+ wrappedSlurm = pkgs.stdenv.mkDerivation {
106+ name = "wrappedSlurm";
107+
108+ propagatedBuildInputs = [ cfg.package configFile ];
109+
110+ builder = pkgs.writeText "builder.sh" ''
111+ source $stdenv/setup
112+ mkdir -p $out/bin
113+ find ${cfg.package}/bin -type f -executable | while read EXE
114+ do
115+ exename="$(basename $EXE)"
116+ wrappername="$out/bin/$exename"
117+ cat > "$wrappername" <<EOT
118+ #!/bin/sh
119+ if [ -z "$SLURM_CONF" ]
120+ then
121+ SLURM_CONF="${configFile}" "$EXE" "\$@"
122+ else
123+ "$EXE" "\$0"
124+ fi
125+ EOT
126+ chmod +x "$wrappername"
127+ done
128+ '';
129+ };
95130
96− environment.systemPackages = [ pkgs.slurm-llnl ];
131+ in mkIf (cfg.client.enable || cfg.server.enable) {
132+
133+ environment.systemPackages = [ wrappedSlurm ];
97134
98135 systemd.services.slurmd = mkIf (cfg.client.enable) {
99− path = with pkgs; [ slurm-llnl coreutils ];
136+ path = with pkgs; [ wrappedSlurm coreutils ];
100137
101138 wantedBy = [ "multi-user.target" ];
102139 after = [ "systemd-tmpfiles-clean.service" ];
103140
104141 serviceConfig = {
105142 Type = "forking";
106− ExecStart = "${pkgs.slurm-llnl}/bin/slurmd -f ${configFile}";
143+ ExecStart = "${wrappedSlurm}/bin/slurmd";
107144 PIDFile = "/run/slurmd.pid";
108145 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
109146 };
147+
148+ preStart = ''
149+ mkdir -p /var/spool
150+ '';
110151 };
111152
112153 systemd.services.slurmctld = mkIf (cfg.server.enable) {
113− path = with pkgs; [ slurm-llnl munge coreutils ];
154+ path = with pkgs; [ wrappedSlurm munge coreutils ];
114155
115156 wantedBy = [ "multi-user.target" ];
116− after = [ "network.target" "auditd.service" "munged.service" "slurmdbd.service" ];
157+ after = [ "network.target" "munged.service" ];
117158 requires = [ "munged.service" ];
118159
119160 serviceConfig = {
120161 Type = "forking";
121− ExecStart = "${pkgs.slurm-llnl}/bin/slurmctld";
162+ ExecStart = "${wrappedSlurm}/bin/slurmctld";
122163 PIDFile = "/run/slurmctld.pid";
123164 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
124165 };
125− environment = { SLURM_CONF = "${configFile}"; };
126166 };
127167
128168 };