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 '';