-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
1754 lines (1473 loc) · 60.4 KB
/
Copy pathjustfile
File metadata and controls
1754 lines (1473 loc) · 60.4 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
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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# justfile for vanixiets. Sections separated by ##; recipes documented with single # on the preceding line.
nix_cmd := "nix --accept-flake-config"
# Default command when 'just' is run without arguments
default: help
# Display help
help:
@printf "\nRun 'just -n <command>' to print what would be executed...\n\n"
@just --list --unsorted
@printf "\n...by running 'just <command>'.\n"
@printf "This message is printed by 'just help' and just 'just'.\n"
## nix
# Check if a package is cached (substitutable) on the current locked nixpkgs rev
[group('nix')]
check-cached package:
#!/usr/bin/env bash
set -euo pipefail
output=$(nix build "path:$(nix eval --raw .#inputs.nixpkgs)#{{package}}" --dry-run 2>&1)
if [ -z "$output" ]; then
echo "{{package}}: cached"
else
echo "$output"
fi
# Preview uncached derivations for a machine (auto-detects darwin vs nixos)
[group('nix')]
check-uncached-machine hostname:
#!/usr/bin/env bash
set -euo pipefail
darwin_hosts=(argentum blackphos rosegold stibnite)
nixos_hosts=(cinnabar electrum galena scheelite)
for h in "${darwin_hosts[@]}"; do
if [[ "$h" == "{{hostname}}" ]]; then
exec just check-uncached "darwinConfigurations.{{hostname}}.system"
fi
done
for h in "${nixos_hosts[@]}"; do
if [[ "$h" == "{{hostname}}" ]]; then
exec just check-uncached "nixosConfigurations.{{hostname}}.config.system.build.toplevel"
fi
done
echo "unknown hostname: {{hostname}}" >&2
echo "darwin: ${darwin_hosts[*]}" >&2
echo "nixos: ${nixos_hosts[*]}" >&2
exit 1
# List derivations that would be built (not cached) for a system configuration
[group('nix')]
check-uncached config:
#!/usr/bin/env bash
set -euo pipefail
output=$(nix build ".#{{config}}" --dry-run 2>&1)
if ! echo "$output" | grep -q 'will be built'; then
echo "all derivations cached"
else
echo "$output" | grep 'will be built'
echo "$output" | grep '\.drv$' | sed 's|.*/[a-z0-9]*-||; s|\.drv$||'
fi
if echo "$output" | grep -q 'will be fetched'; then
echo ""
echo "$output" | grep 'will be fetched'
echo "$output" | grep -A9999 'will be fetched' | tail -n+2 | sed 's|.*/[a-z0-9]*-||'
fi
## activation
# Unified activation commands using nh via flake apps
# All recipes accept nh flags: --dry (preview), --ask (confirm), --verbose
# Auto-detect platform and activate current machine
[group('activation')]
activate *FLAGS:
#!/usr/bin/env bash
set -euo pipefail
if [[ "$(uname -s)" == "Darwin" ]]; then
exec just activate-darwin "$(hostname -s)" {{FLAGS}}
elif [ -f /etc/NIXOS ]; then
exec just activate-os "$(hostname)" {{FLAGS}}
else
exec just activate-home "$USER" {{FLAGS}}
fi
# Activate darwin configuration
[group('activation')]
activate-darwin hostname *FLAGS:
@echo "Activating darwin configuration for {{hostname}}..."
@if [ -x /opt/homebrew/bin/brew ]; then /opt/homebrew/bin/brew update; fi
{{nix_cmd}} run .#darwin -- {{hostname}} . {{FLAGS}}
# Activate NixOS configuration
[group('activation')]
activate-os hostname *FLAGS:
@echo "Activating NixOS configuration for {{hostname}}..."
{{nix_cmd}} run .#os -- {{hostname}} . {{FLAGS}}
# Activate home-manager configuration
[group('activation')]
activate-home username *FLAGS:
@echo "Activating home-manager configuration for {{username}}..."
{{nix_cmd}} run .#home -- {{username}} . {{FLAGS}}
# Print nix flake inputs and outputs
[group('nix')]
flake-info:
{{nix_cmd}} flake metadata
{{nix_cmd}} flake show --legacy --all-systems
# Enumerate flake output surface by category (all 20 top-level outputs)
[group('nix')]
nix-flake-io:
#!/usr/bin/env bash
set -euo pipefail
sys=$(nix eval --impure --raw --expr 'builtins.currentSystem')
systems=(aarch64-darwin aarch64-linux x86_64-linux)
# Per-system attrsets (members listed for current system)
printf "## checks\n"
nix eval ".#checks.${sys}" --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
printf "\n## packages\n"
nix eval ".#packages.${sys}" --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
printf "\n## devShells\n"
nix eval ".#devShells.${sys}" --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
printf "\n## apps\n"
nix eval ".#apps.${sys}" --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
printf "\n## formatter\n"
nix eval ".#formatter.${sys}.name" 2>/dev/null || echo "(empty)"
# Top-level attrsets
printf "\n## overlays\n"
overlays_type=$(nix eval --raw .#overlays --apply 'x: builtins.typeOf x' 2>/dev/null || echo "missing")
if [ "$overlays_type" = "set" ]; then
nix eval .#overlays --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
elif [ "$overlays_type" = "list" ]; then
overlays_len=$(nix eval --raw .#overlays --apply 'x: toString (builtins.length x)' 2>/dev/null || echo "?")
echo "(list of ${overlays_len} items)"
else
echo "(empty)"
fi
printf "\n## nixpkgsOverlays\n"
npo_type=$(nix eval --raw .#nixpkgsOverlays --apply 'x: builtins.typeOf x' 2>/dev/null || echo "missing")
if [ "$npo_type" = "list" ]; then
npo_len=$(nix eval --raw .#nixpkgsOverlays --apply 'x: toString (builtins.length x)' 2>/dev/null || echo "?")
echo "(list of ${npo_len} items)"
elif [ "$npo_type" = "set" ]; then
nix eval .#nixpkgsOverlays --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
else
echo "(empty)"
fi
printf "\n## nixosModules\n"
nix eval .#nixosModules --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
printf "\n## darwinModules\n"
nix eval .#darwinModules --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
printf "\n## nixosConfigurations\n"
nix eval .#nixosConfigurations --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
printf "\n## darwinConfigurations\n"
nix eval .#darwinConfigurations --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
# modules: deferred-module-composition namespace (one level of sub-namespaces)
printf "\n## modules\n"
if nix eval .#modules --apply builtins.attrNames --json 2>/dev/null >/tmp/.nix-flake-io-modules.$$; then
for ns in $(jq -r '.[]' /tmp/.nix-flake-io-modules.$$); do
printf "### modules.%s\n" "$ns"
nix eval ".#modules.${ns}" --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
done
rm -f /tmp/.nix-flake-io-modules.$$
else
echo "(empty)"
fi
# homeConfigurations: flat <user>@<system> (vanixiets flat-tuple shape)
printf "\n## homeConfigurations\n"
if entries=$(nix eval ".#homeConfigurations" --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]'); then
if [ -n "$entries" ]; then
while IFS= read -r e; do
printf "%s\n" "$e"
done <<< "$entries"
fi
fi
# nixidyEnvs: per-system × env
printf "\n## nixidyEnvs\n"
for s in "${systems[@]}"; do
if envs=$(nix eval ".#nixidyEnvs.${s}" --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]'); then
if [ -n "$envs" ]; then
while IFS= read -r e; do
printf "%s.%s\n" "$s" "$e"
done <<< "$envs"
fi
fi
done
# containerMatrix: top-level keys only (members are derivations/lists, not attrsets)
printf "\n## containerMatrix\n"
nix eval .#containerMatrix --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
# clan / clanInternals: clan-core composition attrsets; enumerate top-level keys
printf "\n## clan\n"
nix eval .#clan --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
printf "\n## clanInternals\n"
nix eval .#clanInternals --apply builtins.attrNames --json 2>/dev/null | jq -r '.[]' || echo "(empty)"
# Large re-exports: emit count only (enumerating members pollutes output)
printf "\n## lib\n"
lib_count=$(nix eval --raw .#lib --apply 'x: toString (builtins.length (builtins.attrNames x))' 2>/dev/null || echo "0")
echo "(nixpkgs.lib re-export, ${lib_count} top-level attrs)"
printf "\n## legacyPackages\n"
for s in "${systems[@]}"; do
if count=$(nix eval --raw ".#legacyPackages.${s}" --apply 'x: toString (builtins.length (builtins.attrNames x))' 2>/dev/null); then
printf "%s: (nixpkgs re-export, %s top-level attrs)\n" "$s" "$count"
fi
done
printf "\n## tests\n"
tests_count=$(nix eval --raw .#tests --apply 'x: toString (builtins.length (builtins.attrNames x))' 2>/dev/null || echo "0")
echo "(${tests_count} top-level test attrs)"
printf "\n## inputs\n"
nix flake metadata --json 2>/dev/null | jq -r '.locks.nodes | keys[] | select(. != "root")'
# Lint nix files
[group('nix')]
lint:
prek run --all-files
# Manually enter dev shell
[group('nix')]
dev:
{{nix_cmd}} develop
# Remove build output link (no garbage collection)
[group('nix')]
clean:
rm -f ./result
# Preview nix store garbage collection (dry run)
[group('nix')]
gc-dry keep="5" keep_since="7d":
#!/usr/bin/env bash
set -euo pipefail
nh clean all -n -k {{keep}} -K {{keep_since}}
echo ""
echo "This was a dry run. To execute garbage collection:"
echo " just gc {{keep}} {{keep_since}}"
echo " nh clean all -k {{keep}} -K {{keep_since}}"
# Execute nix store garbage collection
[group('nix')]
gc keep="5" keep_since="7d":
nh clean all -k {{keep}} -K {{keep_since}}
# Build nix flake
[group('nix')]
build profile: lint check
{{nix_cmd}} build --json --no-link --print-build-logs ".#{{ profile }}"
# Build an experimental debug package with nom (isolated from nixpkgs/CI builds)
[group('nix')]
debug-build package:
nom build '.#debug.{{ package }}'
# List all available debug packages
[group('nix')]
debug-list:
@echo "Available debug packages:"
@{{nix_cmd}} eval .#debug --apply 'builtins.attrNames' --json | jq -r '.[]' | sort
# Check nix flake
[group('nix')]
check:
#!/usr/bin/env bash
set -euo pipefail
echo "Running nix flake check..."
{{nix_cmd}} flake check -L --show-trace
# Validate flake checks via nix-fast-build (failure isolation, parallel eval+build, nom output)
# --eval-workers 4: reduces SQLite eval-cache contention (harmless but noisy at default=ncpus)
# nom=auto|on|off: auto disables nom when stdout is not a TTY (e.g., piped to tee)
# push=off|on: on uploads built paths to the niks3 PUSH server (auth token resolved by the
# niks3 client from ~/.config/niks3/auth-token); the PULL substituter cache.scientistexperience.net
# is configured separately. Params are positional, so usage is: just check-fast auto on
[group('nix')]
check-fast nom="auto" push="off":
#!/usr/bin/env bash
set -euo pipefail
case "{{nom}}" in
auto) [ -t 1 ] && flag="" || flag="--no-nom" ;;
on) flag="" ;;
off) flag="--no-nom" ;;
*) echo "nom must be auto|on|off" >&2; exit 1 ;;
esac
pushflag=""; [ "{{push}}" = "on" ] && pushflag="--niks3-server https://niks3.scientistexperience.net"
nix-fast-build $flag $pushflag \
--no-link \
--option accept-flake-config true \
--eval-workers 4 \
--flake ".#checks.$(nix eval --impure --raw --expr 'builtins.currentSystem')"
# Verify system configuration builds after updates (run before activate)
[group('nix')]
verify:
@./scripts/verify-system.sh
# Bisect nixpkgs commits to find which one broke the build (automatic mode)
[group('nix')]
bisect-nixpkgs:
@./scripts/bisect-nixpkgs.sh auto
# Bisect nixpkgs commits (manual mode: start, step, status, reset)
[group('nix')]
bisect-nixpkgs-manual command="status":
@./scripts/bisect-nixpkgs.sh {{ command }}
# Shell with bootstrap dependencies
[group('nix')]
bootstrap-shell:
nix \
--extra-experimental-features "nix-command flakes" \
shell \
"nixpkgs#git" \
"nixpkgs#just"
# Idempotent post-nix bootstrap: install direnv if missing, report status
# Body lives in modules/apps/bootstrap/bootstrap.{nix,sh}.
# Chicken-and-egg: for first-contact nix install, use `make bootstrap`.
[group('bootstrap')]
bootstrap *ARGS:
{{nix_cmd}} run --no-warn-dirty .#bootstrap -- {{ARGS}}
# Verify host nix/flakes/direnv/flake-metadata (mirror of `make verify`)
# Body lives in modules/apps/bootstrap/verify.{nix,sh}.
[group('bootstrap')]
bootstrap-verify *ARGS:
{{nix_cmd}} run --no-warn-dirty .#verify -- {{ARGS}}
# Generate ~/.config/sops/age/keys.txt (mirror of `make setup-user`)
# Body lives in modules/apps/bootstrap/setup-user.{nix,sh}.
# Idempotent: re-print public key and exit 0 if the key already exists.
[group('bootstrap')]
bootstrap-setup-user *ARGS:
{{nix_cmd}} run --no-warn-dirty .#setup-user -- {{ARGS}}
# Bootstrap build home-manager with flake
[group('nix-home-manager')]
home-manager-bootstrap-build profile="aarch64-linux":
nix \
--extra-experimental-features "nix-command flakes" \
run home-manager -- build \
--extra-experimental-features "nix-command flakes" \
--flake ".#{{ profile }}" \
--show-trace \
--print-build-logs
# Bootstrap switch home-manager with flake
[group('nix-home-manager')]
home-manager-bootstrap-switch profile="aarch64-linux":
nix \
--extra-experimental-features "nix-command flakes" \
run home-manager -- switch \
--extra-experimental-features "nix-command flakes" \
--flake ".#{{ profile }}" \
--show-trace \
--print-build-logs
# Build home-manager with flake
[group('nix-home-manager')]
home-manager-build profile="aarch64-linux":
home-manager build --flake ".#{{ profile }}"
# Switch home-manager with flake
[group('nix-home-manager')]
home-manager-switch profile="aarch64-linux":
home-manager switch --flake ".#{{ profile }}"
# Bootstrap nix-darwin with flake
[group('nix-darwin')]
darwin-bootstrap profile="aarch64":
{{nix_cmd}} run nix-darwin -- switch --flake ".#{{ profile }}"
# Build darwin from flake
[group('nix-darwin')]
darwin-build profile="aarch64":
just build "darwinConfigurations.{{ profile }}.config.system.build.toplevel"
# Test darwin from flake
[group('nix-darwin')]
darwin-test profile="aarch64":
darwin-rebuild check --flake ".#{{ profile }}"
# Bootstrap nixos
[group('nixos')]
nixos-bootstrap destination username publickey:
ssh \
-o PubkeyAuthentication=no \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
{{destination}} " \
parted /dev/nvme0n1 -- mklabel gpt; \
parted /dev/nvme0n1 -- mkpart primary 512MiB -8GiB; \
parted /dev/nvme0n1 -- mkpart primary linux-swap -8GiB 100\%; \
parted /dev/nvme0n1 -- mkpart ESP fat32 1MiB 512MiB; \
parted /dev/nvme0n1 -- set 3 esp on; \
sleep 1; \
mkfs.ext4 -L nixos /dev/nvme0n1p1; \
mkswap -L swap /dev/nvme0n1p2; \
mkfs.fat -F 32 -n boot /dev/nvme0n1p3; \
sleep 1; \
mount /dev/disk/by-label/nixos /mnt; \
mkdir -p /mnt/boot; \
mount /dev/disk/by-label/boot /mnt/boot; \
nixos-generate-config --root /mnt; \
sed --in-place '/system\.stateVersion = .*/a \
nix.extraOptions = \"experimental-features = nix-command flakes\";\n \
security.sudo.enable = true;\n \
security.sudo.wheelNeedsPassword = false;\n \
services.openssh.enable = true;\n \
services.openssh.settings.PasswordAuthentication = false;\n \
services.openssh.settings.PermitRootLogin = \"no\";\n \
users.mutableUsers = false;\n \
users.users.{{username}}.extraGroups = [ \"wheel\" ];\n \
users.users.{{username}}.initialPassword = \"{{username}}\";\n \
users.users.{{username}}.home = \"/home/{{username}}\";\n \
users.users.{{username}}.isNormalUser = true;\n \
users.users.{{username}}.openssh.authorizedKeys.keys = [ \"{{publickey}}\" ];\n \
' /mnt/etc/nixos/configuration.nix; \
nixos-install --no-root-passwd; \
reboot;"
# Copy flake to VM
[group('nixos')]
nixos-vm-sync user destination:
rsync -avz \
--exclude='.direnv' \
--exclude='result' \
. \
{{ user }}@{{ destination }}:~/vanixiets
# Build nixos from flake
[group('nixos')]
nixos-build profile="aarch64":
just build "nixosConfigurations.{{ profile }}.config.system.build.toplevel"
# Test nixos from flake
[group('nixos')]
nixos-test profile="aarch64":
nixos-rebuild test --flake ".#{{ profile }}"
# Update nix flake
[group('nix')]
update:
{{nix_cmd}} flake update
# Update a package using its updateScript
# Note: claude-code-bin and ccstatusline are now from llm-agents and update via flake update
[group('nix')]
update-package package="atuin-format":
#!/usr/bin/env bash
set -euo pipefail
UPDATE_SCRIPT=$({{nix_cmd}} build .#{{ package }}.updateScript --no-link --print-out-paths)
echo "Running updateScript for {{ package }}..."
$UPDATE_SCRIPT
echo "Update complete. Review changes with: git diff"
## bun
# Regenerate bun.nix from bun.lock using the pinned bun2nix CLI
# Assumes the devshell (bun2nix + treefmt on PATH); for a non-devshell
# invocation use `nix run .#regenerate-bun-nix` instead.
[group('bun')]
regenerate-bun-nix:
bun2nix --lock-file bun.lock --output-file bun.nix
treefmt bun.nix
# Fail if the npm playwright version drifts from the flake-provided playwright version.
# Run standalone as a sanity check or let the composite gate on it.
[group('bun')]
bun-drift-check:
#!/usr/bin/env bash
set -euo pipefail
FLAKE_PW=$(nix eval --raw --inputs-from . "playwright-web-flake#packages.$(nix eval --impure --raw --expr builtins.currentSystem).playwright-driver.version")
NPM_PW=$(jq -r '.devDependencies."playwright"' packages/docs/package.json)
NPM_PWT=$(jq -r '.devDependencies."@playwright/test"' packages/docs/package.json)
if [[ "$NPM_PW" != "$FLAKE_PW" || "$NPM_PWT" != "$FLAKE_PW" ]]; then
echo "ERROR: playwright drift detected." >&2
echo " flake playwright-web-flake: $FLAKE_PW" >&2
echo " npm playwright: $NPM_PW" >&2
echo " npm @playwright/test: $NPM_PWT" >&2
exit 1
fi
echo "playwright in sync at $FLAKE_PW"
# Bulk-bump every dep in every workspace to latest stable (playwright included;
# reverted by bun-repin-playwright in the composite flow). Hits the npm registry.
[group('bun')]
bun-bump-all:
#!/usr/bin/env bash
set -euo pipefail
echo "Bumping workspace root..."
bun update --latest
echo "Bumping packages/docs..."
(cd packages/docs && bun update --latest)
# Overwrite playwright + @playwright/test in packages/docs/package.json to the
# exact version pinned by the playwright-web-flake flake input. Preserves the
# rangeStrategy=pin invariant that Renovate enforces.
[group('bun')]
bun-repin-playwright:
#!/usr/bin/env bash
set -euo pipefail
FLAKE_PW=$(nix eval --raw --inputs-from . "playwright-web-flake#packages.$(nix eval --impure --raw --expr builtins.currentSystem).playwright-driver.version")
pkg=packages/docs/package.json
tmp=$(mktemp)
jq --arg v "$FLAKE_PW" '
.devDependencies["playwright"] = $v |
.devDependencies["@playwright/test"] = $v
' "$pkg" > "$tmp"
mv "$tmp" "$pkg"
echo "Re-pinned playwright + @playwright/test to $FLAKE_PW in $pkg"
# Reconcile bun.lock with the current package.json(s) without touching node_modules.
# Re-resolves any dep whose locked version no longer satisfies its package.json range.
[group('bun')]
bun-lockfile-reconcile:
bun install --lockfile-only
# Preview outdated deps across all workspaces that bun-update-latest-stable
# would bump. Excludes playwright per the flake-is-version-ceiling invariant.
# The "Latest" column maps to what --latest bumps; "Update" to plain bun update.
[group('bun')]
bun-outdated:
bun outdated --recursive '!playwright' '!@playwright/test'
# Bump all non-playwright deps to latest stable, then reconcile bun.lock and
# regenerate bun.nix. Playwright stays pinned to the playwright-web-flake version
# per the flake-is-version-ceiling invariant.
[group('bun')]
bun-update-latest-stable:
#!/usr/bin/env bash
set -euo pipefail
echo "=== Phase 1: Playwright drift check ==="
just bun-drift-check
echo "=== Phase 2: Bump all deps to latest stable ==="
just bun-bump-all
echo "=== Phase 3: Re-pin playwright to flake version ==="
just bun-repin-playwright
echo "=== Phase 4: Reconcile bun.lock ==="
just bun-lockfile-reconcile
echo "=== Phase 5: Regenerate bun.nix ==="
just regenerate-bun-nix
echo "=== Done ==="
git diff --stat -- package.json packages/docs/package.json bun.lock bun.nix
echo ""
echo "Verify playwright pin preserved:"
grep -E '"(playwright|@playwright/test)":' packages/docs/package.json
## agents
# Regenerate the vendored openspec claude assets from the pinned llm-agents input.
# Runs openspec init in a sandboxed temp dir; rerun after an llm-agents bump.
[group('agents')]
openspec-regen:
{{nix_cmd}} run .#openspec-refresh-vendored-artifacts
## terraform/terranix
# Run terraform via terranix flake app (init + apply, arguments not supported)
[group('terraform')]
terraform:
rosetta-manage --stop
rm -f terraform/.terraform.lock.hcl
{{nix_cmd}} run .#terraform
# Initialize terraform
[group('terraform')]
terraform-init:
rosetta-manage --stop
rm -f terraform/.terraform.lock.hcl
{{nix_cmd}} run .#terraform.terraform -- init -input=false
# Save terraform plan for review (writes terraform/tfplan)
[group('terraform')]
terraform-plan *ARGS: terraform-init
{{nix_cmd}} run .#terraform.terraform -- plan -out=tfplan {{ARGS}}
# Apply a saved terraform plan (reads terraform/tfplan)
[group('terraform')]
terraform-apply *ARGS: terraform-init
{{nix_cmd}} run .#terraform.terraform -- apply tfplan {{ARGS}}
# Run terraform destroy
[group('terraform')]
terraform-destroy *ARGS: terraform-init
{{nix_cmd}} run .#terraform.terraform -- destroy {{ARGS}}
## clan
# Commands for clan-based machine management (deferred module composition+clan architecture)
# Run all tests (nix flake check)
[group('clan')]
test:
{{nix_cmd}} flake check
# Run fast tests only (nix-unit + validation tests)
[group('clan')]
test-quick:
@echo "Running fast validation tests..."
@echo "TC-017: Naming conventions"
{{nix_cmd}} build .#checks.aarch64-darwin.naming-conventions --print-build-logs
@echo ""
@echo "TC-007: Secrets generation"
{{nix_cmd}} build .#checks.aarch64-darwin.secrets-generation --print-build-logs
@echo ""
@echo "TC-006: Deployment safety"
{{nix_cmd}} build .#checks.aarch64-darwin.deployment-safety --print-build-logs
@echo ""
@echo "TC-012: Terraform validation"
{{nix_cmd}} build .#checks.aarch64-darwin.terraform-validate --print-build-logs
@echo ""
@echo "✓ All validation tests passed"
# Run integration tests (VM tests - Linux only)
[group('clan')]
test-integration:
@echo "Running VM integration tests (Linux only)..."
@echo ""
@echo "TC-005: VM test framework validation"
{{nix_cmd}} build .#checks.x86_64-linux.vm-test-framework --print-build-logs
@echo ""
@echo "TC-010: VM boot all machines"
{{nix_cmd}} build .#checks.x86_64-linux.vm-boot-all-machines --print-build-logs
@echo ""
@echo "All VM integration tests passed!"
# Build all machine configurations using nom
[group('clan')]
build-all:
@echo "Building all machine configurations..."
nom build .#nixosConfigurations.cinnabar.config.system.build.toplevel
nom build .#nixosConfigurations.electrum.config.system.build.toplevel
nom build .#darwinConfigurations.blackphos.system
nom build .#darwinConfigurations.stibnite.system
@echo "All machines built successfully"
# Build a specific machine configuration
[group('clan')]
build-machine machine:
nom build .#nixosConfigurations.{{machine}}.config.system.build.toplevel || \
nom build .#darwinConfigurations.{{machine}}.system
# Show flake outputs
[group('clan')]
clan-show:
{{nix_cmd}} flake show
# Show flake metadata
[group('clan')]
clan-metadata:
{{nix_cmd}} flake metadata
## docs
# Install workspace dependencies
[group('docs')]
install:
bun install {{ if env("CI", "") != "" { "--frozen-lockfile" } else { "" } }}
# Start documentation development server
[group('docs')]
docs-dev:
cd packages/docs && bun run dev
# Build the documentation site
[group('docs')]
docs-build: diagrams-build
cd packages/docs && bun run build
# Preview the built documentation site
[group('docs')]
docs-preview:
cd packages/docs && bun run preview
# Format documentation code with Biome
[group('docs')]
docs-format:
cd packages/docs && bun run format
# Lint documentation code with Biome
[group('docs')]
docs-lint:
cd packages/docs && bun run lint
# Check and fix documentation code with Biome
[group('docs')]
docs-check:
cd packages/docs && bun run check:fix
# Validate internal and external links in documentation
[group('docs')]
docs-linkcheck:
nix build --accept-flake-config .#checks.$(nix eval --raw --impure --expr builtins.currentSystem).package-vanixiets-docs-test-linkcheck
## diagrams
# Compile all typst diagrams to SVG and optimize for web
[group('diagrams')]
diagrams-build:
#!/usr/bin/env bash
set -euo pipefail
echo "Compiling typst diagrams to SVG..."
cd packages/docs/diagrams
for typ in *.typ; do
[ -f "$typ" ] || continue
name="${typ%.typ}"
echo " $typ -> $name.svg"
typst compile --format svg "$typ" "../public/diagrams/$name.svg"
done
echo "Optimizing SVGs with svgo..."
cd ..
for svg in public/diagrams/*.svg; do
[ -f "$svg" ] || continue
echo " Optimizing $(basename "$svg")"
svgo --quiet "$svg" -o "$svg"
done
echo "Done. Diagrams in packages/docs/public/diagrams/"
# Compile a single typst diagram (without optimization)
[group('diagrams')]
diagrams-compile name:
cd packages/docs/diagrams && typst compile --format svg "{{name}}.typ" "../public/diagrams/{{name}}.svg"
# Watch typst diagrams for changes and recompile
[group('diagrams')]
diagrams-watch:
cd packages/docs/diagrams && typst watch --format svg reading-paths.typ ../public/diagrams/reading-paths.svg
# Run all documentation tests
[group('docs')]
docs-test:
cd packages/docs && bun run test
# Run documentation unit tests
[group('docs')]
docs-test-unit:
cd packages/docs && bun run test:unit
# Run documentation E2E tests
[group('docs')]
docs-test-e2e:
cd packages/docs && bun run test:e2e
# Open Playwright HTML report from last E2E test run
[group('docs')]
docs-test-e2e-report:
cd packages/docs && bunx playwright show-report
# Generate documentation test coverage report
[group('docs')]
docs-test-coverage:
cd packages/docs && bun run test:coverage
# Deploy documentation to Cloudflare Workers (preview).
# Wraps with `sops exec-env secrets/shared.yaml '<cmd>'` so
# CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID are exported per the
# deploy-docs env-var contract (ADR-002 / env-var-contract-design.md
# §2.1.3 Call site A). Devs with a local `.env` already exporting the
# vars can skip the wrap; the sops prefix is idempotent and keeps fresh
# clones without `.env` working. `sops exec-env` requires exactly two
# positional args (file + single shell-command string), so the nix-run
# invocation is quoted as one arg.
[group('docs')]
docs-deploy-preview branch=`git branch --show-current`:
sops exec-env secrets/shared.yaml \
'nix run --accept-flake-config .#deploy-docs -- preview "{{branch}}"'
# Deploy documentation to Cloudflare Workers (production).
# See docs-deploy-preview header for the sops wrap rationale.
[group('docs')]
docs-deploy-production:
sops exec-env secrets/shared.yaml \
'nix run --accept-flake-config .#deploy-docs -- production'
# List recent Cloudflare deployments
[group('docs')]
docs-deployments:
cd packages/docs && sops exec-env ../../secrets/shared.yaml "bunx wrangler deployments list"
# Tail live logs from Cloudflare Workers
[group('docs')]
docs-tail:
cd packages/docs && sops exec-env ../../secrets/shared.yaml "bunx wrangler tail"
# List recent Cloudflare versions
[group('docs')]
docs-versions limit="10":
cd packages/docs && sops exec-env ../../secrets/shared.yaml "bunx wrangler versions list --limit {{limit}}"
## containers
# Unified container builds using pkgsCross
# Works identically on x86_64-linux, aarch64-linux, and aarch64-darwin
# pkgsCross auto-optimizes: native when host == target, cross-compile otherwise
# Build a container for target architecture (x86_64 or aarch64)
[group('containers')]
container-build CONTAINER="fd" TARGET="aarch64":
{{nix_cmd}} build '.#{{CONTAINER}}Container-{{TARGET}}'
# Build containers for both architectures
[group('containers')]
container-build-all CONTAINER="fd":
@echo "Building x86_64-linux..."
{{nix_cmd}} build '.#{{CONTAINER}}Container-x86_64' -o result-x86_64
@echo "Building aarch64-linux..."
{{nix_cmd}} build '.#{{CONTAINER}}Container-aarch64' -o result-aarch64
@echo "✓ Both architectures built successfully"
# Push multi-arch manifest to registry (requires GITHUB_TOKEN)
# TAGS: comma-separated additional tags applied via crane (no re-upload)
[group('containers')]
container-push CONTAINER="fd" VERSION="1.0.0" TAGS="":
VERSION={{VERSION}} TAGS={{TAGS}} {{nix_cmd}} run --impure '.#{{CONTAINER}}Manifest'
# Push single-arch manifest (x86_64 only)
[group('containers')]
container-push-x86 CONTAINER="fd" VERSION="1.0.0" TAGS="":
VERSION={{VERSION}} TAGS={{TAGS}} {{nix_cmd}} run --impure '.#{{CONTAINER}}Manifest-x86_64'
# Push single-arch manifest (aarch64 only)
[group('containers')]
container-push-arm CONTAINER="fd" VERSION="1.0.0" TAGS="":
VERSION={{VERSION}} TAGS={{TAGS}} {{nix_cmd}} run --impure '.#{{CONTAINER}}Manifest-aarch64'
# Load container image to Docker daemon via nix2container
[group('containers')]
container-load CONTAINER="fd" TARGET="aarch64":
{{nix_cmd}} run '.#{{CONTAINER}}Container-{{TARGET}}.copyToDockerDaemon'
# Test container by running with --help
[group('containers')]
container-test BINARY="fd":
docker run --rm {{BINARY}}:latest --help
# Complete workflow: build, load, and test a container
[group('containers')]
container-all CONTAINER="fd" BINARY="" TARGET="aarch64":
#!/usr/bin/env bash
set -euo pipefail
BINARY="${BINARY:-$CONTAINER}"
just container-build {{CONTAINER}} {{TARGET}}
just container-load {{CONTAINER}} {{TARGET}}
just container-test "$BINARY"
# Verify container architecture metadata
[group('containers')]
container-verify CONTAINER="fd" TARGET="aarch64":
#!/usr/bin/env bash
set -euo pipefail
RESULT=$({{nix_cmd}} build '.#{{CONTAINER}}Container-{{TARGET}}' --no-link --print-out-paths)
echo "Container: $RESULT"
echo "Architecture: $(jq -r '.arch' "$RESULT")"
echo "Layers: $(jq '.layers | length' "$RESULT")"
# Defined containers - keep in sync with containerDefs in modules/containers/default.nix
# CI uses `nix eval .#containerMatrix` for discovery; this is for local convenience
_containers := "fd rg"
# Show container matrix from Nix (same data CI uses)
[group('containers')]
container-matrix:
@echo "=== Container Matrix (from Nix) ==="
@{{nix_cmd}} eval .#containerMatrix --json | jq .
# Build all defined containers for all architectures
[group('containers')]
container-build-all-defs:
#!/usr/bin/env bash
set -euo pipefail
for container in {{_containers}}; do
echo "=== Building $container for all architectures ==="
just container-build-all "$container"
done
echo "✓ All containers built successfully"
# Push all defined container manifests to registry
[group('containers')]
container-push-all VERSION="1.0.0" TAGS="":
#!/usr/bin/env bash
set -euo pipefail
for container in {{_containers}}; do
echo "=== Pushing $container manifest (version {{VERSION}}, tags: ${TAGS:-auto}) ==="
just container-push "$container" "{{VERSION}}" "{{TAGS}}"
done
echo "✓ All manifests pushed successfully"
# Complete workflow: build and push all containers
[group('containers')]
container-release VERSION="1.0.0" TAGS="":
#!/usr/bin/env bash
set -euo pipefail
echo "=== Building all containers ==="
just container-build-all-defs
echo ""
echo "=== Pushing all manifests ==="
just container-push-all "{{VERSION}}" "{{TAGS}}"
echo ""
echo "✓ Release complete: version {{VERSION}}"
if [[ -n "{{TAGS}}" ]]; then
echo " Additional tags: {{TAGS}}"
fi
## k3d
# Create local k3d cluster with OrbStack and bootstrap secrets
# Note: DNS configuration happens in k3d-deploy after Cilium CNI is ready
[group('k3d')]
k3d-up:
# cluster.yaml volume-mounts this host path at /manifests; k3d only warns
# when it is absent, leaving the mount unusable for the rest of the run.
@mkdir -p /tmp/k3d-manifests
ctlptl apply -f kubernetes/clusters/local-k3d/cluster.yaml
@just k3d-bootstrap-secrets
# Bootstrap secrets required before first deployment (idempotent)
# Supports both CI (SOPS_AGE_KEY env var) and local dev (file-based) workflows
# Body lives in modules/apps/cluster/k3d-bootstrap-secrets.{nix,sh}.
[group('k3d')]
k3d-bootstrap-secrets *ARGS:
{{nix_cmd}} run --no-warn-dirty .#k3d-bootstrap-secrets -- {{ARGS}}
# Configure CoreDNS to forward sslip.io queries to public DNS resolvers
# Required because OrbStack's DNS (192.168.107.1) cannot resolve sslip.io wildcards
# Body lives in modules/apps/cluster/k3d-configure-dns.{nix,sh}.
[group('k3d')]
k3d-configure-dns *ARGS:
{{nix_cmd}} run --no-warn-dirty .#k3d-configure-dns -- {{ARGS}}
# Delete local k3d cluster
[group('k3d')]
k3d-down:
ctlptl delete -f kubernetes/clusters/local-k3d/cluster.yaml
# Show k3d cluster status
[group('k3d')]
k3d-status:
k3d cluster list
# Deploy to k3d cluster using staged deployment (foundation then infrastructure)
# This mirrors the kargo pattern of sequential helm --wait installs but declaratively.
# Foundation (CNI) must be ready before infrastructure pods can schedule.
[group('k3d')]
k3d-deploy:
#!/usr/bin/env bash
set -euo pipefail
echo "=== Stage 1: Foundation (CNI) ==="
{{nix_cmd}} run .#k8s-deploy-local-k3d-foundation -- --yes
echo ""
echo "Waiting for Cilium pods to be created..."
sleep 5 # Brief delay for pods to be scheduled
echo "Waiting for Cilium Agent to be ready..."
kubectl wait --for=condition=Ready pods -l app.kubernetes.io/name=cilium-agent -n kube-system --timeout=300s
echo "Waiting for Cilium Operator to be ready..."
kubectl wait --for=condition=Ready pods -l app.kubernetes.io/name=cilium-operator -n kube-system --timeout=300s
echo ""
echo "=== Configure CoreDNS (requires CNI) ==="
just k3d-configure-dns
echo ""
echo "=== Stage 2: Infrastructure (CRDs) ==="
# First pass: applies CRDs in prio-10, CRs may fail (CRDs not yet registered)
{{nix_cmd}} run .#k8s-deploy-local-k3d-infrastructure -- --yes || true
echo ""
echo "Waiting for CRDs to be established..."
kubectl wait --for=condition=Established crd/sopssecrets.isindir.github.com --timeout=60s
kubectl wait --for=condition=Established crd/appprojects.argoproj.io --timeout=60s
kubectl wait --for=condition=Established crd/applications.argoproj.io --timeout=60s
kubectl wait --for=condition=Established crd/applicationsets.argoproj.io --timeout=60s
echo ""
echo "=== Stage 2: Infrastructure (CRs) ==="
# Second pass: CRDs are now registered, CRs will succeed
{{nix_cmd}} run .#k8s-deploy-local-k3d-infrastructure -- --yes
echo ""
echo "=== Deployment complete ==="