summaryrefslogtreecommitdiff
path: root/modules/system
diff options
context:
space:
mode:
authorDaiderd Jordan <daiderd@gmail.com>2017-05-11 23:43:05 +0200
committerDaiderd Jordan <daiderd@gmail.com>2017-05-11 23:43:05 +0200
commit00315bcc9e3fc3337f4bb8c84b9aa8a39515c661 (patch)
treed4e8755f6eddb689ae590d3211a5568623030e37 /modules/system
parent8cb11d968f3a0a094602225973a4f4c38bc0e4a8 (diff)
launchd: don't use $HOME
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/default.nix6
-rw-r--r--modules/system/launchd.nix26
2 files changed, 14 insertions, 18 deletions
diff --git a/modules/system/default.nix b/modules/system/default.nix
index 4e08c74..fb59150 100644
--- a/modules/system/default.nix
+++ b/modules/system/default.nix
@@ -8,8 +8,6 @@ let
cfg = config.system;
- home = builtins.getEnv "HOME";
-
failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions);
throwAssertions = res: if (failedAssertions != []) then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}" else res;
@@ -96,8 +94,8 @@ in
ln -s ${cfg.build.launchd}/Library/LaunchAgents $out/Library/LaunchAgents
ln -s ${cfg.build.launchd}/Library/LaunchDaemons $out/Library/LaunchDaemons
- mkdir -p $out/${home}/Library
- ln -s ${cfg.build.launchd}/${home}/Library/LaunchAgents $out/${home}/Library/LaunchAgents
+ mkdir -p $out/user/Library
+ ln -s ${cfg.build.launchd}/user/Library/LaunchAgents $out/user/Library/LaunchAgents
echo "$activationScript" > $out/activate
substituteInPlace $out/activate --subst-var out
diff --git a/modules/system/launchd.nix b/modules/system/launchd.nix
index e8b9ecd..e0d2a62 100644
--- a/modules/system/launchd.nix
+++ b/modules/system/launchd.nix
@@ -6,8 +6,6 @@ let
cfg = config.system;
- home = builtins.getEnv "HOME";
-
text = import ../lib/write-text.nix {
inherit lib;
mkTextDerivation = pkgs.writeText;
@@ -24,12 +22,12 @@ let
'';
userLaunchdActivation = target: ''
- if ! diff '${cfg.build.launchd}${home}/Library/LaunchAgents/${target}' '${home}/Library/LaunchAgents/${target}'; then
- if test -f '${home}/Library/LaunchAgents/${target}'; then
- launchctl unload -w '${home}/Library/LaunchAgents/${target}' || true
+ if ! diff ${cfg.build.launchd}/user/Library/LaunchAgents/${target} ~/Library/LaunchAgents/${target}; then
+ if test -f ~/Library/LaunchAgents/${target}; then
+ launchctl unload -w ~/Library/LaunchAgents/${target} || true
fi
- cp -f '${cfg.build.launchd}${home}/Library/LaunchAgents/${target}' '${home}/Library/LaunchAgents/${target}'
- launchctl load '${home}/Library/LaunchAgents/${target}'
+ cp -f '${cfg.build.launchd}/user/Library/LaunchAgents/${target}' ~/Library/LaunchAgents/${target}
+ launchctl load ~/Library/LaunchAgents/${target}
fi
'';
@@ -71,12 +69,12 @@ in
config = {
system.build.launchd = pkgs.runCommand "launchd" {} ''
- mkdir -p $out/Library/LaunchAgents $out/Library/LaunchDaemons $out${home}/Library/LaunchAgents
+ mkdir -p $out/Library/LaunchAgents $out/Library/LaunchDaemons $out/user/Library/LaunchAgents
cd $out/Library/LaunchAgents
${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") launchAgents}
cd $out/Library/LaunchDaemons
${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") launchDaemons}
- cd $out${home}/Library/LaunchAgents
+ cd $out/user/Library/LaunchAgents
${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") userLaunchAgents}
'';
@@ -103,15 +101,15 @@ in
'';
system.activationScripts.userLaunchd.text = ''
- # Set up launchd services in ~/Library/LaunchAgents
+ # Set up user launchd services in ~/Library/LaunchAgents
echo "setting up user launchd services..."
${concatMapStringsSep "\n" (attr: userLaunchdActivation attr.target) userLaunchAgents}
- for f in $(ls /run/current-system${home}/Library/LaunchAgents); do
- if test ! -e "${cfg.build.launchd}${home}/Library/LaunchAgents/$f"; then
- launchctl unload -w "${home}/Library/LaunchAgents/$f" || true
- if test -e "${home}/Library/LaunchAgents/$f"; then rm -f "${home}/Library/LaunchAgents/$f"; fi
+ for f in $(ls /run/current-system/user/Library/LaunchAgents); do
+ if test ! -e "${cfg.build.launchd}/user/Library/LaunchAgents/$f"; then
+ launchctl unload -w ~/Library/LaunchAgents/$f || true
+ if test -e ~/Library/LaunchAgents/$f; then rm -f ~/Library/LaunchAgents/$f; fi
fi
done
'';