Files
nix-config/modules/nixos/base/user-group.nix
2026-03-10 23:45:55 +08:00

48 lines
1.1 KiB
Nix

{
myvars,
config,
...
}:
{
# Don't allow mutation of users outside the config.
users.mutableUsers = false;
users.groups = {
"${myvars.username}" = { };
podman = { };
docker = { };
wireshark = { };
# for android platform tools's udev rules
adbusers = { };
dialout = { };
# for openocd (embedded system development)
plugdev = { };
# misc
uinput = { };
};
users.users."${myvars.username}" = {
# we have to use initialHashedPassword here when using tmpfs for /
inherit (myvars) initialHashedPassword;
home = "/home/${myvars.username}";
isNormalUser = true;
extraGroups = [
myvars.username
"users"
"wheel"
"networkmanager" # for nmtui / nm-connection-editor
"podman"
"docker"
"wireshark"
"adbusers" # android debugging
"libvirtd" # virt-viewer / qemu
];
};
# root's ssh key are mainly used for remote deployment
users.users.root = {
inherit (myvars) initialHashedPassword;
openssh.authorizedKeys.keys = myvars.mainSshAuthorizedKeys ++ myvars.secondaryAuthorizedKeys;
};
}