nixos-rebuild: use sudo when whoami != root#216710
Conversation
|
I think there should be a way to disable this functionality. I know this is not advised, but one might get a surprise if but maybe a |
|
That's fair enough. Although, that said, |
8385ec0 to
fa7eb3c
Compare
|
I think this version is a bit better, since it focuses on just the local build case. The remote build case is more complicated to handle well. |
|
Why not use --use-remote-sudo as a fallback? I am using that with an increased sudo timeout and think it should be better than running nix as root. Also does this overwrite --use-remote-sudo? Can this write flake.lock files with sudo? |
|
This isn't related to the change itself, but why use a branch on NixOS/nixpkgs? |
This change pretty much enables the
With this change, if you run And no,
No, all evaluation and realization happen without sudo, as they do with |
Sorry, I just have an alias that does |
Currently, executing `nixos-rebuild switch` as a non-root user will result in a somewhat confusing error about being unable to link a profile to a nix store path. This is not ideal, especially as we already have most of the code to handle this properly and use `sudo` to elevate permissions to install. This is preferrable for flakes (better eval caching), and also more intuitive for new users.
fa7eb3c to
ff8fd21
Compare
| is also set. This is useful when the target-host connection to cache.nixos.org | ||
| is faster than the connection between hosts. | ||
| . | ||
| .It Fl -no-auto-sudo |
There was a problem hiding this comment.
Isn't everything in the script automatic?
| .It Fl -no-auto-sudo | |
| .It Fl -no-sudo |
There was a problem hiding this comment.
Not quite, you can technically do --no-auto-sudo --use-remote-sudo. Although, there's no real reason for this, I guess. I'll make --use-remote-sudo and --no-sudo mutually exclusive.
That'd be equivalent to my I've made a habit out of renaming |
Description of changes
Currently, executing
nixos-rebuild switchas a non-root user willresult in a somewhat confusing error about being unable to link a
profile to a nix store path. This is not ideal, especially as we already
have most of the code to handle this properly and use
sudoto elevatepermissions to install.
This is preferrable for flakes (better eval caching), and also more
intuitive for new users.
FIXME
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)