I installed and am trying to get started with NixOS, and am trying to add my user to the sudoers file.
So that I'm not running all my commands as root I created a user following Chapter 7. User Management of the NixOS manual. That is, I ran
# useradd -m matthew
# su - matthew -c "true"
# passwd matthew
Enter new UNIX password: ***
Retype new UNIX password: ***
And also I added
users.extraUsers.matthew = {
isNormalUser = true;
home = "/home/matthew";
extragroups = [ "wheel" "networkmanager" ];
}
to /etc/nixos/configuration.nix
. But still I am not able to run sudo
as matthew
.
For example, when I try to open sudo's man page with sudo, I get the matthew is not in the sudoers file
error.
$ sudo man sudo
[sudo] password for matthew:
matthew is not in the sudoers file. This incident will be reported.
Then I tried following advice on how to add a user to the sudoers file in other distributions, namely editing with $ visudo
. But when I run that, nixos tells me not to edit that file. That is, running
$ visudo
opens /etc/sudoers.tmp
with first line reading
# Don't edit this file. Set the NixOS option ‘security.sudo.configFile’ instead.
How do I set the NixOS option ‘security.sudo.configFile’?
"wheel"
toextraGroups
worked just fine. Note that it'sextraGroups
and notextragroups
. – shadowtalker Sep 06 '18 at 15:09