at v192 3.7 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.slurm; 8 # configuration file can be generated by http://slurm.schedmd.com/configurator.html 9 configFile = pkgs.writeText "slurm.conf" 10 '' 11 ${optionalString (cfg.controlMachine != null) ''controlMachine=${cfg.controlMachine}''} 12 ${optionalString (cfg.controlAddr != null) ''controlAddr=${cfg.controlAddr}''} 13 ${optionalString (cfg.nodeName != null) ''nodeName=${cfg.nodeName}''} 14 ${optionalString (cfg.partitionName != null) ''partitionName=${cfg.partitionName}''} 15 ${cfg.extraConfig} 16 ''; 17in 18 19{ 20 21 ###### interface 22 23 options = { 24 25 services.slurm = { 26 27 server = { 28 enable = mkEnableOption "slurm control daemon"; 29 30 }; 31 32 client = { 33 enable = mkEnableOption "slurm rlient daemon"; 34 35 }; 36 37 controlMachine = mkOption { 38 type = types.nullOr types.str; 39 default = null; 40 example = null; 41 description = '' 42 The short hostname of the machine where SLURM control functions are 43 executed (i.e. the name returned by the command "hostname -s", use "tux001" 44 rather than "tux001.my.com"). 45 ''; 46 }; 47 48 controlAddr = mkOption { 49 type = types.nullOr types.str; 50 default = cfg.controlMachine; 51 example = null; 52 description = '' 53 Name that ControlMachine should be referred to in establishing a 54 communications path. 55 ''; 56 }; 57 58 nodeName = mkOption { 59 type = types.nullOr types.str; 60 default = null; 61 example = "linux[1-32] CPUs=1 State=UNKNOWN"; 62 description = '' 63 Name that SLURM uses to refer to a node (or base partition for BlueGene 64 systems). Typically this would be the string that "/bin/hostname -s" 65 returns. Note that now you have to write node's parameters after the name. 66 ''; 67 }; 68 69 partitionName = mkOption { 70 type = types.nullOr types.str; 71 default = null; 72 example = "debug Nodes=linux[1-32] Default=YES MaxTime=INFINITE State=UP"; 73 description = '' 74 Name by which the partition may be referenced. Note that now you have 75 to write patrition's parameters after the name. 76 ''; 77 }; 78 79 extraConfig = mkOption { 80 default = ""; 81 type = types.lines; 82 description = '' 83 Extra configuration options that will be added verbatim at 84 the end of the slurm configuration file. 85 ''; 86 }; 87 }; 88 89 }; 90 91 92 ###### implementation 93 94 config = mkIf (cfg.client.enable || cfg.server.enable) { 95 96 environment.systemPackages = [ pkgs.slurm-llnl ]; 97 98 systemd.services.slurmd = mkIf (cfg.client.enable) { 99 path = with pkgs; [ slurm-llnl coreutils ]; 100 101 wantedBy = [ "multi-user.target" ]; 102 after = [ "systemd-tmpfiles-clean.service" ]; 103 104 serviceConfig = { 105 Type = "forking"; 106 ExecStart = "${pkgs.slurm-llnl}/bin/slurmd -f ${configFile}"; 107 PIDFile = "/run/slurmd.pid"; 108 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 109 }; 110 }; 111 112 systemd.services.slurmctld = mkIf (cfg.server.enable) { 113 path = with pkgs; [ slurm-llnl munge coreutils ]; 114 115 wantedBy = [ "multi-user.target" ]; 116 after = [ "network.target" "auditd.service" "munged.service" "slurmdbd.service" ]; 117 requires = [ "munged.service" ]; 118 119 serviceConfig = { 120 Type = "forking"; 121 ExecStart = "${pkgs.slurm-llnl}/bin/slurmctld"; 122 PIDFile = "/run/slurmctld.pid"; 123 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 124 }; 125 environment = { SLURM_CONF = "${configFile}"; }; 126 }; 127 128 }; 129 130}