1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{
config,
lib,
...
}: let
cfg = config.roles.base;
in {
options.roles.base = {
root = lib.mkOption {
type = lib.types.submodule {
options = {
hashedPasswordFile = lib.mkOption {
type = lib.types.path;
};
};
};
};
primaryUser = lib.mkOption {
type = lib.types.submodule {
options = {
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.primaryUser.username
])
];
config = let
homeDirectory = "/home/${cfg.primaryUser.username}";
in {
users.users.root.hashedPasswordFile = cfg.root.hashedPasswordFile;
users.users.${cfg.primaryUser.username} = {
isNormalUser = true;
extraGroups = lib.optional cfg.primaryUser.isWheel "wheel";
home = homeDirectory;
hashedPasswordFile = cfg.primaryUser.hashedPasswordFile;
};
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
};
hm.home = {
inherit (cfg.primaryUser) username;
inherit homeDirectory;
stateVersion = config.system.stateVersion;
};
};
}