I am trying to get disk group added to a user, but it does not seem to be working after rebuilding/rebooting.
users.users = {
sergio = {
isNormalUser = true;
description = "Sergio";
extraGroups = [
"disk"
"incus-admin"
"kvm"
"libvirt"
"networkmanager"
"plugdev"
"video"
"wheel"
"wireshark"
];
};
};
Actual groups:
groups
users wheel video networkmanager kvm incus-admin
Not sure why it isn’t adding the other groups, but really wanting disk to be one of them.
Do these additional groups exist? You can check /etc/group. NixOS cannot add your user to groups that do not exist.
Just off of the top of my head, I’m pretty sure the libvirt group is libvirtd.
You can also check config.users.groups in the repl.
True for libvirtd I updated it, thanks!
But disk does exist:
cat /etc/group | grep disk
disk:x:6:
Adding my user to disk works for me, are your users and groups entirely managed using the NixOS module system (mutableUsers = false)? Setting it to true (default) should “merge” the new changes but maybe it isn’t applying properly…
I don’t seem to have mutableUsers set anywhere. Good point tough.
The default (if unset) is true, you can check config.users.mutableUsers in the repl. You can consider switching to mutableUsers = false if you do not wish to imperatively manage your users - otherwise you can simply add your user to disk using usermod -aG.
Thanks, I’ll look into it. I thought that if it wasn’t set, it would add groups when extraGroups were set.
are you sure your config is actually being activated? this sounds suspicious… it should work
it should… changes to your config should be “merged” even if mutableUsers = true - except for existing passwords.
mutableUsers - If set to true, you are free to add new users and groups to the system with the ordinary useradd and groupadd commands. On system activation, the existing contents of the /etc/passwd and /etc/group files will be merged with the contents generated from the users.users and users.groups options. The initial password for a user will be set according to users.users, but existing passwords will not be changed.
1 Like
Very strangely, I rebuilt again, rebooted and all groups show. extraGroups is indeed set to true, by default.
Pretty confident that I had rebuilt and rebooted the other times too…
Thanks for the help! 
1 Like