alqueva/hosts/shared/users.nix

68 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 = { };
};
config =
let
enabledUsers = lib.filterAttrs (_: user: user.enable == true) users;
in
{
users.users = builtins.mapAttrs (un: uc: {
2025-02-06 01:51:42 +00:00
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";
}) enabledUsers;
systemd.user.tmpfiles.users = builtins.mapAttrs (_: uc: {
rules = uc.tmpfiles;
}) enabledUsers;
};
}