-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
389 lines (328 loc) · 15.2 KB
/
flake.nix
File metadata and controls
389 lines (328 loc) · 15.2 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
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
{
# https://evantravers.com/articles/2024/02/06/switching-to-nix-darwin-and-flakes/
# https://github.com/carlthome/dotfiles/blob/714c86da15ef00bbd0882c8ca1afcced2ebf70fa/modules/nix-darwin/configuration.nix
# https://github.com/dmarcoux/dotfiles/blob/c66ad8c079b0b48227b17d6924212723657486a1/UPDATE.md
# https://github.com/mhanberg/.dotfiles/blob/ce20d790b8f8b30a43b0bf62b051ffdd06e93169/nix/darwin.nix
# https://gist.github.com/jmatsushita/5c50ef14b4b96cb24ae5268dab613050
# https://librephoenix.com/2024-02-10-using-both-stable-and-unstable-packages-on-nixos-at-the-same-time
# The `specialArgs` is used when defining NixOS or system-level arguments for modules.
# The `extraSpecialArgs` is used when invoking Home Manager inside NixOS.
# The `specialArgs` are used by the nixOS system function, whereas `extraSpecialArgs` are used by the homeManagerConfiguration function from home-manager.
# +--------------------------------------+
# | NixOS system |
# | specialArgs = { inputs = { ... }; } |
# | |
# | +--------------------------------+ |
# | | Home Manager (flake) | |
# | | extraSpecialArgs = { ... }; | |
# | +--------------------------------+ |
# | |
# +--------------------------------------+
description = "NixOS Configuration";
# nixConfig = {
# # The extra- prefix appends to any list setting rather than overriding it.
# # https://nix.dev/manual/nix/latest/command-ref/conf-file#file-format
# extra-substituters = [
# "https://cache.nixos.org"
# "https://nix-community.cachix.org"
# ]; # https://nix.dev/manual/nix/latest/command-ref/conf-file#conf-substituters
# # The extra- prefix appends to any list setting rather than overriding it.
# extra-trusted-public-keys = [
# "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
# "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
# ]; # https://nix.dev/manual/nix/latest/command-ref/conf-file#conf-trusted-public-keys
# };
# Nix Channels and Git Branches:
# https://github.com/nixos/nixpkgs/pull/105986
# https://github.com/nixos/rfcs/pull/26
# https://github.com/nixos/rfcs/pull/26#issuecomment-739237393
# https://wiki.nixos.org/wiki/channel_branches#internal_channel_update_process
# ruby_{3_3,3_4}: backport patches for GCC 15 and LLVM 21
# https://github.com/nixos/nixpkgs/pull/451386
# https://nixpk.gs/pr-tracker.html?pr=451386
# The staging workflow exists to batch Hydra builds of many packages together.
# https://github.com/nixos/nixpkgs/blob/master/CONTRIBUTING.md#staging
# Which channel branch should I use?
# https://nix.dev/concepts/faq#channel-branches
# https://nix.dev/manual/nix/development/
# https://nix.dev/manual/nix/latest/
# https://nix.dev/manual/nix/rolling/
# https://nix.dev/manual/nix/stable/
# https://nix.dev/manual/nix/prev-stable/
# https://nix.dev/manual/nix/latest/command-ref/new-cli/nix3-flake.html#examples
# https://nix.dev/manual/nix/2.32/command-ref/new-cli/nix3-flake.html#examples
inputs = {
# nixpkgs.url = "github:nixos/nixpkgs?branch=nixos-unstable&rev=dc704e6102e76aad573f63b74c742cd96f8f1e6c"; # https://github.com/nixos/nixpkgs/issues/449970
# OK
# nixpkgs.url = "github:nixos/nixpkgs?branch=staging-next&rev=dace194d4791e7dec990c0671795f1e73ff4d196"; # https://github.com/nixos/nixpkgs/issues/449970
# FAIL
# nixpkgs.url = "github:nixos/nixpkgs?branch=staging-next&rev=387a92d18b3ff50e3eca63cb5b2bff679a068985"; # https://github.com/nixos/nixpkgs/issues/449970
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# The next two are for pinning to stable vs unstable regardless of what the above is set to
# This is particularly useful when an upcoming stable release is in beta because you can effectively
# keep 'nixpkgs-stable' set to stable for critical packages while setting 'nixpkgs' to the beta branch to
# get a jump start on deprecation changes.
# See also 'stable-packages' and 'unstable-packages' overlays at 'overlays/default.nix'
# nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.05";
# nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nixos-hardware.url = "github:nixos/nixos-hardware/master";
# nixpkgs-helix.url = "github:nixos/nixpkgs/bc947f541ae55e999ffdb4013441347d83b00feb"; # Hack for Helix to be able to build tree-sitter. # https://github.com/llakala/nixos/blob/5dae1c83df4835fd23d433adc76f66bca44962ba/flake.nix#L104
# nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-25.05-darwin";
# OK
# nixpkgs-darwin.url = "github:nixos/nixpkgs?branch=nixos-unstable&rev=dc704e6102e76aad573f63b74c742cd96f8f1e6c"; # https://github.com/nixos/nixpkgs/issues/449970
# FAIL
# nixpkgs-darwin.url = "github:nixos/nixpkgs?branch=staging-next&rev=dace194d4791e7dec990c0671795f1e73ff4d196"; # https://github.com/nixos/nixpkgs/issues/449970
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixos-unstable";
nix-darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs-darwin";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
firefox-addons = {
url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils"; # https://github.com/edgelesssys/contrast/blob/7c5206269d2ce0440090f05db601506011e2cd5f/flake.nix#L13-L15
firefox-gnome-theme = {
url = "github:rafaelmardojai/firefox-gnome-theme";
flake = false;
}; # https://github.com/llakala/nixos/tree/5dae1c83df4835fd23d433adc76f66bca44962ba/apps/programs/firefox
catppuccin.url = "github:catppuccin/nix";
# devenv.url = "github:cachix/devenv";
# flox.url = "github:flox/flox";
# helix-unstable = {
# url = "github:helix-editor/helix"; # Compile Helix from source to support macro keybinds
# inputs.nixpkgs.follows = "nixpkgs-helix"; # So we don't have two instances of `nixpkgs` in flake.lock. We use the same rev from helix's flake.lock so we don't have to recompile
# }; # https://github.com/llakala/nixos/tree/5dae1c83df4835fd23d433adc76f66bca44962ba/apps/programs/firefox
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
# url = "github:nix-community/home-manager/release-24.11";
};
# nh-plus = {
# url = "github:toyvo/nh_plus";
# inputs.nixpkgs.follows = "nixpkgs";
# };
# mac-app-util fails to build with sbcl-2.6.0 package.
# sbcl-2.6.0 broke fare-quasiquote/cl-interpol readtable handling.
# @upstream-issue https://github.com/hraban/mac-app-util/issues/42
# TODO: Enable once upstream issue is fixed. See beads issue nixcfg-gl7.
mac-app-util = {
url = "github:hraban/mac-app-util";
# inputs.nixpkgs.follows = "nixpkgs"; # @upstream-issue https://github.com/hraban/mac-app-util/issues/42
};
microvm = {
url = "github:astro/microvm.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts = {
url = "github:hercules-ci/flake-parts/main";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
stylix = {
url = "github:nix-community/stylix";
inputs.nixpkgs.follows = "nixpkgs";
};
wrapix = {
url = "github:taheris/wrapix/main";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
# errata-ai-alex.flake = false;
# errata-ai-alex.url = "github:errata-ai/alex";
# errata-ai-google.flake = false;
# errata-ai-google.url = "github:errata-ai/google";
# errata-ai-joblint.flake = false;
# errata-ai-joblint.url = "github:errata-ai/joblint";
# errata-ai-microsoft.flake = false;
# errata-ai-microsoft.url = "github:errata-ai/microsoft";
# errata-ai-proselint.flake = false;
# errata-ai-proselint.url = "github:errata-ai/proselint";
# errata-ai-readability.flake = false;
# errata-ai-readability.url = "github:errata-ai/readability";
# errata-ai-write-good.flake = false;
# errata-ai-write-good.url = "github:errata-ai/write-good";
fenix = {
url = "github:nix-community/fenix/monthly";
inputs.nixpkgs.follows = "nixpkgs";
};
# kitty-nightly.flake = false;
# kitty-nightly.url = "github:kovidgoyal/kitty/nightly";
morlana = {
url = "github:ryanccn/morlana";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-index-database = {
url = "github:nix-community/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
nixvim = {
url = "github:nix-community/nixvim/nixos-25.05";
inputs.nixpkgs.follows = "nixpkgs";
};
nur = {
url = "github:nix-community/nur";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
wcurl = {
url = "github:curl/wcurl/main";
flake = false;
};
_1password-shell-plugins.url = "github:1password/shell-plugins";
beads-flake = {
# @upstream-issue https://github.com/steveyegge/beads/issues/1373#issuecomment-3815509770
url = "github:steveyegge/beads/v0.49.1"; # @upstream-issue https://github.com/steveyegge/beads/issues/1373
inputs.nixpkgs.follows = "nixpkgs";
};
nix-systems.url = "github:nix-systems/default"; # https://github.com/nix-systems/nix-systems
nix-secrets = {
url = "git+ssh://git@github.com/sheeeng/nix-secrets.git?ref=main&shallow=1";
# url = "git+file://absolute/path/to/nix-secrets";
# The following are equivalent ways to specify the same flake.
# url = "git+https://github.com/sheeeng/nix-secrets.git?ref=main&shallow=1";
# url = "github:sheeeng/nix-secrets/main";
};
nix-secrets-example = {
url = "git+ssh://git@github.com/sheeeng/nix-secrets-example.git?ref=main&shallow=1";
# url = "git+file://absolute/path/to/nix-secrets-example";
};
};
outputs =
{
self,
nixpkgs,
nix-systems,
treefmt-nix,
...
}@inputs:
let
# Small tool to iterate over each systems
eachSystem =
f: nixpkgs.lib.genAttrs (import nix-systems) (system: f nixpkgs.legacyPackages.${system});
# eachSystem = nixpkgs.lib.genAttrs [
# "aarch64-linux"
# "i686-linux"
# "x86_64-linux"
# "aarch64-darwin"
# "x86_64-darwin"
# ];
# Eval the treefmt modules from ./treefmt.nix
treefmtEval = eachSystem (pkgs: treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
# ========== Extend lib with lib.custom ==========
# NOTE: This approach allows lib.custom to propagate into hm
# see: https://github.com/nix-community/home-manager/pull/3454 # https://github.com/EmergentMind/nix-config/blob/f9168993316e8ff99381ff5dd3c7398273439618/flake.nix#L24
darwinConfiguration =
hostname: _system:
inputs.nix-darwin.lib.darwinSystem {
modules = [
./hosts/${hostname}
inputs.home-manager.darwinModules.home-manager
inputs.mac-app-util.darwinModules.default
inputs.nix-index-database.darwinModules.nix-index
inputs.agenix.darwinModules.default
inputs.sops-nix.darwinModules.sops
{
nixpkgs.overlays = [
(import ./overlays { inherit inputs; }).additions
(import ./overlays { inherit inputs; }).modifications
inputs.morlana.overlays.default
# inputs.nh-plus.overlays.default
inputs.fenix.overlays.default
# TODO: Remove below anonymous/lambda function block after https://github.com/NixOS/nixpkgs/pull/461779 is resolved upstream.
# https://github.com/NixOS/nixpkgs/pull/461779#issuecomment-3540524291
# $ PAGER=cat nix why-depends --derivation github:NixOS/nixpkgs#direnv github:NixOS/nixpkgs#fish
# /nix/store/jw5h4ds90v9kkbazby807qzwvgg0562h-direnv-2.37.1.drv
# └───/nix/store/3kinxxz53hwmzw22l4cvpkxidiwh4w80-fish-4.2.1.drv
# (_self: super: {
# fish = super.fish.overrideAttrs (oldAttrs: {
# # TODO: Remove after https://github.com/NixOS/nixpkgs/pull/462090 is resolved upstream.
# doCheck = false;
# doInstallCheck = false;
# checkPhase = ":";
# installCheckPhase = ":";
# }); # TODO: Remove anonymous/lambda function after https://github.com/NixOS/nixpkgs/pull/462589 is resolved upstream.
# }) # TODO: Remove above anonymous/lambda function after https://github.com/NixOS/nixpkgs/issues/461406 is resolved upstream.
];
nixpkgs.config = {
allowUnfree = true;
};
environment.variables = { };
}
];
specialArgs = { inherit inputs; };
};
nixosConfiguration =
hostname: system:
nixpkgs.lib.nixosSystem {
inherit system;
modules = [
./hosts/${hostname}
inputs.home-manager.nixosModules.home-manager
inputs.disko.nixosModules.disko
inputs.agenix.nixosModules.default
inputs.sops-nix.nixosModules.sops
{
nixpkgs.overlays = [
(import ./overlays { inherit inputs; }).additions
(import ./overlays { inherit inputs; }).modifications
inputs.morlana.overlays.default
inputs.fenix.overlays.default
];
nixpkgs.config = {
allowUnfree = true;
};
}
];
specialArgs = { inherit inputs; };
};
in
{
# for `nix fmt`
formatter = eachSystem (pkgs: treefmtEval.${pkgs.stdenv.hostPlatform.system}.config.build.wrapper);
# for `nix flake check`
checks = eachSystem (pkgs: {
formatting = treefmtEval.${pkgs.stdenv.hostPlatform.system}.config.build.check self;
});
# for `nix develop` - provides development shell
devShells = eachSystem (
pkgs:
let
shells = import ./shell.nix { inherit pkgs; };
in
{
default = shells.standard-shell;
inherit (shells) minimal-shell;
inherit (shells) standard-shell;
}
);
nixosConfigurations = {
# desktop = nixosConfiguration "desktop" "x86_64-linux";
# laptop = nixosConfiguration "laptop" "x86_64-linux";
# rpi = nixosConfiguration "rpi" "aarch64-linux";
nixos = nixosConfiguration "nixos" "x86_64-linux";
};
darwinConfigurations = {
TP95V9LWWL = darwinConfiguration "TP95V9LWWL" "aarch64-darwin";
C02ZV797MD6R = darwinConfiguration "C02ZV797MD6R" "x86_64-darwin";
};
};
}