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
This commit is contained in:
Austin Horstman
2026-05-19 14:15:55 -05:00
parent 509ed3c603
commit 6e92bf094d

View File

@@ -24,7 +24,12 @@ in
in in
'' ''
echo Activating home-manager configuration for ${usercfg.home.username} >&2 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 ( ${lib.optionalString (
cfg.backupFileExtension != null cfg.backupFileExtension != null
) "export HOME_MANAGER_BACKUP_EXT=${lib.escapeShellArg cfg.backupFileExtension}"} ) "export HOME_MANAGER_BACKUP_EXT=${lib.escapeShellArg cfg.backupFileExtension}"}