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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
{home-manager, ...}: let
commonHM = {
nixpkgs.config = {
allowUnfree = true;
allowUnsupportedSystem = true;
};
xdg.configFile."nixpkgs/config.nix".text = ''
{
allowUnfree = true;
}
'';
};
in {
mkHMUser = {
username,
channel,
modules ? [],
stateVersion ? "22.11",
system ? "x86_64-linux",
extraSpecialArgs ? {},
}:
home-manager.lib.homeManagerConfiguration {
pkgs = channel.legacyPackages.${system};
inherit extraSpecialArgs;
modules =
[
../users/${username}/home.nix
({pkgs, ...}:
{
home = {
inherit username stateVersion;
homeDirectory = "/home/${username}";
};
programs.home-manager.enable = true;
nix = {
package = pkgs.nixFlakes;
settings.experimental-features = ["nix-command" "flakes"];
};
}
// commonHM)
]
++ modules;
};
mkUser = {
username,
extraGroups ? [],
extraModules ? [],
extraSpecialArgs ? {},
hashedPassword,
hm ? false,
shell,
stateVersion,
system ? "x86_64-linux",
}:
[
{
users.users.${username} = {
inherit extraGroups hashedPassword shell;
isNormalUser = true;
};
}
]
++ extraModules
++ (
if hm
then [
home-manager.nixosModules.home-manager
{
home-manager = {
inherit extraSpecialArgs;
useGlobalPkgs = true;
useUserPackages = true;
users.${username} =
{
imports = [
../users/${username}/home.nix
];
home.stateVersion = stateVersion;
}
// commonHM
// (
if builtins.match ".*-linux" system != null
then {systemd.user.startServices = true;}
else {}
);
};
}
]
else []
);
}
|