-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
287 lines (284 loc) · 9.26 KB
/
flake.nix
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
{
description = "Pi 2.1 channel stereo receiver";
nixConfig = {
extra-substituters = [ "https://nix-community.cachix.org" ];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs = {
nixpkgs.follows = "nixpkgs";
utils.follows = "flake-utils";
};
};
# todo Actually use disko?
# disko = {
# url = "github:nix-community/disko";
# inputs.nixpkgs.follows = "nixpkgs";
# };
flake-utils.url = "github:numtide/flake-utils";
# todo Look into musnix: https://github.com/musnix/musnix
home-manager = {
# todo Use upstream when my fixes get merged for cross-compiling Mopidy with plugins.
# url = "github:nix-community/home-manager/release-24.05";
url = "github:jwillikers/home-manager/mopidy-fixes-24.11";
inputs.nixpkgs.follows = "nixpkgs";
};
lix-module = {
url = "git+https://git.lix.systems/lix-project/nixos-module.git?ref=release-2.91";
inputs.nixpkgs.follows = "nixpkgs";
};
# todo This is probably unnecessary here.
# But it should make it easier
nix-index-database = {
url = "github:Mic92/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-update-scripts = {
url = "github:jwillikers/nix-update-scripts";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
pre-commit-hooks.follows = "pre-commit-hooks";
treefmt-nix.follows = "treefmt-nix";
};
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
nixpkgs-stable.follows = "nixpkgs";
};
};
raspberry-pi-nix = {
url = "github:nix-community/raspberry-pi-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# todo Use sops-nix for secret management.
# The user login password, Jellyfin server credentials, and Net-SNMP accounts all need to be stored as secrets.
# https://unmovedcentre.com/posts/secrets-management/
# secrets = {
# url = "git+ssh://git@codeberg.org/jwillikers/nix-secrets.git?shallow=1";
# flake = false;
# };
# sops-nix = {
# url = "github:Mic92/sops-nix";
# inputs.nixpkgs.follows = "nixpkgs";
# inputs.nixpkgs-stable.follows = "nixpkgs";
# };
# todo Should I use nixos-hardware?
# nixos-hardware.url = "github:nixos/nixos-hardware";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
# deadnix: skip
self,
deploy-rs,
flake-utils,
nix-update-scripts,
nixpkgs,
pre-commit-hooks,
# secrets,
# sops-nix,
treefmt-nix,
...
}@inputs:
let
overlays = import ./overlays { inherit inputs; };
overlaysList = with overlays; [
additions
ccache
modifications
allow-missing-modules
realtime
unstablePackages
unstable-shairport-sync
shairport-sync-airplay2
];
pkgsArmCross = import nixpkgs {
# inherit system;
system = "x86_64-linux";
crossSystem.config = "aarch64-unknown-linux-gnu";
overlays = overlaysList;
};
pkgsArmNative = import nixpkgs {
overlays = overlaysList;
system = "aarch64-linux";
};
inherit (nixpkgs.lib) nixosSystem;
piceiverRaspberryPi5Config = {
audioHAT = "DigiAmp+";
hostname = "piceiver";
raspberryPiModel = "5";
role = "piceiver";
username = "jordan";
};
# Snapcast client satellite for the Raspberry Pi 4.
snappelliteRaspberryPi4Config = {
audioHAT = "DAC Pro";
hostname = "snappellite";
raspberryPiModel = "4";
role = "snappellite";
username = "jordan";
};
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
stateVersion = "24.05";
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
pre-commit = pre-commit-hooks.lib.${system}.run (
import ./pre-commit-hooks.nix { inherit pkgs treefmtEval; }
);
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in
with pkgs;
{
# todo I should add the overlays as an output, but they must be outside eachDefaultSystem.
# inherit overlays;
apps = {
inherit (nix-update-scripts.apps.${system}) update-nix-direnv update-nixos-release;
};
devShells.default = mkShell {
inherit (pre-commit) shellHook;
nativeBuildInputs =
with pkgs;
[
asciidoctor
# colmena.packages.${system}.colmena
pkgs.deploy-rs
fish
just
lychee
zstd
treefmtEval.config.build.wrapper
# Make formatters available for IDE's.
(builtins.attrValues treefmtEval.config.build.programs)
]
++ pre-commit.enabledPackages;
};
formatter = treefmtEval.config.build.wrapper;
packages = {
default = self.packages.${system}.piceiver-sd-image;
piceiver-sd-image = self.nixosConfigurations.piceiver.config.system.build.sdImage;
piceiver-sd-image-native = self.nixosConfigurations.piceiver-native.config.system.build.sdImage;
snappellite-sd-image = self.nixosConfigurations.snappellite.config.system.build.sdImage;
snappellite-sd-image-native =
self.nixosConfigurations.snappellite-native.config.system.build.sdImage;
};
# pkgs = pkgsArmCross;
}
)
// {
inherit overlays;
checks = builtins.mapAttrs (_system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
deploy = {
nodes = {
piceiver = {
hostname = "piceiver.local";
profiles.system = {
path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.piceiver;
};
};
# piceiver-native = {
# hostname = "piceiver.local";
# profiles.system.path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.piceiver-native;
# };
snappellite = {
hostname = "snappellite.local";
profiles.system.path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.snappellite;
};
# snappellite-native = {
# hostname = "snappellite.local";
# profiles.system.path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.snappellite-native;
# };
};
sshUser = "root";
};
nixosConfigurations = {
piceiver = nixosSystem {
pkgs = pkgsArmCross;
specialArgs = {
inherit inputs overlays stateVersion;
inherit (piceiverRaspberryPi5Config)
audioHAT
hostname
raspberryPiModel
role
username
;
};
modules = [ ./nixos ];
};
piceiver-native = nixosSystem {
pkgs = pkgsArmNative;
specialArgs = {
inherit inputs overlays stateVersion;
inherit (piceiverRaspberryPi5Config)
audioHAT
hostname
raspberryPiModel
role
username
;
};
modules = [ ./nixos ];
};
snappellite = nixosSystem {
pkgs = pkgsArmCross;
specialArgs = {
inherit inputs overlays stateVersion;
inherit (snappelliteRaspberryPi4Config)
audioHAT
hostname
raspberryPiModel
role
username
;
};
modules = [ ./nixos ];
};
snappellite-native = nixosSystem {
pkgs = pkgsArmNative;
specialArgs = {
inherit inputs overlays stateVersion;
inherit (snappelliteRaspberryPi4Config)
audioHAT
hostname
raspberryPiModel
role
username
;
};
modules = [ ./nixos ];
};
# todo Provide builds of the Snappellite image which use the mainline Linux kernel.
# snappellite-mainline = nixosSystem {
# pkgs = pkgsArmCross;
# specialArgs = {
# inherit inputs overlays stateVersion;
# inherit (snappelliteRaspberryPi4Config) audioHAT hostname raspberryPiModel role username;
# };
# modules = [ ./nixos ];
# };
# snappellite-mainline-native = nixosSystem {
# pkgs = pkgsArmNative;
# specialArgs = {
# inherit inputs overlays stateVersion;
# inherit (snappelliteRaspberryPi4Config) audioHAT hostname raspberryPiModel role username;
# };
# modules = [ ./nixos ];
# };
};
};
}