alqueva/hosts/shared/users.nix

60 lines
1.5 KiB
Nix
Raw Normal View History

{
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) attrsOf listOf submodule str package;
2025-02-06 01:51:42 +00:00
users = config.alqueva.users;
in {
options.alqueva.users = mkOption {
type = attrsOf (submodule {
options = {
tmpfiles = mkOption {
description = "tmpfiles";
type = listOf str;
default = [];
};
packages = mkOption {
type = listOf package;
default = [];
description = "Packages installed to the the defined user.";
};
groups = mkOption {
type = listOf str;
default = [];
description = "Groups to add the defined user to.";
};
shell = mkOption {
type = package;
default = config.programs.bash.package;
description = "Shell the user wants to use.";
};
enable = (mkEnableOption "this user.") // {default = true;};
};
});
2025-02-06 01:51:42 +00:00
description = "Users to have on the system.";
default = {};
};
2025-02-06 01:51:42 +00:00
config = let
enabledUsers = lib.filterAttrs (_: user: user.enable == true) users;
in {
users.users =
2025-02-06 01:51:42 +00:00
builtins.mapAttrs (un: uc: {
description = un;
isNormalUser = true;
2025-02-06 01:51:42 +00:00
extraGroups = uc.groups;
inherit (uc) packages shell;
2024-12-10 23:03:51 +00:00
initialPassword = "password";
})
2025-02-06 01:51:42 +00:00
enabledUsers;
systemd.user.tmpfiles.users =
2025-02-06 01:51:42 +00:00
builtins.mapAttrs (_: uc: {
rules = uc.tmpfiles;
})
2025-02-06 01:51:42 +00:00
enabledUsers;
};
}