launchd: allow customization of the default launchd prefix

This commit is contained in:
Wael M. Nasreddine 2020-04-14 14:53:31 -07:00 committed by Wael M. Nasreddine
parent 053f2cb9cb
commit cee84f4ea0
6 changed files with 29 additions and 1 deletions

View file

@ -88,7 +88,7 @@ let
${config.script}
'');
serviceConfig.Label = mkDefault "org.nixos.${name}";
serviceConfig.Label = mkDefault "${cfg.labelPrefix}.${name}";
serviceConfig.ProgramArguments = mkIf (cmd != "") [ "/bin/sh" "-c" "exec ${cmd}" ];
serviceConfig.EnvironmentVariables = mkIf (env != {}) env;
};
@ -97,6 +97,15 @@ in
{
options = {
launchd.labelPrefix = mkOption {
type = types.str;
default = "org.nixos";
description = ''
The default prefix of the service label. Individual services can
override this by setting the Label attribute.
'';
};
launchd.envVariables = mkOption {
type = types.attrsOf (types.either types.str (types.listOf types.str));
default = {};

View file

@ -51,6 +51,7 @@ in
serviceConfig.ProcessType = mkDefault "Interactive";
serviceConfig.LowPriorityIO = config.nix.daemonIONice;
serviceConfig.Nice = config.nix.daemonNiceLevel;
serviceConfig.Label = "org.nixos.nix-daemon"; # must match daemon installed by Nix regardless of the launchd label Prefix
serviceConfig.SoftResourceLimits.NumberOfFiles = mkDefault 4096;
serviceConfig.StandardErrorPath = cfg.logFile;