-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
216 lines (197 loc) · 7.41 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
{
description = "A highly structured configuration database.";
inputs =
{
master.url = "nixpkgs/master";
unstable.url = "nixpkgs/nixos-unstable";
nixos.url = "nixpkgs/release-22.05";
wayland = {
url = "github:nix-community/nixpkgs-wayland";
inputs.nixpkgs.follows = "nixos";
inputs.master.follows = "master";
};
home = {
url = "github:nix-community/home-manager/release-22.05";
inputs.nixpkgs.follows = "nixos";
};
nur.url = "github:nix-community/NUR";
flake-utils.url = "github:numtide/flake-utils";
nixos-hardware.url = "github:NixOS/nixos-hardware";
impermanence.url = "github:nix-community/impermanence";
simple-mailserver = {
url = "gitlab:simple-nixos-mailserver/nixos-mailserver/nixos-22.05";
inputs.nixpkgs.follows = "unstable";
inputs.nixpkgs-22_05.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";
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";
};
neorg = {
url = "github:nvim-neorg/nixpkgs-neorg-overlay";
inputs.nixpkgs.follows = "nixos";
};
nix-autobahn.url = "github:Lassulus/nix-autobahn";
arkenfox.url = "github:dwarfmaster/arkenfox-nixos";
};
outputs = inputs@{ self, home, nixos, master, unstable, wayland, nur, flake-utils,
nixos-hardware, impermanence, simple-mailserver, django, imacs, colors,
lean4, opam2nix, emacs-overlay, nix-doom-emacs, neovim-nightly, nixvim, neorg,
nix-autobahn, arkenfox }:
let
# All overlays to apply
finalOverlays = self.overlays // {
nur = nur.overlay;
arkenfox = arkenfox.overlay;
# neorg = neorg.overlays.default;
# wayland = wayland.overlay;
packages = re: super: {
lean4 = lean4.defaultPackage.x86_64-linux;
opam2nix = opam2nix.defaultPackage.x86_64-linux;
nix-autobahn = nix-autobahn.defaultPackage.x86_64-linux;
nix-colors = colors.colorSchemes;
neovim-nightly = neovim-nightly.packages.default;
};
};
# Modules to be made available to hosts config
finalModules = self.nixosModules // {
inherit libModule;
profiles = { ... }: { imports = nixosProfiles; };
mailserver = simple-mailserver.nixosModules.mailserver;
home-manager = home.nixosModules.home-manager;
imacs = imacs.nixosModules.imacs;
impermanence = impermanence.nixosModule;
};
# HM Modules to be made available to profiles
finalHMModules = system: self.hmModules // {
inherit libModule;
profiles = { ... }: { imports = hmProfiles; };
rycee-base16 = (nur-no-pkgs system).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;
};
# All attributes to add to lib in modules
extraLib = {
hardware = nixos-hardware.nixosModules;
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);
nixosProfiles = importProfiles ./profiles/nixos;
hmProfiles = importProfiles ./profiles/hm;
pkgImport = system: unfree: pkgs:
import pkgs {
inherit system;
overlays = attrValues finalOverlays;
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 = system: import ./packages {
pkgs = import nixos {
inherit system;
config = { allowUnfree = false; };
overlays = [ (self: super: pkgs-variants system) ];
};
inherit lib;
inherit utils;
};
pkgs = system: import nixos {
inherit system;
config = { allowUnfree = false; };
overlays =
attrValues finalOverlays ++ [
(self: super: pkgs-variants system)
(self: super: packages system)
];
};
nur-no-pkgs = system: import nur {
nurpkgs = pkgImport system false nixos;
};
libModule = { pkgs, lib, ... }@args: {
lib = utils.recImport { dir = ./lib; _import = base: import "${./lib}/${base}.nix" args; } // {
inherit utils;
};
};
hosts =
import ./hosts ({
inherit self pkgs lib;
inherit finalOverlays finalModules finalHMModules;
});
in {
packages = eachSupportedSystem packages;
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;
nixosConfigurations =
builtins.mapAttrs (_: config: lib.nixosSystem {
inherit (config) system modules;
}) hosts;
};
}