-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
272 lines (254 loc) · 7.67 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
{
description = "A highly structured configuration database.";
inputs = {
master.url = "nixpkgs/master";
unstable.url = "nixpkgs/nixos-unstable";
nixos.url = "nixpkgs/release-22.11";
home = {
url = "github:nix-community/home-manager/release-22.11";
inputs.nixpkgs.follows = "nixos";
};
nur.url = "github:nix-community/NUR";
flake-utils.url = "github:numtide/flake-utils";
nixos-hardware.url = "github:NixOS/nixos-hardware";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixos";
};
impermanence.url = "github:nix-community/impermanence";
simple-mailserver = {
url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-22.11";
inputs.nixpkgs.follows = "unstable";
inputs.nixpkgs-22_11.follows = "nixos";
};
django.url = "github:pnmadelaine/django-nixos/main";
imacs = {
url = "github:TWal/imacs";
inputs.nixpkgs.follows = "nixos";
inputs.django-nixos.follows = "django";
};
colors.url = "github:Misterio77/nix-colors";
korrvigs = {
url = "github:dwarfmaster/korrvigs";
inputs.nixpkgs.follows = "nixos";
};
lean4 = {
url = "github:leanprover/lean4";
inputs.nixpkgs.follows = "unstable";
};
opam2nix = {
url = "github:dwarfmaster/opam2nix";
inputs.nixpkgs.follows = "nixos";
};
# Forces more recent emacs-overlay, fixes https://github.com/vlaci/nix-doom-emacs/issues/401
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
flake = false;
};
nix-doom-emacs = {
url = "github:nix-community/nix-doom-emacs";
inputs.nixpkgs.follows = "nixos";
inputs.emacs-overlay.follows = "emacs-overlay";
};
neovim-nightly = {
url = "github:nix-community/neovim-nightly-overlay";
inputs.nixpkgs.follows = "nixos";
};
nixvim = {
url = "github:pta2002/nixvim";
inputs.nixpkgs.follows = "nixos";
};
arkenfox.url = "github:dwarfmaster/arkenfox-nixos";
};
outputs = inputs @ {
self,
home,
nixos,
master,
unstable,
nur,
flake-utils,
nixos-hardware,
nixos-generators,
impermanence,
simple-mailserver,
django,
imacs,
colors,
korrvigs,
lean4,
opam2nix,
emacs-overlay,
nix-doom-emacs,
neovim-nightly,
nixvim,
arkenfox,
}: let
# All overlays to apply
overlays =
self.overlays
// {
nur = nur.overlay;
arkenfox = arkenfox.overlay;
neovim-nightly = neovim-nightly.overlay;
korrvigs = korrvigs.overlays.default;
packages = self: super:
{
lean4 = lean4.defaultPackage.x86_64-linux;
opam2nix = opam2nix.defaultPackage.x86_64-linux;
nix-colors = colors.colorSchemes;
tree-sitter-make-grammar =
super.callPackage
(nixos + "/pkgs/development/tools/parsing/tree-sitter/grammar.nix") {};
}
// packages self super;
variants = self: super: pkgs-variants super.system;
};
# Modules to be made available to configs
modules = {
nixos =
self.nixosModules
// {
inherit libModule;
profiles = {...}: {imports = profiles.nixos;};
mailserver = simple-mailserver.nixosModules.mailserver;
home-manager = home.nixosModules.home-manager;
imacs = imacs.nixosModules.imacs;
impermanence = impermanence.nixosModule;
};
hm =
self.hmModules
// {
inherit libModule;
profiles = {...}: {imports = profiles.hm;};
rycee-base16 = nur-modules.repos.rycee.hmModules.theme-base16;
nix-doom-emacs = nix-doom-emacs.hmModule;
arkenfox = arkenfox.hmModules.default;
nixvim = nixvim.homeManagerModules.nixvim;
colors = colors.homeManagerModules.colorScheme;
impermanence = impermanence.nixosModules.home-manager.impermanence;
korrvigs = korrvigs.hmModules.default;
};
nixvim = self.nixvimModules // {profiles = {...}: {imports = profiles.nixvim;};};
};
# All attributes to add to lib in modules
extraLib = {
system = flake-utils.lib.system;
allSystems = flake-utils.lib.allSystems;
arkenfox = arkenfox.lib.arkenfox;
};
# Supported system
supportedSystems = builtins.attrValues {
inherit
(flake-utils.lib.system)
x86_64-linux
aarch64-linux
;
};
# After this point there is no configuration, only plumbing
inherit (builtins) attrNames attrValues;
inherit (nixos) lib;
utils = import ./utils.nix {inherit lib;};
inherit (utils) pathsToImportedAttrs readVisible importProfiles;
eachSupportedSystem = f:
builtins.listToAttrs
(map (system: lib.nameValuePair system (f system)) supportedSystems);
profiles = {
nixos = importProfiles ./profiles/nixos;
hm = importProfiles ./profiles/hm;
nixvim = importProfiles ./profiles/nixvim;
};
pkgImport = system: unfree: pkgs:
import pkgs {
inherit system;
overlays = attrValues overlays;
config = {allowUnfree = unfree;};
};
pkgs-variants = system: {
master = pkgImport system false master;
master-unfree = pkgImport system true master;
unstable = pkgImport system false unstable;
unstable-unfree = pkgImport system true unstable;
unfree = pkgImport system true nixos;
};
packages = import ./packages;
nur-modules = import nur {
# Architecture is hardcoded since it won't be used by modules
nurpkgs = import nixos {system = "x86_64-linux";};
};
libModule = {
pkgs,
lib,
...
} @ args: {
lib =
utils.recImport {
dir = ./lib;
_import = base: import "${./lib}/${base}.nix" args;
}
// {
utils = import ./utils.nix args;
}
// extraLib;
};
hosts = import ./hosts {
inherit self lib;
inherit overlays modules;
};
in {
packages =
eachSupportedSystem (system: let
pkgs = import nixos {
inherit system;
overlays = [packages];
};
in {
inherit
(pkgs)
reupload
;
})
// {
x86_64-linux = {
helzvog-sd-image = nixos-generators.nixosGenerate {
system = "aarch64-linux";
format = "sd-aarch64";
modules = hosts.helzvog.modules;
};
};
};
lib = import ./utils.nix {inherit lib;};
overlays = let
overlayDir = ./overlays;
fullPath = name: overlayDir + "/${name}";
overlayPaths = map fullPath (attrNames (readVisible overlayDir));
in
pathsToImportedAttrs overlayPaths;
nixosModules = let
modulesDir = ./modules/nixos;
fullPath = name: modulesDir + "/${name}";
modulesPaths = map fullPath (attrNames (readVisible modulesDir));
in
pathsToImportedAttrs modulesPaths;
hmModules = let
modulesDir = ./modules/hm;
fullPath = name: modulesDir + "/${name}";
modulesPaths = map fullPath (attrNames (readVisible modulesDir));
in
pathsToImportedAttrs modulesPaths;
nixvimModules = let
modulesDir = ./modules/nixvim;
fullPath = name: modulesDir + "/${name}";
modulesPaths = map fullPath (attrNames (readVisible modulesDir));
in
pathsToImportedAttrs modulesPaths;
nixosConfigurations = builtins.mapAttrs (_: config:
lib.nixosSystem {
inherit (config) modules;
specialArgs = {
hardware = nixos-hardware.nixosModules;
};
})
hosts;
};
}