summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2017-05-14 00:26:22 +0200
committerDaiderd Jordan <daiderd@gmail.com>2017-05-14 00:34:34 +0200
commit264a9237ddaa451efcd77e5fc2d9f78598447caf (patch)
treed3f27d129acebad18c33a5927d192a9bd5bcc629 /modules/system
parenta4eb645d0da4ce4743d86e1cfad7f7deb94de52c (diff)
launchd: add options for setting launchd environment variables
Fixes #12
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/launchd.nix10
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/system/launchd.nix b/modules/system/launchd.nix
index b667efa..2960df8 100644
--- a/modules/system/launchd.nix
+++ b/modules/system/launchd.nix
@@ -11,6 +11,10 @@ let
mkTextDerivation = pkgs.writeText;
};
+ launchdVariables = mapAttrsToList (name: value: ''
+ launchctl setenv ${name} '${value}'
+ '');
+
launchdActivation = basedir: target: ''
if ! diff '${cfg.build.launchd}/Library/${basedir}/${target}' '/Library/${basedir}/${target}' &> /dev/null; then
if test -f '/Library/${basedir}/${target}'; then
@@ -86,7 +90,9 @@ in
system.activationScripts.launchd.text = ''
# Set up launchd services in /Library/LaunchAgents and /Library/LaunchDaemons
- echo "setting up launchd services..."
+ echo "setting up launchd services..." >&2
+
+ ${concatStringsSep "\n" (launchdVariables config.launchd.envVariables)}
${concatMapStringsSep "\n" (attr: launchdActivation "LaunchAgents" attr.target) launchAgents}
${concatMapStringsSep "\n" (attr: launchdActivation "LaunchDaemons" attr.target) launchDaemons}
@@ -112,6 +118,8 @@ in
# Set up user launchd services in ~/Library/LaunchAgents
echo "setting up user launchd services..."
+ ${concatStringsSep "\n" (launchdVariables config.launchd.user.envVariables)}
+
${concatMapStringsSep "\n" (attr: userLaunchdActivation attr.target) userLaunchAgents}
for f in $(ls /run/current-system/user/Library/LaunchAgents); do