From 0b1cc3cd5198afd07a918d206e3b73ad4ac42930 Mon Sep 17 00:00:00 2001 From: Arseniy Seroka Date: Sun, 1 Mar 2015 04:12:13 +0300 Subject: slurm: impl simple service --- nixos/modules/services/computing/slurm/slurm.nix | 99 ++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 nixos/modules/services/computing/slurm/slurm.nix (limited to 'nixos/modules/services/computing/slurm') diff --git a/nixos/modules/services/computing/slurm/slurm.nix b/nixos/modules/services/computing/slurm/slurm.nix new file mode 100644 index 000000000000..9c8261c6df13 --- /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}"; }; + }; + + }; + +} -- cgit 1.4.1