-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathflake.nix
More file actions
346 lines (308 loc) · 10.4 KB
/
flake.nix
File metadata and controls
346 lines (308 loc) · 10.4 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
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
{
description = "My NixOS infrastructure";
inputs = {
# Nix Packages collection
# https://github.com/NixOS/nixpkgs
nixpkgs.url = "git+https://github.com/NixOS/nixpkgs?ref=nixos-unstable&shallow=1";
# Manage a user environment using Nix
# https://github.com/nix-community/home-manager
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# Pure Nix flake utility functions
# https://github.com/numtide/flake-utils
flake-utils = {
url = "github:numtide/flake-utils";
};
### Tools for managing NixOS
# https://github.com/nix-community/disko
# Format disks with nix-config
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
# lollypops deployment tool
# https://github.com/pinpox/lollypops
lollypops = {
url = "github:pinpox/lollypops/c52f704a4bf44bd793558c9080982a38e77af01b";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
# A collection of NixOS modules covering hardware quirks.
# https://github.com/NixOS/nixos-hardware
nixos-hardware = {
url = "github:NixOS/nixos-hardware";
};
# Visual Studio Code Server support in NixOS
# https://github.com/msteen/nixos-vscode-server
vscode-server = {
url = "github:msteen/nixos-vscode-server";
};
nixos-vscode-claude = {
url = "github:MayNiklas/nixos-vscode-claude";
};
# Generate wallpaper images from mathematical functions
# https://github.com/pinpox/wallpaper-generator
wallpaper-generator = {
url = "github:pinpox/wallpaper-generator/6461fa794745fb18f2b04f58015e9a2871ca7099";
};
# Adblocking lists for Unbound DNS servers running on NixOS
# https://github.com/MayNiklas/nixos-adblock-unbound
adblock-unbound = {
url = "github:MayNiklas/nixos-adblock-unbound";
inputs = {
nixpkgs.follows = "nixpkgs";
adblockStevenBlack.follows = "adblockStevenBlack";
};
};
# Adblocking lists for DNS servers
# input here, so it will get updated by nix flake update
adblockStevenBlack = {
url = "github:StevenBlack/hosts";
flake = false;
};
# A Shelly power metrics exporter written in golang.
# https://github.com/MayNiklas/shelly-exporter
shelly-exporter = {
url = "github:MayNiklas/shelly-exporter";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
# A valorant metrics exporter written in golang.
# https://github.com/MayNiklas/valorant-exporter
valorant-exporter = {
url = "github:MayNiklas/valorant-exporter";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
};
outputs =
{ self, ... }@inputs:
with inputs;
let
supportedSystems = [
"aarch64-linux"
"x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
checkHostsBySystem = {
aarch64-linux = [ ];
x86_64-linux = [
"aida"
"daisy"
"deke"
"kora"
"simmons"
"snowflake"
"the-bus"
"the-hub"
];
};
# nixpkgsFor = forAllSystems (
# system:
# import nixpkgs {
# inherit system;
# overlays = [ self.overlays.default ];
# }
# );
in
{
# Use nixfmt-tree for `nix fmt'
formatter = forAllSystems (system: (import nixpkgs { inherit system; }).nixfmt-tree);
# Expose overlay to flake outputs, to allow using it from other flakes.
# Flake inputs are passed to the overlay so that the packages defined in
# it can use the sources pinned in flake.lock
overlays.default = final: prev: (import ./overlays inputs) final prev;
overlays.mayniklas = final: prev: (import ./overlays/mayniklas.nix inputs) final prev;
# Output all modules in ./modules to flake. Modules should be in
# individual subdirectories and contain a default.nix file
nixosModules =
builtins.listToAttrs (
map (x: {
name = x;
value =
{
config,
pkgs,
lib,
modulesPath,
...
}:
{
imports = [
(import ./modules/${x} {
flake-self = self;
inherit
pkgs
lib
config
modulesPath
inputs
nixpkgs
;
})
];
};
}) (builtins.attrNames (builtins.readDir ./modules))
)
//
{
home-manager =
{
config,
pkgs,
lib,
...
}:
let
cfg = config.mayniklas.home-manager;
in
{
imports = [ ./home-manager ];
home-manager.extraSpecialArgs = {
homeManagerModules = self.homeManagerModules;
vscode-server = self.inputs.vscode-server;
nixos-vscode-claude = self.inputs.nixos-vscode-claude;
};
home-manager.users."${cfg.username}" = lib.mkIf cfg.enable {
nixpkgs.overlays = [ self.overlays.mayniklas ];
};
};
};
# nix run .#homeConfigurations.nik@MacBook-Pro-14-2021.activationPackage
# home-manager switch --flake .
homeConfigurations."nik@MacBook-Pro-14-2021" =
let
system = "aarch64-darwin";
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
};
overlays = [ ];
};
in
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
{ }
./home-manager/profiles/mac.nix
];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
extraSpecialArgs = {
flake-self = self;
homeManagerModules = self.homeManagerModules;
}
// inputs;
};
homeManagerModules =
let
modulesDir = builtins.readDir ./home-manager/modules;
in
builtins.listToAttrs (
map (name: {
inherit name;
value = import (./home-manager/modules + "/${name}");
}) (builtins.filter (name: modulesDir.${name} == "directory") (builtins.attrNames modulesDir))
);
# Each subdirectory in ./machines is a host. Add them all to
# nixosConfiguratons. Host configurations need a file called
# configuration.nix that will be read first
nixosConfigurations = builtins.listToAttrs (
map (x: {
name = x;
value = nixpkgs.lib.nixosSystem {
# Make inputs and the flake itself accessible as module parameters.
# Technically, adding the inputs is redundant as they can be also
# accessed with flake-self.inputs.X, but adding them individually
# allows to only pass what is needed to each module.
specialArgs = {
flake-self = self;
}
// inputs;
modules = [
lollypops.nixosModules.lollypops
(./machines + "/${x}/configuration.nix")
{ imports = builtins.attrValues self.nixosModules; }
];
};
}) (builtins.attrNames (builtins.readDir ./machines))
);
checks =
let
hostsForSystem =
system: names:
nixpkgs.lib.genAttrs names (name: self.nixosConfigurations.${name}.config.system.build.toplevel);
in
nixpkgs.lib.mapAttrs hostsForSystem checkHostsBySystem;
}
//
# All packages in the ./packages subfolder are also added to the flake.
# flake-utils is used for this part to make each package available for each
# system. This works as all packages are compatible with all architectures
(flake-utils.lib.eachSystem (flake-utils.lib.defaultSystems ++ [ "aarch64-darwin" ])) (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
self.overlays.mayniklas
];
config = {
allowUnsupportedSystem = true;
allowUnfree = true;
};
};
in
rec {
# Custom packages added via the overlay are selectively exposed here, to
# allow using them from other flakes that import this one.
packages = flake-utils.lib.flattenTree {
build_outputs = pkgs.callPackage ./packages/build_outputs { inherit self; };
woodpecker-pipeline = pkgs.callPackage ./packages/woodpecker-pipeline {
hostMeta = builtins.mapAttrs (name: cfg: {
system = cfg.pkgs.stdenv.hostPlatform.system;
inChecks = builtins.elem name (checkHostsBySystem.${cfg.pkgs.stdenv.hostPlatform.system} or [ ]);
}) self.nixosConfigurations;
};
inherit (pkgs.mayniklas)
ASPM-status
check-updates
darknet
mtu-check
pycharm-fix
set-performance
usb-serial
vs-fix
;
csgo-server = pkgs.csgo-server;
drone-gen = pkgs.drone-gen;
gen-module = pkgs.gen-module;
preview-update = pkgs.preview-update;
s3uploader = pkgs.s3uploader;
};
# Allow custom packages to be run using `nix run`
apps = {
# lollypops deployment tool
# https://github.com/pinpox/lollypops
#
# nix run '.#lollypops' -- --list-all
# nix run '.#lollypops' -- aida
# nix run '.#lollypops' -- aida kora
# nix run '.#lollypops' -- aida deke kora simmons snowflake the-bus -p
default = self.apps.${system}.lollypops;
lollypops = lollypops.apps.${system}.default {
configFlake = self;
};
};
}
);
}