From 1b5fa6be405425ae5040d68c4a3bfff14fdf2100 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Tue, 5 Nov 2024 01:14:16 +1100 Subject: [PATCH] uninstaller: remove unnecessary attempt to delete `nix-daemon` Fixes https://github.com/LnL7/nix-darwin/issues/910 --- pkgs/darwin-uninstaller/configuration.nix | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pkgs/darwin-uninstaller/configuration.nix b/pkgs/darwin-uninstaller/configuration.nix index 6487774b..0bdccb98 100644 --- a/pkgs/darwin-uninstaller/configuration.nix +++ b/pkgs/darwin-uninstaller/configuration.nix @@ -7,31 +7,29 @@ with lib; assertions = mkForce []; system.activationScripts.checks.text = mkForce ""; - # Disable etc, launchd, ... environment.etc = mkForce {}; launchd.agents = mkForce {}; launchd.daemons = mkForce {}; launchd.user.agents = mkForce {}; system.activationScripts.postUserActivation.text = mkAfter '' - if test -L ~/.nix-defexpr/channels/darwin; then + if [[ -L ~/.nix-defexpr/channels/darwin ]]; then nix-channel --remove darwin || true fi ''; system.activationScripts.postActivation.text = mkAfter '' - if test -L /Applications/Nix\ Apps; then + if [[ -L /Applications/Nix\ Apps ]]; then rm /Applications/Nix\ Apps fi - if test -L /etc/static; then + if [[ -L /etc/static ]]; then rm /etc/static fi - if test -O /nix/store; then - if ! test -e /Library/LaunchDaemons/org.nixos.nix-daemon.plist; then - sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist || true - sudo launchctl remove org.nixos.nix-daemon 2> /dev/null || true + # If the Nix Store is owned by root then we're on a multi-user system + if [[ -O /nix/store ]]; then + if [[ -e /nix/var/nix/profiles/default/Library/LaunchDaemons/org.nixos.nix-daemon.plist ]]; then sudo cp /nix/var/nix/profiles/default/Library/LaunchDaemons/org.nixos.nix-daemon.plist /Library/LaunchDaemons/org.nixos.nix-daemon.plist sudo launchctl load -w /Library/LaunchDaemons/org.nixos.nix-daemon.plist fi