{
config,
lib,
...
}: let
cfg = config.roles.base;
in {
options.roles.base = {
username = lib.mkOption {
type = lib.types.str;
};
isWheel = lib.mkEnableOption "wheter to enable admin permissions";
hashedPasswordFile = lib.mkOption {
type = lib.types.path;
};
};
imports = [
(lib.mkAliasOptionModule ["hm"] [
"home-manager"
"users"
cfg.username
])
];
config = let
homeDirectory = "/home/${cfg.username}";
in {
users.users.${cfg.username} = {
isNormalUser = true;
extraGroups = lib.optional cfg.isWheel "wheel";
home = homeDirectory;
hashedPasswordFile = cfg.hashedPasswordFile;
};
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
};
hm.home = {
inherit (cfg) username;
inherit homeDirectory;
stateVersion = config.system.stateVersion;
};
};
}