diff options
| author | Daiderd Jordan <daiderd@gmail.com> | 2016-12-19 21:38:34 +0100 |
|---|---|---|
| committer | Daiderd Jordan <daiderd@gmail.com> | 2016-12-19 21:50:22 +0100 |
| commit | 698713f2d92a76aff71699eb7b384c3bec74bb62 (patch) | |
| tree | 61a4f5089a434c72eedd0fe1f048eea4cb692fec /modules/system | |
| parent | 58e4f7d0cffb675d3c2026efa936d33d86d7ee2a (diff) | |
improve launchd activation
Diffstat (limited to 'modules/system')
| -rw-r--r-- | modules/system/launchd.nix | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/modules/system/launchd.nix b/modules/system/launchd.nix index fc85af4..4083353 100644 --- a/modules/system/launchd.nix +++ b/modules/system/launchd.nix @@ -11,6 +11,14 @@ let mkTextDerivation = pkgs.writeText; }; + launchdActivation = basedir: target: '' + if test -f '/Library/${basedir}/${target}'; then + launchctl unload '/Library/${basedir}/${target}' + fi + cp -f '${cfg.build.launchd}/Library/${basedir}/${target}' '/Library/${basedir}/${target}' + launchctl load '/Library/${basedir}/${target}' + ''; + launchAgents = filter (f: f.enable) (attrValues config.environment.launchAgents); launchDaemons = filter (f: f.enable) (attrValues config.environment.launchDaemons); @@ -51,12 +59,8 @@ in # Set up launchd services in /Library/LaunchAgents and /Library/LaunchDaemons echo "setting up launchd services..." - ${concatMapStringsSep "\n" (attr: "launchctl unload '/Library/LaunchAgents/${attr.target}'") launchAgents} - ${concatMapStringsSep "\n" (attr: "launchctl unload '/Library/LaunchDaemons/${attr.target}'") launchDaemons} - ${concatMapStringsSep "\n" (attr: "cp -f '${cfg.build.launchd}/Library/LaunchAgents/${attr.target}' '/Library/LaunchAgents/${attr.target}'") launchAgents} - ${concatMapStringsSep "\n" (attr: "cp -f '${cfg.build.launchd}/Library/LaunchDaemons/${attr.target}' '/Library/LaunchDaemons/${attr.target}'") launchDaemons} - ${concatMapStringsSep "\n" (attr: "launchctl load '/Library/LaunchAgents/${attr.target}'") launchAgents} - ${concatMapStringsSep "\n" (attr: "launchctl load '/Library/LaunchDaemons/${attr.target}'") launchDaemons} + ${concatMapStringsSep "\n" (attr: launchdActivation "LaunchAgents" attr.target) launchAgents} + ${concatMapStringsSep "\n" (attr: launchdActivation "LaunchDaemons" attr.target) launchDaemons} ''; }; |
