1 { config, pkgs, lib, ... }:
4 cfg = config.services.salt.master;
6 fullConfig = lib.recursiveUpdate {
7 # Provide defaults for some directories to allow an immutable config dir
9 # Default is equivalent to /etc/salt/master.d/*.conf
10 default_include = "/var/lib/salt/master.d/*.conf";
11 # Default is in /etc/salt/pki/master
12 pki_dir = "/var/lib/salt/pki/master";
19 services.salt.master = {
20 enable = lib.mkEnableOption "Salt configuration management system master service";
21 configuration = lib.mkOption {
22 type = lib.types.attrs;
24 description = "Salt master configuration as Nix attribute set.";
29 config = lib.mkIf cfg.enable {
31 # Set this up in /etc/salt/master so `salt`, `salt-key`, etc. work.
32 # The alternatives are
33 # - passing --config-dir to all salt commands, not just the master unit,
34 # - setting a global environment variable,
35 etc."salt/master".source = pkgs.writeText "master" (
36 builtins.toJSON fullConfig
38 systemPackages = with pkgs; [ salt ];
40 systemd.services.salt-master = {
41 description = "Salt Master";
42 wantedBy = [ "multi-user.target" ];
43 after = [ "network.target" ];
45 util-linux # for dmesg
48 ExecStart = "${pkgs.salt}/bin/salt-master";
54 config.environment.etc."salt/master".source
59 meta.maintainers = with lib.maintainers; [ Flakebi ];