diff options
author | Lancelot SIX <lsix@lancelotsix.com> | 2015-12-25 15:54:35 +0100 |
---|---|---|
committer | Lancelot SIX <lsix@lancelotsix.com> | 2015-12-25 15:54:35 +0100 |
commit | ca4c35478979106fe64163c11606516e3b3d2e7e (patch) | |
tree | 6d26ec9beae1479f0dfae0331e08a068c692dd8f /nixos/modules/services/computing | |
parent | 66b294dd48508cac821b284543e6c0c9de03797b (diff) | |
download | nixlib-ca4c35478979106fe64163c11606516e3b3d2e7e.tar nixlib-ca4c35478979106fe64163c11606516e3b3d2e7e.tar.gz nixlib-ca4c35478979106fe64163c11606516e3b3d2e7e.tar.bz2 nixlib-ca4c35478979106fe64163c11606516e3b3d2e7e.tar.lz nixlib-ca4c35478979106fe64163c11606516e3b3d2e7e.tar.xz nixlib-ca4c35478979106fe64163c11606516e3b3d2e7e.tar.zst nixlib-ca4c35478979106fe64163c11606516e3b3d2e7e.zip |
slurm service: improve config
Diffstat (limited to 'nixos/modules/services/computing')
-rw-r--r-- | nixos/modules/services/computing/slurm/slurm.nix | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/nixos/modules/services/computing/slurm/slurm.nix b/nixos/modules/services/computing/slurm/slurm.nix index 019d7fbb16cd..cf00d8946557 100644 --- a/nixos/modules/services/computing/slurm/slurm.nix +++ b/nixos/modules/services/computing/slurm/slurm.nix @@ -34,6 +34,15 @@ in }; + package = mkOption { + type = types.package; + default = pkgs.slurm-llnl; + example = literalExample "pkgs.slurm-llnl-full"; + description = '' + The packge to use for slurm binaries. + ''; + }; + controlMachine = mkOption { type = types.nullOr types.str; default = null; @@ -91,38 +100,69 @@ in ###### implementation - config = mkIf (cfg.client.enable || cfg.server.enable) { + config = + let + wrappedSlurm = pkgs.stdenv.mkDerivation { + name = "wrappedSlurm"; + + propagatedBuildInputs = [ cfg.package configFile ]; + + builder = pkgs.writeText "builder.sh" '' + source $stdenv/setup + mkdir -p $out/bin + find ${cfg.package}/bin -type f -executable | while read EXE + do + exename="$(basename $EXE)" + wrappername="$out/bin/$exename" + cat > "$wrappername" <<EOT + #!/bin/sh + if [ -z "$SLURM_CONF" ] + then + SLURM_CONF="${configFile}" "$EXE" "\$@" + else + "$EXE" "\$0" + fi + EOT + chmod +x "$wrappername" + done + ''; + }; - environment.systemPackages = [ pkgs.slurm-llnl ]; + in mkIf (cfg.client.enable || cfg.server.enable) { + + environment.systemPackages = [ wrappedSlurm ]; systemd.services.slurmd = mkIf (cfg.client.enable) { - path = with pkgs; [ slurm-llnl coreutils ]; + path = with pkgs; [ wrappedSlurm coreutils ]; wantedBy = [ "multi-user.target" ]; after = [ "systemd-tmpfiles-clean.service" ]; serviceConfig = { Type = "forking"; - ExecStart = "${pkgs.slurm-llnl}/bin/slurmd -f ${configFile}"; + ExecStart = "${wrappedSlurm}/bin/slurmd"; PIDFile = "/run/slurmd.pid"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; }; + + preStart = '' + mkdir -p /var/spool + ''; }; systemd.services.slurmctld = mkIf (cfg.server.enable) { - path = with pkgs; [ slurm-llnl munge coreutils ]; + path = with pkgs; [ wrappedSlurm munge coreutils ]; wantedBy = [ "multi-user.target" ]; - after = [ "network.target" "auditd.service" "munged.service" "slurmdbd.service" ]; + after = [ "network.target" "munged.service" ]; requires = [ "munged.service" ]; serviceConfig = { Type = "forking"; - ExecStart = "${pkgs.slurm-llnl}/bin/slurmctld"; + ExecStart = "${wrappedSlurm}/bin/slurmctld"; PIDFile = "/run/slurmctld.pid"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; }; - environment = { SLURM_CONF = "${configFile}"; }; }; }; |