Skip to content

Commit 52e1767

Browse files
committed
nix fmt
1 parent a80d562 commit 52e1767

52 files changed

Lines changed: 1028 additions & 607 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

flake.nix

Lines changed: 109 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,22 @@
109109
};
110110

111111
outputs =
112-
{ self
113-
, nixpkgs
114-
, systems
115-
, colmena
116-
, agenix
117-
, agenix-rekey
118-
, disko
119-
, nix-index-database
120-
, ocflib
121-
, ocf-sync-etc
122-
, ocf-pam-trimspaces
123-
, ocf-utils
124-
, wayout
125-
, ocf-cosmic-applets
126-
, ocf-jukebox
112+
{
113+
self,
114+
nixpkgs,
115+
systems,
116+
colmena,
117+
agenix,
118+
agenix-rekey,
119+
disko,
120+
nix-index-database,
121+
ocflib,
122+
ocf-sync-etc,
123+
ocf-pam-trimspaces,
124+
ocf-utils,
125+
wayout,
126+
ocf-cosmic-applets,
127+
ocf-jukebox,
127128
}@inputs:
128129
let
129130
# ============== #
@@ -139,8 +140,9 @@
139140
agenix-rekey.overlays.default
140141
];
141142

142-
customModules =
143-
(with nixpkgs.lib; filter (hasSuffix ".nix") (filesystem.listFilesRecursive ./modules));
143+
customModules = (
144+
with nixpkgs.lib; filter (hasSuffix ".nix") (filesystem.listFilesRecursive ./modules)
145+
);
144146

145147
commonModules = customModules ++ [
146148
./profiles/base.nix
@@ -150,99 +152,115 @@
150152
];
151153

152154
defaultSystem = "x86_64-linux";
153-
overrideSystem = { overheat = "aarch64-linux"; };
155+
overrideSystem = {
156+
overheat = "aarch64-linux";
157+
};
154158

155159
# ============== #
156160
# Glue/Internals #
157161
# ============== #
158162

159-
pkgsFor = system: import nixpkgs {
160-
inherit overlays system;
161-
config = {
162-
allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [
163-
"code"
164-
"claude-code"
165-
"dwarf-fortress"
166-
"google-chrome"
167-
"helvetica-neue-lt-std" #tornado
168-
"mongodb" #zecora for unifi
169-
"nvidia-settings"
170-
"nvidia-x11"
171-
"steam"
172-
"steam-unwrapped"
173-
"unifi-controller"
174-
"vscode"
175-
"zoom"
176-
"drawio"
177-
"datagrip"
178-
"davinci-resolve"
179-
];
163+
pkgsFor =
164+
system:
165+
import nixpkgs {
166+
inherit overlays system;
167+
config = {
168+
allowUnfreePredicate =
169+
pkg:
170+
builtins.elem (nixpkgs.lib.getName pkg) [
171+
"code"
172+
"claude-code"
173+
"dwarf-fortress"
174+
"google-chrome"
175+
"helvetica-neue-lt-std" # tornado
176+
"mongodb" # zecora for unifi
177+
"nvidia-settings"
178+
"nvidia-x11"
179+
"steam"
180+
"steam-unwrapped"
181+
"unifi-controller"
182+
"vscode"
183+
"zoom"
184+
"drawio"
185+
"datagrip"
186+
"davinci-resolve"
187+
];
188+
};
180189
};
181-
};
182190

183-
forAllSystems = fn: nixpkgs.lib.genAttrs (import systems)
184-
(system: fn (pkgsFor system));
191+
forAllSystems = fn: nixpkgs.lib.genAttrs (import systems) (system: fn (pkgsFor system));
185192

186-
readGroup = group: nixpkgs.lib.mapAttrs'
187-
(filename: _: {
193+
readGroup =
194+
group:
195+
nixpkgs.lib.mapAttrs' (filename: _: {
188196
name = nixpkgs.lib.nameFromURL filename ".";
189197
value = {
190198
inherit group;
191199
modules = [ ./hosts/${group}/${filename} ];
192200
};
193-
})
194-
(builtins.readDir ./hosts/${group});
201+
}) (builtins.readDir ./hosts/${group});
195202

