-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
263 lines (239 loc) · 6.45 KB
/
flake.nix
File metadata and controls
263 lines (239 loc) · 6.45 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
{
description = "My NixOS configuration :P";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nixpkgs-25_05.url = "github:NixOS/nixpkgs/nixos-25.05";
# ~/ files config
home-manager = {
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
# Desktop Environment config
plasma-manager = {
url = "github:nix-community/plasma-manager";
inputs.nixpkgs.follows = "nixpkgs-unstable";
inputs.home-manager.follows = "home-manager";
};
# Expands upon the nix std lib.
nix-std.url = "github:chessai/nix-std";
# Get deps for non-nix binaries.
nix-alien.url = "github:thiagokokada/nix-alien";
# My system manager.
system-manager = {
url = "github:tye-exe/system-manager/v1.6.0";
# inputs.nixpkgs.follows = "nixpkgs";
};
# Secret Management.
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# Flatpaks
nix-flatpak.url = "github:gmodena/nix-flatpak";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
winapps = {
url = "github:winapps-org/winapps";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
nixpkgs,
nixpkgs-unstable,
home-manager,
nix-std,
...
}:
let
lib = nixpkgs.lib;
std = nix-std.lib;
users = [
"tye"
"work"
];
devices =
[
"undefined"
"laptop"
"framework"
"desktop"
"nas"
{
device = "rpi";
system = "aarch64-linux";
}
]
|> map (
settings:
(
if (builtins.isAttrs settings) then
settings
else
{
device = settings;
system = "x86_64-linux";
}
)
);
# Allows me to pass custom options into every module.
opts = {
keys = import ./lib/keys.nix;
};
# Generates the nixos system configuration for each system
nix_conf =
{
name,
system,
}:
{
inherit system;
specialArgs = {
inherit
inputs
system
name
opts
;
pkgs-unstable = import nixpkgs-unstable {
inherit system;
config = {
allowUnfree = true;
};
};
};
modules = [
./system/${name}.nix
./hardware-confs/${name}.nix
# Allows for making system images with less compressed iso.
self.nixosModules.myFormats
];
};
# Generates the home-manager configuration for each system
home_conf =
{
device,
system,
user,
name,
}:
{
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
};
};
extraSpecialArgs =
let
# Unstable pkgs
pkgs-unstable = import nixpkgs-unstable {
inherit system;
config = {
allowUnfree = true;
};
};
# Unstable pkgs
pkgs-25_05 = import inputs.nixpkgs-25_05 {
inherit system;
config = {
allowUnfree = true;
};
};
in
{
inherit
std
inputs
pkgs-unstable
pkgs-25_05
opts
device
system
user
name
;
};
modules = [
./home/common/${device}.nix
];
};
in
{
# System confs
nixosConfigurations = (
devices
|> map (settings: {
name = settings.device;
system = settings.system;
})
|> map (settings: {
name = settings.name;
value = (nix_conf settings |> lib.nixosSystem);
})
|> builtins.listToAttrs
);
# Home manager confs
homeConfigurations =
lib.forEach users (
user:
(
devices
|> map (
settings: with settings; {
inherit device system user;
}
)
)
)
|> lib.flatten
|> map (
settings: with settings; {
name = "${user}-${device}";
inherit device system user;
}
)
|> map (settings: {
name = settings.name;
value = (home_conf settings |> home-manager.lib.homeManagerConfiguration);
})
|> builtins.listToAttrs;
# Defines custom formats for https://github.com/nix-community/nixos-generators
# To build use "nix build .#nixosConfigurations.<identity>.config.formats.iso"
nixosModules.myFormats =
{ config, ... }:
{
nixpkgs.hostPlatform = "x86_64-linux";
# Imports all formats so iso can be overridden (i think).
imports = [
inputs.nixos-generators.nixosModules.all-formats
];
formatConfigs.iso =
{ config, modulesPath, ... }:
{
imports =
let
# Shows the path to configurable options
# module = builtins.trace "${toString modulesPath}/installer/cd-dvd/iso-image.nix";
in
[
"${toString modulesPath}/installer/cd-dvd/iso-image.nix"
];
# EFI booting
isoImage.makeEfiBootable = true;
# USB booting
isoImage.makeUsbBootable = true;
formatAttr = "isoImage";
fileExtension = ".iso";
# Minor compression helps alot and takes little time.
# The difference between the default 19 and 3 is about 1GB and 10 minuets of compression time
# for the former
isoImage.squashfsCompression = "zstd -Xcompression-level 3";
};
};
};
}