-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
90 lines (76 loc) · 2.75 KB
/
Copy pathjustfile
File metadata and controls
90 lines (76 loc) · 2.75 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
# Auto-detect the current hostname and run the right switch command
switch:
#!/usr/bin/env bash
HOST=$(hostname -s)
case "$HOST" in
spellbook)
sudo nix run nix-darwin -- switch --flake .#spellbook
;;
grimoire)
sudo nix run nix-darwin -- switch --flake .#grimoire
;;
tower)
sudo nixos-rebuild switch --flake .#tower
;;
*)
echo "Unknown host: $HOST — run 'just spellbook', 'just grimoire', or 'just tower' explicitly"
exit 1
;;
esac
# Switch spellbook — work MacBook (darwin)
spellbook:
sudo nix run nix-darwin -- switch --flake .#spellbook
# Switch grimoire — personal MacBook (darwin)
grimoire:
sudo nix run nix-darwin -- switch --flake .#grimoire
# Build tower (NixOS/WSL) without switching
tower:
nix build .#nixosConfigurations.tower.config.system.build.toplevel
# Switch tower (NixOS/WSL) — run on the tower machine
tower-switch:
sudo nixos-rebuild switch --flake .#tower
# Visualize the spellbook derivation tree
tree-spellbook:
nix run nixpkgs#nix-tree -- --derivation ~/.config/darwin#darwinConfigurations.spellbook.system
# Update all flake inputs (creates a new flake.lock)
update:
nix flake update
# Update a single flake input, e.g.: just update-input nixpkgs
update-input input:
nix flake update {{ input }}
# Check the flake for errors without building
check:
nix flake check
# Format all files
fmt:
nix fmt
# Collect garbage older than 30 days
gc:
nix-collect-garbage --delete-older-than 30d
sudo nix-collect-garbage --delete-older-than 30d
# Optimise the nix store (deduplicates identical files)
optimise:
nix store optimise
# Bootstrap the sops age key on spellbook from your SSH key (run once after first switch)
bootstrap-sops:
mkdir -p /var/lib/sops-nix
ssh-to-age -private-key -i ~/.ssh/id_ed25519 | sudo tee /var/lib/sops-nix/key.txt
sudo chmod 600 /var/lib/sops-nix/key.txt
echo "sops age key bootstrapped at /var/lib/sops-nix/key.txt"
# Edit sops secrets for a host (e.g.: just secret spellbook)
secret host:
sops secrets/hosts/{{ host }}.yaml
# Update the optout.nix hash from upstream do-not-track-cli
update-optout:
#!/usr/bin/env bash
set -euo pipefail
NIXFILE="flake/programs/privacy.nix"
URL="https://raw.githubusercontent.com/alloydwhitlock/do-not-track-cli/main/do_not_track.env"
NEW_HASH=$(nix-prefetch-url "$URL" 2>/dev/null)
CURRENT=$(grep 'sha256 = ' "$NIXFILE" | head -1 | sed 's/.*sha256 = "\(.*\)".*/\1/')
if [ "$NEW_HASH" = "$CURRENT" ]; then
echo "optout is already up to date ($CURRENT)"
exit 0
fi
sed -i "" "s|sha256 = \"$CURRENT\"|sha256 = \"$NEW_HASH\"|" "$NIXFILE"
echo "Updated optout hash: $CURRENT -> $NEW_HASH"