feat(nixos): add sudo module and refactor user options
This commit is contained in:
parent
03fca8b28b
commit
aa06b5f6fd
2 changed files with 13 additions and 8 deletions
11
nix/modules/system/sudo.nix
Normal file
11
nix/modules/system/sudo.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{ config, ... }:
|
||||
let
|
||||
cfg = config.flake;
|
||||
in
|
||||
{
|
||||
flake.modules.nixos.default = {
|
||||
security.sudo.wheelNeedsPassword = false;
|
||||
nix.settings.trusted-users = [ "@wheel" ];
|
||||
users.users.${cfg.admin.username}.extraGroups = [ "wheel" ];
|
||||
};
|
||||
}
|
|
@ -1,26 +1,20 @@
|
|||
{ config, lib, ... }:
|
||||
{ config, ... }:
|
||||
let
|
||||
cfg = config.flake;
|
||||
inherit (cfg.lib.modules) userListToAttrs forAllUsers';
|
||||
inherit (lib.lists) optional;
|
||||
in
|
||||
{
|
||||
flake.modules.nixos.default =
|
||||
{ config, ... }:
|
||||
{
|
||||
#TODO: move sudo/security options elsewhere
|
||||
# security.sudo.wheelNeedsPassword = false;
|
||||
# nix.settings.trusted-users = [ "@wheel" ];
|
||||
# persist uids and gids
|
||||
persistDirs = [ "/var/lib/nixos" ];
|
||||
users = {
|
||||
mutableUsers = false;
|
||||
groups.users.gid = 100;
|
||||
users = forAllUsers' (
|
||||
name: value: {
|
||||
name: _: {
|
||||
isNormalUser = true;
|
||||
hashedPasswordFile = config.sops.secrets."${name}/hashedPassword".path;
|
||||
extraGroups = optional (value.primary or false) "wheel";
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue