summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/computing/slurm/slurm.nix99
1 files changed, 99 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 00000000000..9c8261c6df1
--- /dev/null
+++ b/nixos/modules/services/computing/slurm/slurm.nix
@@ -0,0 +1,99 @@
+{ 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" 
+    ''
+    ${cfg.extraConfig}
+    '';
+in
+
+{
+
+  ###### interface
+
+  options = {
+
+    services.slurm = {
+
+      server = {
+        enable = mkOption {
+          default = false;
+          type = types.bool;
+          description = ''
+            Whether to enable slurm control daemon.
+          '';
+        };
+
+      };
+      
+      client = {
+        enable = mkOption {
+          default = false;
+          type = types.bool;
+          description = ''
+            Whether to enable slurm client daemon.
+          '';
+        };
+
+      };
+
+      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";
+        ExecStop = "${pkgs.coreutils}/bin/kill $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";
+        ExecStop = "${pkgs.coreutils}/bin/kill $MAINPID";
+      };
+      environment = { SLURM_CONF = "${configFile}"; };
+    };
+
+  };
+
+}