-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
301 lines (285 loc) · 8.88 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
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
# nixos-rebuild switch will read its configuration from /etc/nixos/flake.nix if it is present.
{
description = "kiara's nix config";
inputs = {
# Flake inputs
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
impermanence.url = "github:nix-community/impermanence";
flake-compat.url = "github:edolstra/flake-compat";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
systems.url = "github:nix-systems/default";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
flake-parts.url = "github:hercules-ci/flake-parts";
flake-utils-plus = {
url = "github:gytis-ivaskevicius/flake-utils-plus";
inputs.flake-utils.follows = "flake-utils";
};
nixos-hardware.url = "github:nixos/nixos-hardware?rev=3980e7816c99d9e4da7a7b762e5b294055b73b2f"; # unstable nixpkgs: no branch
sops-nix = {
url = "github:mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs";
};
stylix = {
url = "github:danth/stylix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
inputs.flake-compat.follows = "flake-compat";
};
nix-colors.url = "github:misterio77/nix-colors";
flake-programs-sqlite = {
url = "github:wamserma/flake-programs-sqlite";
inputs.nixpkgs.follows = "nixos";
inputs.utils.follows = "flake-utils";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
niri = {
url = "github:sodiboo/niri-flake";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
nix-index-database = {
url = "github:Mic92/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
anyrun = {
url = "github:Kirottu/anyrun";
inputs.nixpkgs.follows = "nixpkgs";
};
yazi-mime = {
url = "git+https://gitee.com/DreamMaoMao/mime-ext.yazi.git";
flake = false;
};
nixgl = {
url = "github:guibou/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
unfree = {
url = "github:numtide/nixpkgs-unfree";
inputs.nixpkgs.follows = "nixpkgs";
};
nur.url = "github:nix-community/NUR";
nixos.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs/release-24.05";
unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
stable.url = "github:nixos/nixpkgs/release-24.05";
workman-vim = {
url = "gitlab:ajgrf/workman-vim-bindings";
flake = false;
};
flake-schemas.url = "github:gvolpe/flake-schemas";
## nix client with schema support: see https://github.com/NixOS/nix/pull/8892
nix-schema = {
inputs.flake-schemas.follows = "flake-schemas";
url = "github:DeterminateSystems/nix-src/flake-schemas";
};
nix-search = {
url = "github:diamondburned/nix-search";
inputs.nixpkgs.follows = "nixpkgs";
};
noshell = {
url = "github:viperML/noshell";
inputs.nixpkgs.follows = "nixpkgs";
};
hullcaster = {
url = "github:gilcu3/hullcaster";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
home-manager,
nur,
nixos-hardware,
disko,
impermanence,
sops-nix,
nix-index-database,
flake-programs-sqlite,
niri,
stylix,
...
} @ inputs: let
inherit (self) outputs;
name = "kiara";
lib =
nixpkgs.lib
// home-manager.lib
// (import ./lib {inherit (nixpkgs) lib;});
forSystem = f: let
o = lib.genAttrs ["aarch64-linux" "x86_64-linux"] f;
in
o
// {
default = o.x86_64-linux;
};
# { default: overlay }
overlaysAttrs = import ./overlays.nix {inherit inputs lib;};
# [ overlay ]
overlays =
builtins.attrValues overlaysAttrs
# external overlays
++ lib.lists.map (k: inputs."${k}".overlay) [
"nixgl"
"nur"
];
# for each system: nixpkgs
pkgsFor =
forSystem
(
system: let
pkgs = nixpkgs.legacyPackages.${system};
in
pkgs
// import ./packages.nix {
inherit inputs lib pkgs;
}
);
# for each system: apply pkgs to a function
forAllSystems = f: forSystem (system: f pkgsFor.${system});
# Your custom packages, accessible through 'nix build', 'nix shell', etc
# for each system: packages including overlays
packages =
forAllSystems
(_pkgs: forSystem (system: pkgsFor.${system}));
userConfig = {
inherit name;
home = "/home/${name}";
};
specialFor = forSystem (system:
{
inherit system lib inputs outputs userConfig;
# pkgs = pkgsFor.${system}; # programs/k9s: attribute 'formats' missing
}
// lib.mapVals (nixpkgs': nixpkgs'.legacyPackages.${system}) {
inherit
(inputs)
nixpkgs
unfree
stable
unstable
;
});
# Eval the treefmt modules from ./treefmt.nix
treefmtEval =
forAllSystems
(pkgs: inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
nixosModules = import ./modules/nixos;
homeModules = [
impermanence.nixosModules.home-manager.impermanence
nur.nixosModules.nur
sops-nix.homeManagerModules.sops
nix-index-database.hmModules.nix-index
stylix.homeManagerModules.stylix
flake-programs-sqlite.nixosModules.programs-sqlite # command-not-found
./modules/home-manager
./home-manager/kiara/home.nix
{nixpkgs = {inherit overlays;};}
];
in {
# This facilitates consuming my custom packages thru the flake
inherit lib packages;
# Reusable nixos modules you might want to export
# These are usually stuff you would upstream into nixpkgs
nixosModules = lib.mapVals import nixosModules;
# for `nix fmt`
formatter =
forAllSystems (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
# for `nix flake check`
checks = forAllSystems (pkgs: {
formatting = treefmtEval.${pkgs.system}.config.build.check self;
});
# Devshell for bootstrapping
# Accessible through 'nix develop -c $SHELL' or 'nix-shell' (legacy)
devShells = forAllSystems (pkgs: import ./shell.nix {inherit pkgs;});
# Your custom packages and modifications, exported as overlays
overlays = overlaysAttrs;
schemas =
inputs.flake-schemas.schemas
// import ./lib/schemas.nix {inherit (inputs) flake-schemas;};
# Allow partitioning with `disko -f .#hammer`
diskoConfigurations.hammer = import ./hosts/hammer/disko-config.nix;
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .'
nixosConfigurations = forSystem (
system:
inputs.nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {inherit system lib inputs outputs userConfig;};
modules = [
disko.nixosModules.disko
impermanence.nixosModule
nur.nixosModules.nur
nixos-hardware.nixosModules.lenovo-ideapad-slim-5
niri.nixosModules.niri
home-manager.nixosModules.home-manager
sops-nix.nixosModules.sops
./cache.nix
{imports = lib.attrValues nixosModules;}
{nixpkgs = {inherit overlays;};}
./hosts/hammer/configuration.nix
./hosts/hammer/imports.nix
{
home-manager = {
extraSpecialArgs = specialFor.${system};
users.${name}.imports =
homeModules
++ [
./home-manager/kiara/niri.nix
./home-manager/kiara/waybar.nix
];
};
}
];
}
);
# `nix run .`
defaultPackage = forSystem (system: nixpkgs.legacyPackages.${system}.just);
# defaultPackage = forSystem (system: home-manager.defaultPackage.${system});
homeConfigurations = let
bySystem = forSystem (system:
home-manager.lib.homeManagerConfiguration {
# inherit overlays;
pkgs = pkgsFor.${system};
extraSpecialArgs = specialFor.${system};
modules = homeModules;
});
in
bySystem
// {
krost =
bySystem.x86_64-linux
// {
imports = [
./home-manager/kiara/chromebook.nix
];
};
};
# Apps make it easy to run my scripts from the flake
apps = forSystem (system: let
pkgs = pkgsFor.${system};
in {
nix = {
type = "app";
program = "${pkgs.nix-schema}/bin/nix-schema";
};
});
};
}