196-
hosts = nixpkgs.lib.concatMapAttrs
197-
(group: _: readGroup group)
198-
(builtins.readDir ./hosts);
203+
hosts = nixpkgs.lib.concatMapAttrs (group: _: readGroup group) (builtins.readDir ./hosts);
199204

200205
deploy-user = "ocf-nix-deploy-user";
201-
colmenaHosts = builtins.mapAttrs
202-
(host: { modules, group }: {
206+
colmenaHosts = builtins.mapAttrs (
207+
host:
208+
{ modules, group }:
209+
{
203210
imports = commonModules ++ modules;
204211
deployment.tags = [ group ];
205212
deployment.targetHost = "${host}.ocf.berkeley.edu";
206213
# TODO: Think of a less ugly way of doing this
207-
deployment.targetUser = nixpkgs.lib.mkIf self.colmenaHive.nodes.${host}.config.ocf.managed-deployment.enable deploy-user;
208-
})
209-
hosts;
214+
deployment.targetUser =
215+
nixpkgs.lib.mkIf self.colmenaHive.nodes.${host}.config.ocf.managed-deployment.enable
216+
deploy-user;
217+
}
218+
) hosts;
210219
in
211220
{
212221
formatter = forAllSystems (pkgs: pkgs.nixfmt-tree);
213222

214-
colmenaHive = colmena.lib.makeHive (colmenaHosts // {
215-
meta = {
216-
nixpkgs = pkgsFor defaultSystem;
217-
nodeNixpkgs = nixpkgs.lib.mapAttrs (name: pkgsFor) overrideSystem;
218-
specialArgs = { inherit self inputs; };
223+
colmenaHive = colmena.lib.makeHive (
224+
colmenaHosts
225+
// {
226+
meta = {
227+
nixpkgs = pkgsFor defaultSystem;
228+
nodeNixpkgs = nixpkgs.lib.mapAttrs (name: pkgsFor) overrideSystem;
229+
specialArgs = { inherit self inputs; };
230+
};
231+
}
232+
);
233+
234+
autoDeploy =
235+
let
236+
# returns the value of a managed-deployment option (given as a string containing the option name) for the given node
237+
getOptionForNode =
238+
option: node: self.colmenaHive.nodes.${node}.config.ocf.managed-deployment.${option};
239+
240+
# returns a list of the MAC addresses for the given list of nodes with automated deploy enabled
241+
# hosts that do not have mac-address set will be gracefully ignored
242+
getMACs =
243+
nodes:
244+
builtins.filter (mac: mac != "") (builtins.map (node: getOptionForNode "mac-address" node) nodes);
245+
in
246+
{
247+
# list of nodes with automated deploy enabled, to be consumed by github actions
248+
nodes = builtins.filter (node: getOptionForNode "automated-deploy" node) (
249+
builtins.attrNames self.colmenaHive.nodes
250+
);
251+
252+
# list of mac addresses of nodes that github actions should wake up on deploy
253+
MACs = getMACs self.autoDeploy.nodes;
254+
255+
# attribute set combining automatedDeployNodes and automatedDeployNodeMACs
256+
# get json with `nix eval .#autoDeploy.nodesWithMACs --json`!
257+
# TODO: script to wake up hosts with this
258+
nodesWithMACs = nixpkgs.lib.listToAttrs (
259+
nixpkgs.lib.zipListsWith (name: value: {
260+
inherit name value;
261+
}) self.autoDeploy.nodes self.autoDeploy.MACs
262+
);
219263
};
220-
});
221-
222-
autoDeploy = let
223-
# returns the value of a managed-deployment option (given as a string containing the option name) for the given node
224-
getOptionForNode = option: node: self.colmenaHive.nodes.${node}.config.ocf.managed-deployment.${option};
225-
226-
# returns a list of the MAC addresses for the given list of nodes with automated deploy enabled
227-
# hosts that do not have mac-address set will be gracefully ignored
228-
getMACs = nodes: builtins.filter (mac: mac != "")
229-
(builtins.map
230-
(node: getOptionForNode "mac-address" node)
231-
nodes);
232-
in {
233-
# list of nodes with automated deploy enabled, to be consumed by github actions
234-
nodes = builtins.filter (node: getOptionForNode "automated-deploy" node) (builtins.attrNames self.colmenaHive.nodes);
235-
236-
# list of mac addresses of nodes that github actions should wake up on deploy
237-
MACs = getMACs self.autoDeploy.nodes;
238-
239-
# attribute set combining automatedDeployNodes and automatedDeployNodeMACs
240-
# get json with `nix eval .#autoDeploy.nodesWithMACs --json`!
241-
# TODO: script to wake up hosts with this
242-
nodesWithMACs = nixpkgs.lib.listToAttrs (nixpkgs.lib.zipListsWith
243-
(name: value: { inherit name value; })
244-
self.autoDeploy.nodes self.autoDeploy.MACs);
245-
};
246264

