-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
242 lines (225 loc) · 6.59 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
{
description = "A highly structured configuration database.";
inputs = {
master.url = "nixpkgs/master";
nixos.url = "nixpkgs/nixos-unstable";
stable.url = "nixpkgs/release-24.05";
home = {
url = "github:nix-community/home-manager";
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";
inputs.nixpkgs.follows = "nixos";
};
django.url = "github:pnmadelaine/django-nixos/main";
imacs = {
url = "github:TWal/imacs";
inputs.nixpkgs.follows = "nixos";
inputs.django-nixos.follows = "django";
};
stylix = {
url = "github:danth/stylix";
inputs.nixpkgs.follows = "nixos";
inputs.home-manager.follows = "home";
};
korrvigs = {
# url = "github:dwarfmaster/korrvigs";
url = "/home/luc/repos/korrvigs";
inputs.nixpkgs.follows = "nixos";
};
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixos";
};
arkenfox = {
url = "github:dwarfmaster/arkenfox-nixos";
inputs.nixpkgs.follows = "nixos";
};
};
outputs = {
self,
home,
nixos,
master,
stable,
nur,
flake-utils,
nixos-hardware,
nixos-generators,
impermanence,
simple-mailserver,
django,
imacs,
stylix,
korrvigs,
nixvim,
arkenfox,
} @ inputs: let
# All overlays to apply
overlays =
self.overlays
// {
nur = nur.overlay;
arkenfox = arkenfox.overlays.default;
korrvigs = korrvigs.overlays.default;
packages = self: super:
{
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;
stylix = stylix.nixosModules.stylix;
imacs = imacs.nixosModules.imacs;
impermanence = impermanence.nixosModule;
};
hm =
self.hmModules
// {
inherit libModule;
profiles = {...}: {imports = profiles.hm;};
arkenfox = arkenfox.hmModules.default;
nixvim = nixvim.homeManagerModules.nixvim;
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;
stable = pkgImport system false stable;
stable-unfree = pkgImport system true stable;
unfree = pkgImport system true nixos;
};
packages = import ./packages;
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;
inputs = builtins.removeAttrs inputs ["self"];
};
in {
packages = eachSupportedSystem (system: let
pkgs = import nixos {
inherit system;
overlays = builtins.attrValues overlays ++ [packages];
};
in {
inherit
(pkgs)
reupload
fvim
;
});
# // {
# 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;
};
}