nixos/slurm: Extend configuration options

* Updated SrunX11 option
* Added extraPlugstackConfig parameter
* Added option enableStools
* Add cgroup.conf to module
* Fix some typos

Changed files
+52 -8
nixos
modules
services
computing
slurm
+52 -8
nixos/modules/services/computing/slurm/slurm.nix
···
cfg = config.services.slurm;
# configuration file can be generated by http://slurm.schedmd.com/configurator.html
-
configFile = pkgs.writeText "slurm.conf"
''
${optionalString (cfg.controlMachine != null) ''controlMachine=${cfg.controlMachine}''}
${optionalString (cfg.controlAddr != null) ''controlAddr=${cfg.controlAddr}''}
···
${cfg.extraConfig}
'';
-
plugStackConfig = pkgs.writeText "plugstack.conf"
''
${optionalString cfg.enableSrunX11 ''optional ${pkgs.slurm-spank-x11}/lib/x11.so''}
'';
in
{
···
client = {
enable = mkEnableOption "slurm client daemon";
};
package = mkOption {
···
example = "debug Nodes=linux[1-32] Default=YES MaxTime=INFINITE State=UP";
description = ''
Name by which the partition may be referenced. Note that now you have
-
to write patrition's parameters after the name.
'';
};
···
description = ''
If enabled srun will accept the option "--x11" to allow for X11 forwarding
from within an interactive session or a batch job. This activates the
-
slurm-spank-x11 module. Note that this requires 'services.openssh.forwardX11'
-
to be enabled on the compute nodes.
'';
};
···
the end of the slurm configuration file.
'';
};
};
};
···
wrappedSlurm = pkgs.stdenv.mkDerivation {
name = "wrappedSlurm";
-
propagatedBuildInputs = [ cfg.package configFile ];
builder = pkgs.writeText "builder.sh" ''
source $stdenv/setup
···
#!/bin/sh
if [ -z "$SLURM_CONF" ]
then
-
SLURM_CONF="${configFile}" "$EXE" "\$@"
else
"$EXE" "\$0"
fi
···
'';
};
-
in mkIf (cfg.client.enable || cfg.server.enable) {
environment.systemPackages = [ wrappedSlurm ];
···
mkdir -p /var/spool
'';
};
systemd.services.slurmctld = mkIf (cfg.server.enable) {
path = with pkgs; [ wrappedSlurm munge coreutils ]
···
cfg = config.services.slurm;
# configuration file can be generated by http://slurm.schedmd.com/configurator.html
+
configFile = pkgs.writeTextDir "slurm.conf"
''
${optionalString (cfg.controlMachine != null) ''controlMachine=${cfg.controlMachine}''}
${optionalString (cfg.controlAddr != null) ''controlAddr=${cfg.controlAddr}''}
···
${cfg.extraConfig}
'';
+
plugStackConfig = pkgs.writeTextDir "plugstack.conf"
''
${optionalString cfg.enableSrunX11 ''optional ${pkgs.slurm-spank-x11}/lib/x11.so''}
+
${cfg.extraPlugstackConfig}
'';
+
+
+
cgroupConfig = pkgs.writeTextDir "cgroup.conf"
+
''
+
${cfg.extraCgroupConfig}
+
'';
+
+
# slurm expects some additional config files to be
+
# in the same directory as slurm.conf
+
etcSlurm = pkgs.symlinkJoin {
+
name = "etc-slurm";
+
paths = [ configFile cgroupConfig plugStackConfig ];
+
};
+
in
{
···
client = {
enable = mkEnableOption "slurm client daemon";
+
};
+
enableStools = mkOption {
+
type = types.bool;
+
default = false;
+
description = ''
+
Wether to provide a slurm.conf file.
+
Enable this option if you do not run a slurm daemon on this host
+
(i.e. <literal>server.enable</literal> and <literal>client.enable</literal> are <literal>false</literal>)
+
but you still want to run slurm commands from this host.
+
'';
};
package = mkOption {
···
example = "debug Nodes=linux[1-32] Default=YES MaxTime=INFINITE State=UP";
description = ''
Name by which the partition may be referenced. Note that now you have
+
to write the partition's parameters after the name.
'';
};
···
description = ''
If enabled srun will accept the option "--x11" to allow for X11 forwarding
from within an interactive session or a batch job. This activates the
+
slurm-spank-x11 module. Note that this option also enables
+
'services.openssh.forwardX11' on the client.
'';
};
···
the end of the slurm configuration file.
'';
};
+
+
extraPlugstackConfig = mkOption {
+
default = "";
+
type = types.lines;
+
description = ''
+
Extra configuration that will be added to the end of <literal>plugstack.conf</literal>.
+
'';
+
};
+
+
extraCgroupConfig = mkOption {
+
default = "";
+
type = types.lines;
+
description = ''
+
Extra configuration for <literal>cgroup.conf</literal>. This file is
+
used when <literal>procTrackType=proctrack/cgroup</literal>.
+
'';
+
};
};
};
···
wrappedSlurm = pkgs.stdenv.mkDerivation {
name = "wrappedSlurm";
+
propagatedBuildInputs = [ cfg.package etcSlurm ];
builder = pkgs.writeText "builder.sh" ''
source $stdenv/setup
···
#!/bin/sh
if [ -z "$SLURM_CONF" ]
then
+
SLURM_CONF="${etcSlurm}/slurm.conf" "$EXE" "\$@"
else
"$EXE" "\$0"
fi
···
'';
};
+
in mkIf (cfg.enableStools || cfg.client.enable || cfg.server.enable) {
environment.systemPackages = [ wrappedSlurm ];
···
mkdir -p /var/spool
'';
};
+
+
services.openssh.forwardX11 = mkIf cfg.client.enable (mkDefault true);
systemd.services.slurmctld = mkIf (cfg.server.enable) {
path = with pkgs; [ wrappedSlurm munge coreutils ]