-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
82 lines (64 loc) · 2.71 KB
/
justfile
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
# friendship ended with Makefile
# I LOVE justFILE!!!!!!
# modules are unstable atm
# mod utils
true := "true"
# build the current configuration
build system="" +extra_args="":
nixos-rebuild -v -L --keep-going --accept-flake-config --log-format internal-json --flake .#{{system}} build \
{{extra_args}} |& nom --json
{{ if system == "" {"nvd diff /run/current-system result"} else {""} }}
# build and test the configuration, but don't switch
test system="":
nixos-rebuild -v -L test --flake .#{{system}} --accept-flake-config
deploy system:
nixos-rebuild switch --flake .#{{system}} --target-host {{system}} --use-remote-sudo -v -L --use-substitutes
dry-deploy system:
nixos-rebuild build --flake .#{{system}} --target-host {{system}} --use-remote-sudo -v -L --use-substitutes
# switch to the current configuration
switch system="": sudo_cache
sudo nixos-rebuild -v -L switch --flake .#{{system}} --accept-flake-config --keep-going
# literally nixos-rebuild boot with a different name
defer system="": sudo_cache
sudo nixos-rebuild -v -L boot --flake .#{{system}} --accept-flake-config
build-all: (for-all-systems 'build' 'true')
deploy-all: (for-all-systems 'deploy' '!system.config.gensokyo.traits.sensitive && (system.config.nixpkgs.hostPlatform.system == builtins.currentSystem)' true)
# check the flake
check:
nix flake check
# delete old nixos generations and GCs the store.
gc older_than="3d": sudo_cache
sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than {{older_than}}
sudo nix store gc -vL
# run utility programs
utils recipe="list" +extras="":
@echo "Running utils/{{recipe}}"
@just -d utils -f utils/justfile {{recipe}} {{extras}}
# update an input in the flake lockfile
update-input input:
nix flake lock --update-input {{input}}
# update everything in flake.lock and commit that
flake-update:
nix flake update --commit-lock-file
# list changes in the current config vs the system config
diff:
nvd diff /run/current-system result
# build a vm for a system
vm system run="true" bootloader="false":
nixos-rebuild -v -L build-vm{{if bootloader == "true" {"-with-bootloader"} else {""} }} --flake .#{{system}}
{{if run == true {"./result/bin/run-"+system+"-vm"} else {""} }}
[private]
sudo_cache:
@sudo -v
[private]
for-all-systems recipe filter ignore_failure="false":
#!/usr/bin/env bash
set -euxo pipefail
for system in $(nix eval --impure --apply 'configs: builtins.map (system: system.config.networking.hostName) (builtins.filter (system: {{filter}}) (builtins.attrValues configs))' .#nixosConfigurations --json | jq '.[]' | xargs); do
set +e
just {{recipe}} ${system}
if [ {{ if ignore_failure == true {""} else {"$? -ne 0 -o"} }} $? -eq 130 ]; then
exit 1;
fi
set -e
done