-
-
Notifications
You must be signed in to change notification settings - Fork 472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
darwin-rebuild: Don't prompt for sudo multiple times #1147
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@emilazy any thoughts on this PR?
I don’t suppose My thoughts:
(1) is the only blocker here for me, but the factors combined make me wonder if it’s worth doing this right now. It’d be good to understand what’s causing this better, since it seems like most people don’t experience this problem – would you perhaps be able to share your nix-darwin configuration, or at least the Homebrew portion of it? |
So I just did some more digging and discovered that this is a "feature" of homebrew, introduced in Homebrew/brew#17694. Current source here: https://github.com/Homebrew/brew/blob/451c3a8735eb9b3050e40802a771eddf7c23e568/bin/brew#L72 I've boiled it down to this MRE: sudo ls # asks for password
brew --help
sudo ls # asks again!
@emilazy responding to some of your other points: 1: Dropping the 2: Going by the fact that this is in the 3: In that case could we go a step further and do the elevate/drop dance at the point where we first invoke 6: It's good to hear that! I recall instinctively trying Let me know if you still want more details about my configuration — or whether you're able to repro the MRE ootb. |
Re (1), I think I would prefer Moving more stuff from activation scripts into launchd daemons, in line with NixOS’s trajectory, is definitely a goal. We technically do already have a system activation daemon that runs as boot, but it barely activates anything… (see #726). Activation changes will also make it easier for us to support multi‐user setups and to mostly reuse existing NixOS deployment tools, which is pretty exciting, and part of the reason I’m hesitant to introduce more activation complexity that we’d have to preserve for a while for backwards compatibility. |
I've seen this behavior for a long time, but never bothered reporting it or looking into it :P Mainly because i just need to move my finger a few inches, but it is kinda annoying if I want to kick off a rebuild and walk away. |
For what it's worth, this also happens to me, but I didn't care enough to report it. My sudo timeout is 30 minutes. The issue started a few months ago around the time the change to restart the dock on activation is introduced if I remember correctly Edit: somehow after writing my comment I realized that the double sudo prompt doesn't happen anymore for me recently. However, I still get promoted for sudo once even when my sudo session hasn't expired. |
I also get prompted for password ~3 times for darwin-rebuild with Homebrew and sudo timeout, across multiple machines. I've temporarily removed Homebrew to avoid this. |
I've found that
darwin-rebuild switch
always asks me for sudo permissions twice — once when it runssudo nix-env --set
and the second time when it runssudo $systemConfig/activate
— even though I have a reasonable (default)timestamp_timeout
.In debugging this, I realized that the call to
brew bundle
withinactivate-user
was somehow making it so that the nextsudo
invocation would require a password again. I'm honestly not sure of the root cause behind this strange behavior exhibited bybrew bundle
, but as a workaround I realized that if we 1) elevate privileges, 2) drop down to callactivate-user
, and 3) callactivate
in the elevated context, we don't need tosudo
again since we're already root.FWIW I'm open to input here, especially as a new nix-darwin user: is this issue specific to me or is everyone just used to authenticating twice? Do let me know if I'm "holding it wrong". But Brew Bundle aside, this PR does work around the general issue where arbitrary user scripts in
activate-user
can result in sudo prompting again, so I think this might be worth merging regardless of the root cause.