Doas support
Currently if you use doas instead of sudo it doesn't work. I'm unsure how this would work in implementation but a nix option of what to use for superuser access would be great.
Updoot!
There is no interest from maintainers to suppory doas, as we do not use it and are not presented a strong argument for supporting it. Please consider opening a pull request if this is important to you.
@NotAShelf Ok, will try to make a PR for this
I was also wondering the reasoning behind why nh doesn't support being invoked with sudo, one such case where this may be useful is if a user wants to rebuild a system & leave their machine (i.e. to make a sandwich) while it rebuilds as the current implementation requires you to be present to enter your password.
sudo nh os switch -R
I was also wondering the reasoning behind why nh doesn't support being invoked with sudo, one such case where this may be useful is if a user wants to rebuild a system & leave their machine (i.e. to make a sandwich) while it rebuilds as the current implementation requires you to be present to enter your password.
It does support being invoked with sudo, but it's not recommended. Running all commands with sudo even when there is no need for it is a security flaw. By default nh only elevates privileges when necessary, i.e., when we're switching generations.
Oh, ok thanks for clearing that up
$ sudo nh os switch -f '<nixpkgs/nixos>' -- -I nixos-config=/etc/nixos/configuration.nix -R
Error:
0: Don't run nh os as root. I will call sudo internally as needed
Location:
src/nixos.rs:59
as seen above it was previously not working when I was parsing the -R flag
however, it seems to work fine with the long flag (--bypass-root-check), but this only seems to be an issue on my current system, weird.
You have to pass -R to nh, not to nix:
sudo nh os switch -R -f '<nixpkgs/nixos>' -- -I nixos-config=/etc/nixos/configuration.nix
On my two machines, nh works with doas flawlesly with doas-sudo-shim package installed. There is no sudo installed on my systems and everything works as expected.
nh os switch works with doas-sudo-shim but nh clean fails because --preserve-env is not supported