slurm: impl simple service
This commit is contained in:
parent
69e59e9962
commit
0b1cc3cd51
99
nixos/modules/services/computing/slurm/slurm.nix
Normal file
99
nixos/modules/services/computing/slurm/slurm.nix
Normal file
@ -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}"; };
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user