diff options
author | Arseniy Seroka <jagajaga@users.noreply.github.com> | 2015-03-19 21:06:49 +0300 |
---|---|---|
committer | Arseniy Seroka <jagajaga@users.noreply.github.com> | 2015-03-19 21:06:49 +0300 |
commit | 9cfdeba3249062a094df131327c38f53881eb6b6 (patch) | |
tree | 424c0771d20839dfaf19de40e14d2ee5c1fd5d08 /nixos/modules/services | |
parent | afb0874e060298f2fadb770201547b931a014336 (diff) | |
parent | 30e6f1b4eaed19848e0e76b550be04320e7ae8b3 (diff) | |
download | nixlib-9cfdeba3249062a094df131327c38f53881eb6b6.tar nixlib-9cfdeba3249062a094df131327c38f53881eb6b6.tar.gz nixlib-9cfdeba3249062a094df131327c38f53881eb6b6.tar.bz2 nixlib-9cfdeba3249062a094df131327c38f53881eb6b6.tar.lz nixlib-9cfdeba3249062a094df131327c38f53881eb6b6.tar.xz nixlib-9cfdeba3249062a094df131327c38f53881eb6b6.tar.zst nixlib-9cfdeba3249062a094df131327c38f53881eb6b6.zip |
Merge pull request #6611 from jagajaga/slurm
Slurm module
Diffstat (limited to 'nixos/modules/services')
-rw-r--r-- | nixos/modules/services/computing/slurm/slurm.nix | 130 | ||||
-rw-r--r-- | nixos/modules/services/security/munge.nix | 61 |
2 files changed, 191 insertions, 0 deletions
diff --git a/nixos/modules/services/computing/slurm/slurm.nix b/nixos/modules/services/computing/slurm/slurm.nix new file mode 100644 index 000000000000..019d7fbb16cd --- /dev/null +++ b/nixos/modules/services/computing/slurm/slurm.nix @@ -0,0 +1,130 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + 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}''} + ${optionalString (cfg.nodeName != null) ''nodeName=${cfg.nodeName}''} + ${optionalString (cfg.partitionName != null) ''partitionName=${cfg.partitionName}''} + ${cfg.extraConfig} + ''; +in + +{ + + ###### interface + + options = { + + services.slurm = { + + server = { + enable = mkEnableOption "slurm control daemon"; + + }; + + client = { + enable = mkEnableOption "slurm rlient daemon"; + + }; + + controlMachine = mkOption { + type = types.nullOr types.str; + default = null; + example = null; + description = '' + The short hostname of the machine where SLURM control functions are + executed (i.e. the name returned by the command "hostname -s", use "tux001" + rather than "tux001.my.com"). + ''; + }; + + controlAddr = mkOption { + type = types.nullOr types.str; + default = cfg.controlMachine; + example = null; + description = '' + Name that ControlMachine should be referred to in establishing a + communications path. + ''; + }; + + nodeName = mkOption { + type = types.nullOr types.str; + default = null; + example = "linux[1-32] CPUs=1 State=UNKNOWN"; + description = '' + Name that SLURM uses to refer to a node (or base partition for BlueGene + systems). Typically this would be the string that "/bin/hostname -s" + returns. Note that now you have to write node's parameters after the name. + ''; + }; + + partitionName = mkOption { + type = types.nullOr types.str; + default = null; + 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. + ''; + }; + + extraConfig = mkOption { + default = ""; + type = types.lines; + description = '' + Extra configuration options that will be added verbatim at + the end of the slurm configuration file. + ''; + }; + }; + + }; + + + ###### implementation + + config = mkIf (cfg.client.enable || cfg.server.enable) { + + environment.systemPackages = [ pkgs.slurm-llnl ]; + + systemd.services.slurmd = mkIf (cfg.client.enable) { + path = with pkgs; [ slurm-llnl coreutils ]; + + wantedBy = [ "multi-user.target" ]; + after = [ "systemd-tmpfiles-clean.service" ]; + + serviceConfig = { + Type = "forking"; + ExecStart = "${pkgs.slurm-llnl}/bin/slurmd -f ${configFile}"; + PIDFile = "/run/slurmd.pid"; + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + }; + }; + + systemd.services.slurmctld = mkIf (cfg.server.enable) { + path = with pkgs; [ slurm-llnl munge coreutils ]; + + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" "auditd.service" "munged.service" "slurmdbd.service" ]; + requires = [ "munged.service" ]; + + serviceConfig = { + Type = "forking"; + ExecStart = "${pkgs.slurm-llnl}/bin/slurmctld"; + PIDFile = "/run/slurmctld.pid"; + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + }; + environment = { SLURM_CONF = "${configFile}"; }; + }; + + }; + +} diff --git a/nixos/modules/services/security/munge.nix b/nixos/modules/services/security/munge.nix new file mode 100644 index 000000000000..919c2c2b0e15 --- /dev/null +++ b/nixos/modules/services/security/munge.nix @@ -0,0 +1,61 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.munge; + +in + +{ + + ###### interface + + options = { + + services.munge = { + enable = mkEnableOption "munge service"; + + password = mkOption { + default = "/etc/munge/munge.key"; + type = types.string; + description = '' + The path to a daemon's secret key. + ''; + }; + + }; + + }; + + ###### implementation + + config = mkIf cfg.enable { + + environment.systemPackages = [ pkgs.munge ]; + + systemd.services.munged = { + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + + path = [ pkgs.munge pkgs.coreutils ]; + + preStart = '' + chmod 0700 ${cfg.password} + mkdir -p /var/lib/munge -m 0711 + mkdir -p /var/log/munge -m 0700 + mkdir -p /run/munge -m 0755 + ''; + + serviceConfig = { + ExecStart = "${pkgs.munge}/bin/munged --syslog --key-file ${cfg.password}"; + PIDFile = "/run/munge/munged.pid"; + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + }; + + }; + + }; + +} |