-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathflake.nix
More file actions
256 lines (226 loc) · 6.67 KB
/
flake.nix
File metadata and controls
256 lines (226 loc) · 6.67 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
{
description = "NixOS configuration for the Open Computing Facility";
inputs = {
nixpkgs = {
type = "github";
owner = "nixos";
repo = "nixpkgs";
ref = "nixos-unstable";
};
systems = {
type = "github";
owner = "nix-systems";
repo = "default";
ref = "main";
};
colmena = {
type = "github";
owner = "zhaofengli";
repo = "colmena";
ref = "main";
inputs.nixpkgs.follows = "nixpkgs";
};
agenix = {
type = "github";
owner = "ryantm";
repo = "agenix";
ref = "main";
inputs.nixpkgs.follows = "nixpkgs";
};
agenix-rekey = {
type = "github";
owner = "oddlama";
repo = "agenix-rekey";
ref = "main";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
type = "github";
owner = "nix-community";
repo = "disko";
ref = "latest";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-index-database = {
type = "github";
owner = "nix-community";
repo = "nix-index-database";
ref = "main";
inputs.nixpkgs.follows = "nixpkgs";
};
ocflib = {
type = "github";
owner = "ocf";
repo = "ocflib";
ref = "master";
};
ocf-sync-etc = {
type = "github";
owner = "ocf";
repo = "etc";
ref = "master";
};
ocf-pam-trimspaces = {
type = "github";
owner = "ocf";
repo = "pam_trimspaces";
ref = "master";
};
ocf-utils = {
type = "github";
owner = "ocf";
repo = "utils";
ref = "master";
inputs.nixpkgs.follows = "nixpkgs";
inputs.ocflib.follows = "ocflib";
};
wayout = {
type = "github";
owner = "ocf";
repo = "wayout";
ref = "main";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self
, nixpkgs
, systems
, colmena
, agenix
, agenix-rekey
, disko
, nix-index-database
, ocflib
, ocf-sync-etc
, ocf-pam-trimspaces
, ocf-utils
, wayout
}@inputs:
let
# ============== #
# Things to edit #
# ============== #
overlays = [
self.overlays.default
ocflib.overlays.default
ocf-sync-etc.overlays.default
ocf-pam-trimspaces.overlays.default
nix-index-database.overlays.nix-index
agenix-rekey.overlays.default
];
customModules =
(with nixpkgs.lib; filter (hasSuffix ".nix") (filesystem.listFilesRecursive ./modules));
commonModules = customModules ++ [
./profiles/base.nix
agenix.nixosModules.default
agenix-rekey.nixosModules.default
disko.nixosModules.disko
];
defaultSystem = "x86_64-linux";
overrideSystem = { overheat = "aarch64-linux"; };
# ============== #
# Glue/Internals #
# ============== #
pkgsFor = system: import nixpkgs {
inherit overlays system;
config = {
allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [
"code"
"dwarf-fortress"
"google-chrome"
"helvetica-neue-lt-std" #tornado
"mongodb" #zecora for unifi
"nvidia-settings"
"nvidia-x11"
"steam"
"steam-unwrapped"
"unifi-controller"
"vscode"
"zoom"
];
};
};
forAllSystems = fn: nixpkgs.lib.genAttrs (import systems)
(system: fn (pkgsFor system));
readGroup = group: nixpkgs.lib.mapAttrs'
(filename: _: {
name = nixpkgs.lib.nameFromURL filename ".";
value = {
inherit group;
modules = [ ./hosts/${group}/${filename} ];
};
})
(builtins.readDir ./hosts/${group});
hosts = nixpkgs.lib.concatMapAttrs
(group: _: readGroup group)
(builtins.readDir ./hosts);
deploy-user = "ocf-nix-deploy-user";
colmenaHosts = builtins.mapAttrs
(host: { modules, group }: {
imports = commonModules ++ modules;
deployment.tags = [ group ];
deployment.targetHost = "${host}.ocf.berkeley.edu";
# TODO: Think of a less ugly way of doing this
deployment.targetUser = nixpkgs.lib.mkIf self.colmenaHive.nodes.${host}.config.ocf.managed-deployment.enable deploy-user;
})
hosts;
in
{
formatter = forAllSystems (pkgs: pkgs.nixpkgs-fmt);
colmenaHive = colmena.lib.makeHive (colmenaHosts // {
meta = {
nixpkgs = pkgsFor defaultSystem;
nodeNixpkgs = nixpkgs.lib.mapAttrs (name: pkgsFor) overrideSystem;
specialArgs = { inherit inputs; };
};
});
# list of nodes with automated deploy enabled, to be consumed by github actions
automatedDeployNodes = builtins.filter (node: self.colmenaHive.nodes.${node}.config.ocf.managed-deployment.automated-deploy) (builtins.attrNames self.colmenaHive.nodes);
overlays.default = final: prev: {
ocf-utils = ocf-utils.packages.${final.system}.default;
ocf-wayout = wayout.packages.${final.system}.default;
plasma-applet-commandoutput = final.callPackage ./pkgs/plasma-applet-commandoutput.nix { };
catppuccin-sddm = final.qt6Packages.callPackage ./pkgs/catppuccin-sddm.nix { };
ocf-papers = final.callPackage ./pkgs/ocf-papers.nix { };
ocf-okular = final.kdePackages.callPackage ./pkgs/ocf-okular.nix { };
# FIXME remove once https://github.com/NixOS/nixpkgs/pull/465400 reaches our version of nixpkgs
termbench-pro = prev.termbench-pro.overrideAttrs {
buildInputs = [
final.fmt
(final.glaze.override { enableSSL = false; })
];
};
};
agenix-rekey = agenix-rekey.configure {
userFlake = self;
nixosConfigurations = self.colmenaHive.nodes;
};
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = [
pkgs.git
pkgs.agenix-rekey
pkgs.age-plugin-fido2-hmac
colmena.packages.${pkgs.system}.colmena
disko.packages.${pkgs.system}.disko
];
};
deploy = pkgs.mkShell {
packages = [
pkgs.git
pkgs.openssh
colmena.packages.${pkgs.system}.colmena
];
};
});
nixosConfigurations = builtins.mapAttrs
(host: colmenaConfig: nixpkgs.lib.nixosSystem rec {
system = overrideSystem.${host} or defaultSystem;
pkgs = pkgsFor system;
modules = colmenaConfig.imports;
specialArgs = { inherit inputs; };
})
colmenaHosts;
};
}