nixos/slurm: Extend configuration options

* Updated SrunX11 option
* Added extraPlugstackConfig parameter
* Added option enableStools
* Add cgroup.conf to module
* Fix some typos
This commit is contained in:
Markus Kowalewski 2018-05-24 20:16:01 +02:00
parent b17b44232f
commit 995d2ec928
No known key found for this signature in database
GPG Key ID: D865C8A91D7025EB

View File

@ -6,7 +6,7 @@ let
cfg = config.services.slurm; cfg = config.services.slurm;
# configuration file can be generated by http://slurm.schedmd.com/configurator.html # configuration file can be generated by http://slurm.schedmd.com/configurator.html
configFile = pkgs.writeText "slurm.conf" configFile = pkgs.writeTextDir "slurm.conf"
'' ''
${optionalString (cfg.controlMachine != null) ''controlMachine=${cfg.controlMachine}''} ${optionalString (cfg.controlMachine != null) ''controlMachine=${cfg.controlMachine}''}
${optionalString (cfg.controlAddr != null) ''controlAddr=${cfg.controlAddr}''} ${optionalString (cfg.controlAddr != null) ''controlAddr=${cfg.controlAddr}''}
@ -17,10 +17,25 @@ let
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
plugStackConfig = pkgs.writeText "plugstack.conf" plugStackConfig = pkgs.writeTextDir "plugstack.conf"
'' ''
${optionalString cfg.enableSrunX11 ''optional ${pkgs.slurm-spank-x11}/lib/x11.so''} ${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 in
{ {
@ -46,7 +61,17 @@ in
client = { client = {
enable = mkEnableOption "slurm client daemon"; 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 { package = mkOption {
@ -97,7 +122,7 @@ in
example = "debug Nodes=linux[1-32] Default=YES MaxTime=INFINITE State=UP"; example = "debug Nodes=linux[1-32] Default=YES MaxTime=INFINITE State=UP";
description = '' description = ''
Name by which the partition may be referenced. Note that now you have Name by which the partition may be referenced. Note that now you have
to write patrition's parameters after the name. to write the partition's parameters after the name.
''; '';
}; };
@ -107,8 +132,8 @@ in
description = '' description = ''
If enabled srun will accept the option "--x11" to allow for X11 forwarding 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 from within an interactive session or a batch job. This activates the
slurm-spank-x11 module. Note that this requires 'services.openssh.forwardX11' slurm-spank-x11 module. Note that this option also enables
to be enabled on the compute nodes. 'services.openssh.forwardX11' on the client.
''; '';
}; };
@ -130,6 +155,23 @@ in
the end of the slurm configuration file. 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>.
'';
};
}; };
}; };
@ -142,7 +184,7 @@ in
wrappedSlurm = pkgs.stdenv.mkDerivation { wrappedSlurm = pkgs.stdenv.mkDerivation {
name = "wrappedSlurm"; name = "wrappedSlurm";
propagatedBuildInputs = [ cfg.package configFile ]; propagatedBuildInputs = [ cfg.package etcSlurm ];
builder = pkgs.writeText "builder.sh" '' builder = pkgs.writeText "builder.sh" ''
source $stdenv/setup source $stdenv/setup
@ -155,7 +197,7 @@ in
#!/bin/sh #!/bin/sh
if [ -z "$SLURM_CONF" ] if [ -z "$SLURM_CONF" ]
then then
SLURM_CONF="${configFile}" "$EXE" "\$@" SLURM_CONF="${etcSlurm}/slurm.conf" "$EXE" "\$@"
else else
"$EXE" "\$0" "$EXE" "\$0"
fi fi
@ -165,7 +207,7 @@ in
''; '';
}; };
in mkIf (cfg.client.enable || cfg.server.enable) { in mkIf (cfg.enableStools || cfg.client.enable || cfg.server.enable) {
environment.systemPackages = [ wrappedSlurm ]; environment.systemPackages = [ wrappedSlurm ];
@ -190,6 +232,8 @@ in
''; '';
}; };
services.openssh.forwardX11 = mkIf cfg.client.enable (mkDefault true);
systemd.services.slurmctld = mkIf (cfg.server.enable) { systemd.services.slurmctld = mkIf (cfg.server.enable) {
path = with pkgs; [ wrappedSlurm munge coreutils ] path = with pkgs; [ wrappedSlurm munge coreutils ]
++ lib.optional cfg.enableSrunX11 slurm-spank-x11; ++ lib.optional cfg.enableSrunX11 slurm-spank-x11;