247265
overlays.default = final: prev: {
248266
ocf-utils = ocf-utils.packages.${final.system}.default;
@@ -265,7 +283,7 @@
265283
default = pkgs.mkShell {
266284
packages = [
267285
pkgs.git
268-
pkgs.age
286+
pkgs.age
269287
pkgs.agenix-rekey
270288
pkgs.age-plugin-fido2-hmac
271289
pkgs.wol
@@ -284,13 +302,14 @@
284302
};
285303
});
286304

287-
nixosConfigurations = builtins.mapAttrs
288-
(host: colmenaConfig: nixpkgs.lib.nixosSystem rec {
305+
nixosConfigurations = builtins.mapAttrs (
306+
host: colmenaConfig:
307+
nixpkgs.lib.nixosSystem rec {
289308
system = overrideSystem.${host} or defaultSystem;
290309
pkgs = pkgsFor system;
291310
modules = colmenaConfig.imports;
292311
specialArgs = { inherit inputs; };
293-
})
294-
colmenaHosts;
312+
}
313+
) colmenaHosts;
295314
};
296315
}

hardware/minisforum-new.nix

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
{ config, lib, pkgs, modulesPath, ... }:
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
modulesPath,
6+
...
7+
}:
28

39
{
410
imports = [
511
(modulesPath + "/installer/scan/not-detected.nix")
612
];
713

8-
boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "thunderbolt" "usbhid" "usb_storage" "sd_mod" ];
14+
boot.initrd.availableKernelModules = [
15+
"xhci_pci"
16+
"nvme"
17+
"thunderbolt"
18+
"usbhid"
19+
"usb_storage"
20+
"sd_mod"
21+
];
922
boot.initrd.kernelModules = [ ];
1023
boot.kernelModules = [ "kvm-amd" ];
1124
boot.extraModulePackages = [ ];

hardware/nuc.nix

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
{ config, lib, pkgs, modulesPath, ... }:
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
modulesPath,
6+
...
7+
}:
28

39
{
410
imports = [
511
(modulesPath + "/installer/scan/not-detected.nix")
612
];
713

8-
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" "rtsx_pci_sdmmc" ];
14+
boot.initrd.availableKernelModules = [
15+
"xhci_pci"
16+
"thunderbolt"
17+
"ahci"
18+
"nvme"
19+
"usb_storage"
20+
"usbhid"
21+
"sd_mod"
22+
"rtsx_pci_sdmmc"
23+
];
924
boot.initrd.kernelModules = [ ];
1025
boot.kernelModules = [ "kvm-intel" ];
1126
boot.extraModulePackages = [ ];

hardware/nucleus.nix

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
# Hardware configuration for 2022 newk8s servers (dna).
22
# Requires filesystems to be labeled with `nixos` and `boot`.
33

4-
{ config, lib, pkgs, modulesPath, ... }:
4+
{
5+
config,
6+
lib,
7+
pkgs,
8+
modulesPath,
9+
...
10+
}:
511

612
{
713
imports = [
814
(modulesPath + "/installer/scan/not-detected.nix")
915
];
1016

11-
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "sr_mod" ];
17+
boot.initrd.availableKernelModules = [
18+
"nvme"
19+
"xhci_pci"
20+
"ahci"
21+
"usbhid"
22+
"usb_storage"
23+
"sd_mod"
24+
"sr_mod"
25+
];
1226
boot.initrd.kernelModules = [ ];
1327
boot.kernelModules = [ "kvm-amd" ];
1428
boot.extraModulePackages = [ ];

0 commit comments

Comments
 (0)