mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-16 05:18:17 +00:00
launchd: add command, path and environment options
This commit is contained in:
parent
44d4d2b277
commit
d014ed2445
2 changed files with 48 additions and 9 deletions
|
@ -34,9 +34,7 @@ in {
|
||||||
environment.systemPath = mkOption {
|
environment.systemPath = mkOption {
|
||||||
type = types.loeOf types.path;
|
type = types.loeOf types.path;
|
||||||
default = (reverseList cfg.profiles) ++ [ "/usr/local" "/usr" "" ];
|
default = (reverseList cfg.profiles) ++ [ "/usr/local" "/usr" "" ];
|
||||||
description = ''
|
description = "The set of paths that are added to PATH.";
|
||||||
The set of paths that are added to PATH
|
|
||||||
'';
|
|
||||||
apply = x: if isList x then makeBinPath x else x;
|
apply = x: if isList x then makeBinPath x else x;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,9 +46,7 @@ in {
|
||||||
"/nix/var/nix/profiles/default"
|
"/nix/var/nix/profiles/default"
|
||||||
"/run/current-system/sw"
|
"/run/current-system/sw"
|
||||||
];
|
];
|
||||||
description = ''
|
description = "A list of profiles used to setup the global environment.";
|
||||||
A list of profiles used to setup the global environment.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.extraOutputsToInstall = mkOption {
|
environment.extraOutputsToInstall = mkOption {
|
||||||
|
@ -63,14 +59,13 @@ in {
|
||||||
environment.loginShell = mkOption {
|
environment.loginShell = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "$SHELL";
|
default = "$SHELL";
|
||||||
description = ''
|
description = "Configure default login shell.";
|
||||||
Configure default login shell.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.variables = mkOption {
|
environment.variables = mkOption {
|
||||||
type = types.attrsOf (types.either types.str (types.listOf types.str));
|
type = types.attrsOf (types.either types.str (types.listOf types.str));
|
||||||
default = {};
|
default = {};
|
||||||
|
example = { EDITOR = "vim"; LANG = "nl_NL.UTF-8"; };
|
||||||
description = ''
|
description = ''
|
||||||
A set of environment variables used in the global environment.
|
A set of environment variables used in the global environment.
|
||||||
These variables will be set on shell initialisation.
|
These variables will be set on shell initialisation.
|
||||||
|
|
|
@ -16,7 +16,49 @@ let
|
||||||
|
|
||||||
serviceOptions =
|
serviceOptions =
|
||||||
{ config, name, ... }:
|
{ config, name, ... }:
|
||||||
|
let
|
||||||
|
|
||||||
|
cmd = config.command;
|
||||||
|
env = config.environment // optionalAttrs (config.path != "") { PATH = config.path; };
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
{ options = {
|
{ options = {
|
||||||
|
environment = mkOption {
|
||||||
|
type = types.attrsOf (types.either types.str (types.listOf types.str));
|
||||||
|
default = {};
|
||||||
|
example = { PATH = "/foo/bar/bin"; LANG = "nl_NL.UTF-8"; };
|
||||||
|
description = "Environment variables passed to the service's processes.";
|
||||||
|
apply = mapAttrs (n: v: if isList v then concatStringsSep ":" v else v);
|
||||||
|
};
|
||||||
|
|
||||||
|
path = mkOption {
|
||||||
|
type = types.listOf types.path;
|
||||||
|
default = [];
|
||||||
|
apply = ps: "${makeBinPath ps}";
|
||||||
|
description = ''
|
||||||
|
Packages added to the service's <envar>PATH</envar>
|
||||||
|
environment variable. Both the <filename>bin</filename>
|
||||||
|
and <filename>sbin</filename> subdirectories of each
|
||||||
|
package are added.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
command = mkOption {
|
||||||
|
type = types.either types.str types.path;
|
||||||
|
default = "";
|
||||||
|
description = "Command executed as the service's main process.";
|
||||||
|
};
|
||||||
|
|
||||||
|
# preStart = mkOption {
|
||||||
|
# type = types.lines;
|
||||||
|
# default = "";
|
||||||
|
# description = ''
|
||||||
|
# Shell commands executed before the service's main process
|
||||||
|
# is started.
|
||||||
|
# '';
|
||||||
|
# };
|
||||||
|
|
||||||
serviceConfig = mkOption {
|
serviceConfig = mkOption {
|
||||||
type = types.submodule launchdConfig;
|
type = types.submodule launchdConfig;
|
||||||
example =
|
example =
|
||||||
|
@ -33,6 +75,8 @@ let
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
serviceConfig.Label = mkDefault "org.nixos.${name}";
|
serviceConfig.Label = mkDefault "org.nixos.${name}";
|
||||||
|
serviceConfig.ProgramArguments = mkIf (cmd != "") [ "/bin/sh" "-c" "exec ${cmd}" ];
|
||||||
|
serviceConfig.EnvironmentVariables = mkIf (env != {}) env;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue