-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhost.nix
More file actions
197 lines (177 loc) · 4.85 KB
/
Copy pathhost.nix
File metadata and controls
197 lines (177 loc) · 4.85 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
{
user,
inputs,
flake,
overlays,
}:
let
npins = import ../npins;
nixpkgs = {
inherit overlays;
config.allowUnfree = true;
};
netlib = import ../lib/network.nix;
# extra args for nixos/darwin system modules
specialArgs = { inherit inputs flake npins; };
# extra args for home-manager modules
extraSpecialArgs = { inherit inputs npins; };
in
rec {
mkBase =
defaultModules:
{
users ? [ "nixos" ],
hostName,
hostModules ? [ ],
hardware-config ? (import ../machines/${hostName}),
system ? "x86_64-linux",
}:
let
inherit (inputs.nixpkgs) lib;
# TODO: pls improve this
raw_users = lib.zipListsWith (
name: uid:
if builtins.isAttrs name then (lib.mergeAttrs { inherit uid; } name) else { inherit name uid; }
) users (lib.range 1000 (builtins.length users + 1000));
part = builtins.partition (
raw_user:
builtins.elem raw_user.name [
"nixos"
"maelstroem"
"alice"
]
) raw_users;
sys_users = (map user.mkSystemUser part.right) ++ (map user.mkGuestUser part.wrong);
modules =
defaultModules
++ hostModules
++ [
(
{
lib,
config,
pkgs,
...
}:
{
_module.args.netlib = netlib config lib;
imports = [
../modules/hosts
hardware-config
../network.nix
]
++ sys_users;
nix.registry.nixpkgs.flake = inputs.nixpkgs;
nix.package = pkgs.lixPackageSets.stable.lix;
nixpkgs.overlays = [ inputs.nixpkgs-wayland.overlay ] ++ overlays;
sops = {
defaultSopsFile = ../sops/sops.yaml;
age = {
keyFile = "/var/lib/sops-nix/key.txt";
generateKey = false;
};
};
programs.fish.enable = true;
i18n.supportedLocales = [
"en_US.UTF-8/UTF-8"
"en_GB.UTF-8/UTF-8"
"de_DE.UTF-8/UTF-8"
];
i18n.extraLocales = [
"en_US.UTF-8/UTF-8"
"en_GB.UTF-8/UTF-8"
"de_DE.UTF-8/UTF-8"
];
phil.core.hostName = lib.mkDefault hostName;
system.nixos.label = "g${inputs.self.shortRev or "shortRev-not-set"}";
}
)
inputs.nixocaine.nixosModules.default
inputs.sops-nix-src.nixosModules.sops
inputs.disko.nixosModules.disko
];
in
lib.nixosSystem {
inherit system modules specialArgs;
};
mkNixos =
hmUsers:
mkBase [
inputs.stylix.nixosModules.stylix
inputs.home-manager.nixosModules.home-manager
(
{
pkgs,
lib,
...
}:
{
nixpkgs = nixpkgs // {
overlays = nixpkgs.overlays ++ [
#inputs.hyprland.overlays.default
#inputs.xdg-desktop-hyprland.overlays.default
];
};
home-manager = {
inherit extraSpecialArgs;
useGlobalPkgs = true;
useUserPackages = true;
users = lib.mapAttrs (user.mkConfig pkgs) hmUsers;
};
}
)
];
mkDarwin =
{
name,
userConfig ? { },
extraPackages ? _: [ ],
username ? "philippherzog",
system ? "aarch64-darwin",
lib ? inputs.nixpkgs.lib,
hardware-config ? (import ../machines/${name}),
}:
inputs.darwin.lib.darwinSystem {
inherit system specialArgs;
modules = [
hardware-config
(
{
pkgs,
config,
lib,
...
}:
{
_module.args.netlib = netlib config lib;
inherit nixpkgs;
nix = {
registry.nixpkgs.flake = inputs.nixpkgs;
settings.trusted-users = [ username ];
package = pkgs.lixPackageSets.stable.lix;
# # currently broken on mac?
# extraOptions = ''
# auto-optimise-store = false
# '';
};
home-manager.users.${username} = {
imports = [
(user.mkConfig pkgs username {
inherit userConfig extraPackages;
stateVersion = "22.05";
homeDirectory = "/Users/${username}";
})
];
};
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
inherit extraSpecialArgs;
};
}
)
inputs.home-manager.darwinModules.default
inputs.stylix.darwinModules.stylix
];
};
}