Skip to content

Commit fda642c

Browse files
committed
redo hardware-rpi5 nixos-modules
1 parent 05cc92c commit fda642c

File tree

5 files changed

+61
-20
lines changed

5 files changed

+61
-20
lines changed

nixos-configurations/adama.nix

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
imports = [
77
ezModules.authentik-blueprints
8-
ezModules.hardware-rpi5
98
ezModules.sshd
109
ezModules.user-peteresselius
1110
ezModules.ca
@@ -20,6 +19,10 @@
2019
context = "home";
2120
formfactor = "server";
2221

22+
hardware-rpi5 = {
23+
enable = true;
24+
};
25+
2326
networking.firewall.allowedTCPPorts = [
2427
443 # Nginx
2528
# 1880 # Node-RED
@@ -183,7 +186,7 @@
183186
];
184187

185188
profiles.monitoring = {
186-
enable = false;
189+
enable = true;
187190
domain = "grafana.adama.lan";
188191
root_url = "https://grafana.adama.lan/";
189192
oauth = {
@@ -196,8 +199,9 @@
196199
};
197200
};
198201
services.prometheus = {
202+
enable = true;
199203
scrapeConfigs = [
200-
{ job_name = "starbuck-node-exporter"; static_configs = [{ targets = [ "starbuck:9100" ]; }]; }
204+
{ job_name = "starbuck"; static_configs = [{ targets = [ "starbuck:9090" ]; }]; }
201205
{ job_name = "openwrt"; static_configs = [{ targets = [ "192.168.1.1:9100" "192.168.1.2:9100" ]; }]; }
202206
];
203207
};

nixos-configurations/starbuck.nix

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
{
44
imports = [
5-
ezModules.hardware-rpi5
65
ezModules.sshd
76
ezModules.user-peteresselius
87
ezModules.nix-gc
@@ -15,10 +14,16 @@
1514
context = "home";
1615
formfactor = "server";
1716

17+
profiles.telemetry.enable = true;
18+
1819
networking.firewall.allowedTCPPorts = [
19-
9100
20+
9090
2021
];
2122

22-
profiles.storage.enable = true;
23-
profiles.telemetry.enable = true;
23+
hardware-rpi5 = {
24+
enable = true;
25+
enableNVMe = true;
26+
enablePCIeGen3 = true;
27+
enableMaxUSBCurrent = true;
28+
};
2429
}

nixos-modules/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
ezModules.nix
88
ezModules.profiles
99
../overlays.nix
10+
ezModules.hardware-rpi5
1011
];
1112
}

nixos-modules/hardware-rpi5.nix

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,56 @@
1-
{ inputs, ... }:
1+
{ inputs, lib, config, ... }:
22

3+
let
4+
cfg = config.hardware-rpi5;
5+
in
36
{
47
imports = [
58
inputs.raspberry-pi-nix.nixosModules.raspberry-pi
69
];
710

8-
raspberry-pi-nix = {
9-
uboot.enable = false;
10-
pin-inputs.enable = true;
11-
board = "bcm2712";
12-
libcamera-overlay.enable = false;
11+
options.hardware-rpi5 = {
12+
enable = lib.mkEnableOption "Enable extra Raspberry Pi 5 hardware features";
13+
enableNVMe = lib.mkEnableOption "Enable NVMe support";
14+
enablePCIeGen3 = lib.mkEnableOption "Enable PCIe Gen3 support";
15+
enableMaxUSBCurrent = lib.mkEnableOption "Enable maximum USB current";
1316
};
1417

15-
hardware = {
16-
bluetooth = {
17-
enable = true;
18-
settings.General.Experimental = true;
18+
config = lib.mkIf cfg.enable {
19+
raspberry-pi-nix = {
20+
uboot.enable = false;
21+
pin-inputs.enable = true;
22+
board = "bcm2712";
23+
libcamera-overlay.enable = false;
1924
};
2025

21-
raspberry-pi.config.all.base-dt-params.krnbt = {
22-
enable = true;
23-
value = "on";
26+
hardware = {
27+
bluetooth = {
28+
enable = true;
29+
settings.General.Experimental = true;
30+
};
31+
32+
raspberry-pi.config.all = {
33+
options.usb_max_current_enable = lib.mkIf cfg.enableMaxUSBCurrent {
34+
enable = true;
35+
value = 1;
36+
};
37+
38+
base-dt-params = {
39+
krnbt = {
40+
enable = true;
41+
value = "on";
42+
};
43+
44+
nvme = lib.mkIf cfg.enableNVMe {
45+
enable = true;
46+
};
47+
48+
pciex1_1 = lib.mkIf cfg.enablePCIeGen3 {
49+
enable = true;
50+
value = "gen3";
51+
};
52+
};
53+
};
2454
};
2555
};
2656
}

nixos-modules/profiles/telemetry.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ in
1616
exporters = {
1717
node = {
1818
enable = true;
19+
openFirewall = true;
1920
enabledCollectors = [
2021
"cgroups"
2122
"systemd"

0 commit comments

Comments
 (0)