From 6e92bf094d45bc33d754e2b0f75d9ca1827cc363 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Tue, 19 May 2026 14:15:55 -0500 Subject: [PATCH] nix-darwin: pass DRY_RUN to activation Ensure nix-darwin Home Manager activation preserves DRY_RUN when invoking per-user activation through sudo. Closes #7344 --- nix-darwin/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix index cd3ceae71..259298290 100644 --- a/nix-darwin/default.nix +++ b/nix-darwin/default.nix @@ -24,7 +24,12 @@ in in '' echo Activating home-manager configuration for ${usercfg.home.username} >&2 - launchctl asuser "$(id -u ${usercfg.home.username})" sudo -u ${usercfg.home.username} --set-home ${pkgs.writeShellScript "activation-${usercfg.home.username}" '' + hmDryRunArgs=() + hmParentArgs="$(ps -p "$PPID" -ww -o args= || true)" + if [[ -v DRY_RUN || "$hmParentArgs" == *" --dry-run"* ]]; then + hmDryRunArgs=(env DRY_RUN=1) + fi + launchctl asuser "$(id -u ${usercfg.home.username})" sudo -u ${usercfg.home.username} --set-home "''${hmDryRunArgs[@]}" ${pkgs.writeShellScript "activation-${usercfg.home.username}" '' ${lib.optionalString ( cfg.backupFileExtension != null ) "export HOME_MANAGER_BACKUP_EXT=${lib.escapeShellArg cfg.backupFileExtension}"}