From b740fb3106c5a63ed6dd2b6d368b6e57303bb2b7 Mon Sep 17 00:00:00 2001 From: Haonan Chen Date: Fri, 2 Jan 2026 11:23:34 +0800 Subject: [PATCH] nixos/slurm: add extraFlags option to slurmctld service --- .../services/computing/slurm/slurm.nix | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/computing/slurm/slurm.nix b/nixos/modules/services/computing/slurm/slurm.nix index 52e6ef873f17..f6f3fac6c5f0 100644 --- a/nixos/modules/services/computing/slurm/slurm.nix +++ b/nixos/modules/services/computing/slurm/slurm.nix @@ -3,6 +3,7 @@ lib, options, pkgs, + utils, ... }: let @@ -83,6 +84,28 @@ in slurm to work properly (see `services.munge.password`). ''; }; + + flags = lib.mkOption { + type = lib.types.attrsOf ( + lib.types.oneOf [ + lib.types.str + lib.types.bool + lib.types.float + lib.types.int + ] + ); + default = { }; + example = { + "i" = true; + "systemd" = true; + "L" = "/var/log/file with space.log"; + "n" = 10; + }; + description = '' + Flags passed to `slurmctld` daemon, see {manpage}`slurmctld(8)`. + Special characters are properly escaped. + ''; + }; }; dbdserver = { @@ -484,7 +507,17 @@ in serviceConfig = { Type = "forking"; - ExecStart = "${wrappedSlurm}/bin/slurmctld"; + ExecStart = + let + isLong = optionName: builtins.stringLength optionName > 1; + flagFormat = optionName: { + option = if isLong optionName then "--${optionName}" else "-${optionName}"; + sep = null; + explicitBool = false; + }; + cli = [ "${wrappedSlurm}/bin/slurmctld" ] ++ lib.cli.toCommandLine flagFormat cfg.server.flags; + in + utils.escapeSystemdExecArgs cli; PIDFile = "/run/slurmctld.pid"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; };