-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
413 lines (369 loc) · 11.7 KB
/
flake.nix
File metadata and controls
413 lines (369 loc) · 11.7 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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
{
description = "flake for nixos, nix-darwin & more I've running on my desktop & laptops";
inputs = {
flake-input-patcher.url = "github:jfly/flake-input-patcher";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
nixpkgs-darwin.url = "github:NixOS/nixpkgs/nixpkgs-25.11-darwin";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
# https://discourse.nixos.org/t/unstable-fails-to-build-stable-ok-flakes/67837
lix = {
url = "https://git.lix.systems/lix-project/lix/archive/main.tar.gz";
flake = false;
};
lix-module = {
url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
inputs.lix.follows = "lix";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
devenv = {
url = "github:cachix/devenv";
inputs.nixpkgs.follows = "nixpkgs";
};
darwin = {
url = "github:LnL7/nix-darwin/nix-darwin-25.11";
inputs.nixpkgs.follows = "nixpkgs-darwin";
};
home-manager = {
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
mac-app-util = {
url = "github:hraban/mac-app-util";
inputs.nixpkgs.follows = "nixpkgs";
};
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
zen-browser = {
url = "github:0xc000022070/zen-browser-flake";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
nix-index-database = {
url = "github:nix-community/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
catppuccin.url = "github:catppuccin/nix/release-25.05";
# Libraries
flockenzeit.url = "github:balsoft/Flockenzeit";
# fork using ungoogled chromium
nix-webapps.url = "github:becknik/nix-webapps";
# Setting the browsers to unstable, just like I do in my home-manager derivation
nix-webapps.inputs.nixpkgs.follows = "nixpkgs-unstable";
# Other stuff
ohmyzsh = {
url = "github:ohmyzsh/ohmyzsh";
flake = false;
};
};
nixConfig = {
extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=";
extra-substituters = "https://devenv.cachix.org";
};
outputs =
inputs-unpatched:
let
patcher = inputs-unpatched.flake-input-patcher.lib.x86_64-linux;
inputs = patcher.patch inputs-unpatched {
nixvim.patches = [
./patches/nixvim/plugins-otter-on-attach.patch
];
nixpkgs.patches = [
./patches/nixpkgs/ibus-xorg-crashes.patch
];
};
inherit (inputs)
self
nixpkgs
nixpkgs-unstable
darwin
home-manager
;
systems = [
"aarch64-darwin"
"x86_64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
stateVersion = "25.11";
# Necessary e.g. for NixOS `config.system.autoUpgrade.flake` with `--commit-lockfile`
mkFlakeDir =
userName: config:
(
if builtins.hasAttr "users" config then
"${config.users.users.${userName}.home}/devel/own/dotfiles.nix"
else
"${config.home.homeDirectory}/devel/own/dotfiles.nix"
);
# Default nixpkgs config
config = {
permittedInsecurePackages = [
"mbedtls-2.28.10" # openrgb
];
allowUnfreePredicate =
pkg:
builtins.elem (nixpkgs.lib.getName pkg) [
"brgenml1lpr"
"brscan5"
"brscan5-etc-files"
"joypixels"
"obsidian"
"google-chrome"
"steam"
"steam-unwrapped"
"steam-original"
"steam-run"
"jetbrains-toolbox"
"idea"
"code"
"vscode"
];
joypixels.acceptLicense = true;
};
# `nixpkgs-unstable'` varies between hosts due to target platform modification config on `dnix`
defaultOverlays =
{
nixpkgs-unstable' ? self.overlays.nixpkgs-unstable,
}:
with self.overlays;
[
default # Additions to `nixpkgs.lib`
nixpkgs-unstable'
modifications
additions # contents of ./pkgs
]
++ (with inputs; [
nix-webapps.overlays.lib
]);
# Default system specialArgs
args = userName: {
# https://discourse.nixos.org/t/flakes-accessing-selfs-revision/11237/6
inherit
self
inputs
stateVersion
userName
mkFlakeDir
;
inherit (inputs) flockenzeit;
};
# home-manager config generation function
mkHomeManagerConf =
{
system,
isLaptop,
userName,
...
}:
{
home-manager = {
extraSpecialArgs = (args userName) // {
inherit system isLaptop;
};
useGlobalPkgs = true;
useUserPackages = true;
# enabled for all users, not just one:
sharedModules =
with inputs;
[
sops-nix.homeManagerModules.sops
nix-index-database.homeModules.nix-index
catppuccin.homeModules.catppuccin
inputs.zen-browser.homeModules.beta
]
++ nixpkgs.lib.optional (inputs.nixpkgs.lib.strings.hasInfix "darwin" system) mac-app-util.homeManagerModules.default;
# home-manager on darwin doesn't support all options
users.${userName} = nixpkgs.lib.concatStringsSep "/" [
./home-manager
"users"
(if inputs.nixpkgs.lib.strings.hasInfix "darwin" system then "darwin.nix" else "nixos.nix")
];
};
};
in
{
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
# using standalone variant of nixvim to enable "bleeding edge" features & plugins, hence nixos stable stateVersion
packages = forAllSystems (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ inputs.nix-webapps.overlays.lib ];
# overlays = builtins.attrValues inputs.nix-webapps.overlays;
};
pkgs-unstable = import nixpkgs-unstable { inherit system; };
nixvim' = inputs.nixvim.legacyPackages.${system};
in
import ./pkgs {
inherit
pkgs
pkgs-unstable
nixvim'
inputs
;
}
);
overlays = import ./overlays { inherit inputs config; };
#nixosModules = import ./modules/nixos;
#homeManagerModules = import ./modules/home-manager;
nixosConfigurations.dnix =
let
system = "x86_64-linux";
userName = "jnnk";
isLaptop = false;
in
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = (args userName) // {
inherit isLaptop;
};
modules =
with inputs.nixos-hardware.nixosModules;
[
common-cpu-intel
common-pc
common-pc-ssd
]
++ [
inputs.disko.nixosModules.disko
inputs.lix-module.nixosModules.default
./nixos
./nixos/dnix
home-manager.nixosModules.home-manager
(mkHomeManagerConf {
inherit system userName isLaptop;
})
(
{ lib, pkgs, ... }@module-inputs:
{
nixpkgs = {
inherit system config;
overlays = defaultOverlays { };
};
}
)
inputs.catppuccin.nixosModules.catppuccin
];
};
nixosConfigurations.lnix =
let
system = "x86_64-linux";
userName = "jnnk";
isLaptop = true;
in
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = (args userName) // {
inherit isLaptop;
};
modules =
with inputs.nixos-hardware.nixosModules;
[
common-cpu-amd
common-cpu-amd-pstate
common-pc-laptop
common-pc-laptop-ssd
#common-pc-laptop-acpi_call # "acpi_call makes tlp work for newer thinkpads"
asus-battery
]
++ [
(
{ lib, pkgs, ... }@module-inputs:
{
nixpkgs = {
inherit system config;
overlays = defaultOverlays { };
};
}
)
inputs.disko.nixosModules.disko
inputs.lix-module.nixosModules.default
./nixos
./nixos/lnix
home-manager.nixosModules.home-manager
(mkHomeManagerConf {
inherit system userName isLaptop;
})
inputs.catppuccin.nixosModules.catppuccin
];
};
darwinConfigurations.wnix =
let
system = "aarch64-darwin";
userName = "jnnk";
isLaptop = true;
in
darwin.lib.darwinSystem {
inherit system;
specialArgs = (args userName);
modules = [
inputs.mac-app-util.darwinModules.default
home-manager.darwinModules.home-manager
(
{ lib, pkgs, ... }@module-inputs:
{
nixpkgs = {
inherit system config;
overlays = with self.overlays; [
(final: _prev: {
unstable = import inputs.nixpkgs-unstable {
inherit config;
system = final.system;
};
})
# error: A definition for option `nixpkgs.overlays."[definition 1-entry 1]"' is not of type `nixpkgs overlay'. Definition values:
# - In `<unknown-file>'
#nixpkgs-unstable
default
modifications
additions
];
};
}
)
./darwin
home-manager.darwinModules.home-manager
(mkHomeManagerConf {
inherit system userName isLaptop;
})
];
};
devShells = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = inputs.devenv.lib.mkShell {
inherit inputs pkgs;
modules = [
(
{ pkgs, config, ... }:
{
# https://devenv.sh/guides/using-with-flakes/
# https://devenv.sh/reference/options/
# https://github.com/expipiplus1/update-nix-fetchgit
packages = [ pkgs.update-nix-fetchgit ];
languages.nix.enable = true;
git-hooks.hooks = {
nixfmt-rfc-style.enable = true;
};
scripts.update-fetchgit.exec = builtins.readFile ./update-fetchgit.sh;
}
)
];
};
}
);
};
}