1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-13 20:30:02 +00:00
This commit is contained in:
Kabir Oberai 2024-11-09 22:53:14 -05:00
parent 7d26a5f249
commit 93800d2951

View file

@ -226,11 +226,12 @@ fi
if [ "$action" = switch ] || [ "$action" = activate ] || [ "$action" = rollback ]; then
if [ "$USER" != root ]; then
# Running `$systemConfig/activate-user` causes subsequent sudo invocations to prompt
# for the password even if we previously ran sudo in the same session; indeed, by this
# point we've already run `nix-env --set` as sudo. To avoid prompting a second time,
# we become root *before* running activate-user and then drop down to the user to
# invoke it. This way, the call to activate doesn't require a password.
# Running `$systemConfig/activate-user` may cause subsequent sudo invocations to prompt
# for the password even if we previously ran sudo in the same session, since `brew` resets
# the sudo timestamp: see https://github.com/Homebrew/brew/pull/17694.
# Indeed, by this point we've already run `nix-env --set` as sudo. So to avoid prompting a
# second time, we become root *before* running activate-user and then drop down to the user
# to invoke it. This way, the call to `activate` doesn't require a password.
sudo @shell@ -c "$sudo_base -u $USER $systemConfig/activate-user && $systemConfig/activate"
else
"$systemConfig/activate-user"