-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
451 lines (402 loc) · 16.3 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
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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# (2022/07/20) Recreating this flake based on misterio's as it has many of the
# elements I'm looking for: https://github.com/Misterio77/nix-config
# TODO: he has a bunch of cool looking nix tools listed:
# https://github.com/Misterio77/nix-config/blob/main/home/misterio/cli/default.nix
#
# (2022/07/21) NOTE: we can have each home-manager config have its own dedicated
# folder in home too, if we want to specify individual machine stuff without
# trying to figure out how to do a ton of abstraction
# (2022/07/22) Is it possibly worth it to extract a lot of the vim config stuff
# into development modules? It would be nice if cli-core were actually pretty small,
# and maybe there are quite a few systems where I don't really need any language
# servers.
# TODO: also have a "minimal" hm that has almost nothing
# Note that the way you update packages (I think) for a home mangaer configuration
# is as they mention in their wiki, which is literally just "nix flake update":
# https://rycee.gitlab.io/home-manager/index.html#sec-flakes-standalone
# Also see the third-deep nested comment, discusses how you can explicitly set nix
# to directly follow a specific url
# https://www.reddit.com/r/NixOS/comments/pmz2vi/how_do_i_update_nix_to_the_latest_unstable_version/
# (2022/07/24) Current problem with bootstrap: the first time you run it never
# works because I guess nix isn't found in path yet?
# (2022/09/14) I added a basic vscode install to arcane, but there's a lot of
# features that don't work since you can't edit the settings on the fly. There's
# a solution to this that modifies home activation for that package, seems
# fairly straightfoward: https://github.com/nix-community/home-manager/issues/1800
# (2022/10/23) I regularly get a "tput: unknown terminal 'xterm-kitty'" error the
# time I'm trying to install things. This might be related to
# https://sw.kovidgoyal.net/kitty/faq/#i-get-errors-about-the-terminal-being-unknown-or-opening-the-terminal-failing-when-sshing-into-a-different-computer
# where the solution is to ssh with `kitty +kitten ssh myserver` It might be worth
# it to eventually include that terminfo directly in my config and copy over?
# (2022/10/26) Another valuable set of dotfiles to reference: https://man.sr.ht/~hutzdog/dotfiles/
# the nixos/flake book, potentially some good conventions to use here:
# https://nixos-and-flakes.thiscute.world/nixos-with-flakes/downgrade-or-upgrade-packages
# TODO's
# ===============================
# TODO: make each profile use separate lock file through iris
# TODO: add iris flag to pass next flags to underlying commands
# TODO: make opengl stuff work on non-nixos: https://github.com/nix-community/nixGL/issues/114#issuecomment-1585323281
# TODO: make an install nix anywhere script https://zameermanji.com/blog/2023/3/26/using-nix-without-root/
# curl -L https://hydra.nixos.org/job/nix/maintenance-2.20/buildStatic.x86_64-linux/latest/download-by-type/file/binary-dist > nix
# export NIX_CONF_DIR="[...]/.config/nix"
# (set up the nix.conf)
# ./nix ... (will use .local/share/nix)
# (for it to work on macos will likely need https://github.com/nixie-dev/fakedir)
# nix shell nixpkgs#homemanager
#
#
# STRT: make the cli-core nvim more minimal, use dev modules to add more plugin stuff
# TODO: way to automate firefox speedups? https://www.drivereasy.com/knowledge/speed-up-firefox/ (will need to add nur which has firefox and extensions)
# TODO: script to keep backup ref to home-manager gen and make it easy to switch to that one
# TODO: add pre-commit stuff to this
# TODO: snippet for nix header block
# TODO: fix vim auto line break to be how I used to have it
# TODO: investigate allowing serving a nix store via ssh https://nixos.org/manual/nix/stable/package-management/ssh-substituter.html
# TODO: make some nice plymouth boot stuff!
# MODULES NEEDED
#================================
# dev (-python -web -research) [unclear how much to break this up]
# research
# desktop/i3
# radio
# (hosting stuff)
# gaming
# Debugging tools:
#-------------------
# builtins.trace e1 e2 (prints e1, returns e2)
# nixpkgs.lib.traceVal e1 (prints and returns e1)
# QUESTIONS
# ===============================
# - He has custom pkgs, but how does he reference them/pull them in?
# A: ahhh, I believe he does it in overlay/default.nix at the end, the // ../pkgs
#
# - Where does he pull in the features? lib.mkHome only puts them into
# "extraSpecialArgs" along with some modules.
# A: Inside home/misterio/default, he has an imports list that concats a map
# with the features list (this "imports" is what makes it a "module", and it
# is notably importing other modules)
#
# - How do modules work, do they just automagically append everything when
# multiple modules are all assigning to the same thing?
# A: Yeah I think so, in https://nixos.wiki/wiki/Module in "under the hood",
# they mention that for each option they collect all definitions from all
# modules and merge them together according to options type.
# NOTE: so this means we could probably have things like vim plugins/settings
# modularized too? (e.g. I don't want javascript linters clogging up my system
# if I have no intention of developing javascript on that system.)
# NOTE: also, I can probably nest folders like misterio but also have default
# in top level, so you can either auto import everything by specifying the top
# level feature, or specify only select things.
#
# - Wait, where's the "laptop" module? He mentions in /home/misterio/default
# "import features _that have modules_, are there features that don't?
#
# - How do we get those other elements put into extraSpecialArgs?
# A: They are passed as arguments to each module, so the beginning { ... }
# function def line.
#
# - How do I get access to my library functions deep within modules?
# A: It's somehow still an argument being passed around.
{
description = "My awesome-sauce and cool-beans nix configuration-y things.";
inputs = {
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
# keeping around so if I ever need a specific nixpkgs commit, use this
# nixpkgs-pinned.url = "github:nixos/nixpkgs?rev=988cc958c57ce4350ec248d2d53087777f9e1949";
home-manager = {
# https://github.com/EmergentMind/nix-config
# TODO TODO: TODO: TODO: https://discourse.nixos.org/t/anatomy-of-a-nixos-config/40252
# TODO: apparently you can follow specific releases? (e.g.
# home-manager/release-23.11) would this solve some of the stability
# issues?
# TODO: is there a way to see a list of changes to options in HM modules
# that I use?
# TODO: look into using nixvim instead of doing neovim through HM
url = "github:nix-community/home-manager/release-24.11";
inputs.nixpkgs.follows = "nixpkgs"; # unsure what this actually does. (It
# makes it so that home-manager isn't downloading it's own set of nixpkgs,
# we're "overriding" the nixpkgs input home-manager defines by default)
};
nixgl = {
url = "github:nix-community/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
# TODO: add in nix-colors!
};
#outputs = inputs:
outputs = { self, nixpkgs, home-manager, nixgl, ... } @ inputs:
let
inherit (self) outputs;
systems = [
"x86_64-linux"
"aarch64-darwin"
];
forEachSystem = f: lib.genAttrs systems (system: f pkgsFor.${system});
pkgsFor = lib.genAttrs systems (system: import nixpkgs {
inherit system;
overlays = builtins.attrValues outputs.overlays ++ [ nixgl.overlay ];
config.allowUnfree = true;
});
mylib = import ./lib { inherit inputs; };
lib = nixpkgs.lib // home-manager.lib // mylib;
inherit (mylib) mkHome mkSystem mkStableSystem forAllSystems;
inherit (builtins) attrValues;
in
{
inherit mylib;
inherit lib;
inherit pkgsFor;
overlays = import ./overlays { inherit inputs outputs; };
# =================== NIXOS CONFIGURATIONS ==================
nixosConfigurations = {
delta = lib.nixosSystem {
pkgs = pkgsFor.x86_64-linux;
modules = [ ./hosts ];
specialArgs = {
inherit self inputs outputs;
stable = true;
configName = "delta";
hostname = "delta";
configLocation = "/home/dwl/lab/nix-config";
timezone = "America/New_York";
};
};
# delta = mkSystem {
# configName = "delta";
# hostname = "delta";
# system = "x86_64-linux";
# };
# amethyst = mkSystem {
# configName = "amethyst";
# hostname = "amethyst";
# system = "x86_64-linux";
# };
amethyst = lib.nixosSystem {
pkgs = pkgsFor.x86_64-linux;
modules = [ ./hosts ];
specialArgs = {
inherit self inputs outputs;
stable = true;
configName = "amethyst";
hostname = "amethyst";
configLocation = "/home/dwl/lab/nix-config";
timezone = "America/New_York";
};
};
therock = lib.nixosSystem {
pkgs = pkgsFor.x86_64-linux;
modules = [ ./hosts ];
specialArgs = {
inherit self inputs outputs;
stable = true;
configName = "therock";
hostname = "therock";
configLocation = "/home/dwl/lab/nix-config";
timezone = "America/New_York";
};
};
};
# ===========================================================
# =================== HOME CONFIGURATIONS ===================
homeConfigurations = {
# primary desktop
phantom = mkHome {
configName = "phantom";
username = "dwl";
hostname = "phantom";
noNixos = true;
};
# amethyst = mkHome {
# configName = "amethyst";
# username = "dwl";
# hostname = "amethyst";
# };
amethyst = lib.homeManagerConfiguration {
pkgs = pkgsFor.x86_64-linux;
modules = [ ./home ];
extraSpecialArgs = {
inherit self inputs outputs;
hostname = "amethyst";
username = "dwl";
configName = "amethyst";
gitUsername = "Martindale, Nathan";
gitEmail = "[email protected]";
configLocation = "/home/dwl/lab/nix-config";
noNixos = false;
};
};
# primary laptop
delta = lib.homeManagerConfiguration {
pkgs = pkgsFor.x86_64-linux;
modules = [ ./home ];
extraSpecialArgs = {
inherit self inputs outputs;
hostname = "delta";
username = "dwl";
configName = "delta";
configLocation = "/home/dwl/lab/nix-config";
gitUsername = "Martindale, Nathan";
gitEmail = "[email protected]";
noNixos = false;
};
};
# delta = mkHome {
# configName = "delta";
# username = "dwl";
# hostname = "delta";
# };
# homeserver
therock = lib.homeManagerConfiguration {
pkgs = pkgsFor.x86_64-linux;
modules = [ ./home ];
extraSpecialArgs = {
inherit self inputs outputs;
hostname = "therock";
username = "dwl";
configName = "therock";
gitUsername = "Martindale, Nathan";
gitEmail = "[email protected]";
configLocation = "/home/dwl/lab/nix-config";
noNixos = false;
};
};
# work linux workstation
arcane = lib.homeManagerConfiguration {
pkgs = pkgsFor.x86_64-linux;
modules = [ ./home ];
extraSpecialArgs = {
inherit self inputs outputs nixgl;
hostname = "arcane";
username = "81n";
configName = "arcane";
configLocation = "/home/81n/lab/nix-config";
gitEmail = "[email protected]";
gitUsername = "Martindale, Nathan";
noNixos = true;
};
};
# work linux laptop
planet = lib.homeManagerConfiguration {
pkgs = pkgsFor.x86_64-linux;
modules = [ ./home ];
extraSpecialArgs = {
inherit self inputs outputs nixgl;
hostname = "planet";
username = "81n";
configName = "planet";
configLocation = "/home/81n/lab/nix-config";
gitUsername = "Martindale, Nathan";
gitEmail = "[email protected]";
noNixos = true;
};
};
# work cluster
endor = lib.homeManagerConfiguration {
pkgs = pkgsFor.x86_64-linux;
modules = [ ./home ];
extraSpecialArgs = {
inherit self inputs outputs;
hostname = "endor";
username = "81n";
configName = "endor";
configLocation = "/data/jocasta/home/81n";
gitUsername = "Martindale, Nathan";
gitEmail = "[email protected]";
noNixos = true;
};
};
# work laptop (wsl)
wlap = mkHome {
configName = "wlap";
username = "dwl";
hostname = "LAP124750";
features = [ "dev" ];
noNixos = true;
gitEmail = "[email protected]";
};
# work laptop (mac)
wmac = mkHome {
configName = "wmac";
username = "81n";
hostname = "MAC135974";
system = "aarch64-darwin";
#noNixos = true;
gitEmail = "[email protected]";
configLocation = "/Users/81n/lab/nix-config";
};
};
# ===========================================================
# overlays = {
# # https://nixos.wiki/wiki/Flakes (see section "Importing packages from multiple channels")
# # a single overlay that always includes both,
# # this would allow modules that get imported from both a stable and
# # unstable context to work if they require a specific channel, and all the
# # rest of the packages will just default to whatever context called from.
#
# stable-unstable-combo = final: prev: {
# unstable = import inputs.nixpkgs-unstable {
# system = prev.system;
# config.allowUnfree = true;
# config.permittedInsecurePackages = [ "electron-25.9.0" ];
# };
# stable = import inputs.nixpkgs {
# system = prev.system;
# config.allowUnfree = true;
# };
# };
#
# custom-pkgs = import ./overlay { inherit inputs; };
# };
# overlay-unstable = final: prev: {
# unstable = import inputs.nixpkgs-unstable {
# system = prev.system;
# config.allowUnfree = true;
# };
# };
#
# overlay-stable = final: prev: {
# stable = import inputs.nixpkgs-stable {
# system = prev.system;
# config.allowUnree = true;
# };
# };
# legacyPackagesUnstable = forAllSystems (system:
# import inputs.nixpkgs-unstable {
# inherit system;
# overlays = attrValues overlays; # ++ [ overlay-stable ];
# config.allowUnfree = true;
# }
# );
#
# legacyPackagesStable = forAllSystems (system:
# import inputs.nixpkgs {
# inherit system;
# overlays = attrValues overlays; # ++ [ overlay-unstable ];
# config.allowUnfree = true;
# }
# );
# NOTE: the updated way to do this is (after running current ./setup)
# nix shell nixpkgs#home-manager
# home-manager switch --flake .#[configname]
# home-manager bootstrap script. If home-manager isn't yet installed, run
# `nix shell .` and then `bootstrap [NAME OF HOME CONFIG]`
# TODO: why isn't this just using the writeshellscript whatever?
# checkout the bootstrap used in https://github.com/Misterio77/nix-starter-configs/blob/main/standard/shell.nix
# packages = forAllSystems (system: {
# default = with legacyPackagesUnstable.${system};
# stdenv.mkDerivation rec {
# name = "bootstrap-script";
# installPhase = /* bash */ ''
# mkdir -p $out/bin
# echo "#!${runtimeShell}" >> $out/bin/bootstrap
# echo "export TERMINFO_DIRS=/usr/share/terminfo" >> $out/bin/bootstrap
# echo "nix build --no-write-lock-file home-manager" >> $out/bin/bootstrap
# echo "./result/bin/home-manager --flake \".#\$1\" switch --impure" >> $out/bin/bootstrap
# chmod +x $out/bin/bootstrap
# '';
# dontUnpack = true;
# };
# });
};
}