-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
196 lines (172 loc) · 7.07 KB
/
Copy pathjustfile
File metadata and controls
196 lines (172 loc) · 7.07 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
# dotfiles task runner
# usage: just <recipe> — run a recipe
# just --list — list all recipes
# just update-pkg <name> — update a single package
# ── Formatting & Validation ──────────────────────────────────────────
# format all nix files
fmt:
nix fmt
# run flake checks
check:
nix flake check
# ── Flake Updates ────────────────────────────────────────────────────
# update all flake inputs
update-flake:
nix flake update --accept-flake-config
# update nixpkgs-unstable to newest rev where PACKAGES are cached
update-flake-cached +PACKAGES:
nix-cached-update {{PACKAGES}}
# ── Package Updates ──────────────────────────────────────────────────
# snowfall-lib puts nix sources in a separate store path, so nix-update
# can't locate the file to patch. --override-filename fixes this.
# format: "attr:relative/path/to/file.nix"
_nix_update_pkgs := "chrome-devtools-mcp:nix/packages/chrome-devtools-mcp/package.nix docs-mcp-server:nix/packages/docs-mcp-server/package.nix rusty-psn:nix/packages/rusty-psn/default.nix oclif:nix/packages/oclif/default.nix razer-cli:nix/packages/razer-cli/default.nix es-de:nix/packages/es-de/default.nix apple-emoji-linux:nix/packages/apple-emoji-linux/default.nix"
# update a single package via nix-update (pass extra args after name)
[no-exit-message]
update-pkg PKG *ARGS:
#!/usr/bin/env bash
set -euo pipefail
file="nix/packages/{{PKG}}/default.nix"
[[ -f "nix/packages/{{PKG}}/package.nix" ]] && file="nix/packages/{{PKG}}/package.nix"
nix-update "{{PKG}}" --flake --override-filename "$file" {{ARGS}}
# update opencode (custom script)
update-opencode:
./nix/packages/opencode/update.sh
# update sf-cli (custom script)
update-sf-cli:
./nix/packages/sf-cli/update.sh
# update xrt + xrt-plugin-amdxdna (custom script)
update-xrt:
./nix/packages/xrt/update.sh
# update fastflowlm (custom script)
update-fastflowlm:
./nix/packages/fastflowlm/update.sh
# update all packages that support nix-update
[no-exit-message]
update-nix-update-pkgs:
#!/usr/bin/env bash
set -uo pipefail
failed=()
succeeded=()
skipped=()
for entry in {{_nix_update_pkgs}}; do
pkg="${entry%%:*}"
file="${entry#*:}"
echo "── updating $pkg ──"
if output=$(nix-update "$pkg" --flake --override-filename "$file" 2>&1); then
if echo "$output" | grep -q "No changes\|No update\|skipping"; then
skipped+=("$pkg")
echo " skipped (up to date)"
else
succeeded+=("$pkg")
echo " updated"
fi
else
failed+=("$pkg")
echo " FAILED"
echo "$output" | tail -5 | sed 's/^/ /'
fi
echo
done
echo "══════════════════════════════════════"
echo " results"
echo "══════════════════════════════════════"
[[ ${#succeeded[@]} -gt 0 ]] && echo " updated: ${succeeded[*]}"
[[ ${#skipped[@]} -gt 0 ]] && echo " up to date: ${skipped[*]}"
[[ ${#failed[@]} -gt 0 ]] && echo " failed: ${failed[*]}"
echo "══════════════════════════════════════"
[[ ${#failed[@]} -gt 0 ]] && exit 1 || exit 0
# update ALL packages (nix-update + custom scripts)
[no-exit-message]
update-packages:
#!/usr/bin/env bash
set -uo pipefail
failed=()
succeeded=()
skipped=()
# ── custom update scripts ──
for entry in "opencode:./nix/packages/opencode/update.sh" "sf-cli:./nix/packages/sf-cli/update.sh" "xrt:./nix/packages/xrt/update.sh" "fastflowlm:./nix/packages/fastflowlm/update.sh"; do
pkg="${entry%%:*}"
script="${entry#*:}"
echo "── updating $pkg (custom) ──"
if output=$("$script" 2>&1); then
if echo "$output" | grep -qi "already up to date"; then
skipped+=("$pkg")
echo " skipped (up to date)"
else
succeeded+=("$pkg")
echo "$output" | tail -1 | sed 's/^/ /'
fi
else
failed+=("$pkg")
echo " FAILED"
echo "$output" | tail -5 | sed 's/^/ /'
fi
echo
done
# ── nix-update packages ──
for entry in {{_nix_update_pkgs}}; do
pkg="${entry%%:*}"
file="${entry#*:}"
echo "── updating $pkg ──"
if output=$(nix-update "$pkg" --flake --override-filename "$file" 2>&1); then
if echo "$output" | grep -q "No changes\|No update\|skipping"; then
skipped+=("$pkg")
echo " skipped (up to date)"
else
succeeded+=("$pkg")
echo " updated"
fi
else
failed+=("$pkg")
echo " FAILED"
echo "$output" | tail -5 | sed 's/^/ /'
fi
echo
done
echo "══════════════════════════════════════"
echo " results"
echo "══════════════════════════════════════"
[[ ${#succeeded[@]} -gt 0 ]] && echo " updated: ${succeeded[*]}"
[[ ${#skipped[@]} -gt 0 ]] && echo " up to date: ${skipped[*]}"
[[ ${#failed[@]} -gt 0 ]] && echo " failed: ${failed[*]}"
echo "══════════════════════════════════════"
[[ ${#failed[@]} -gt 0 ]] && exit 1 || exit 0
# ── Build & Deploy ───────────────────────────────────────────────────
# rebuild NixOS system config
os *ARGS:
nh os switch . {{ARGS}}
# rebuild home-manager config
home *ARGS:
nh home switch . {{ARGS}}
# build a specific host without switching
build HOST:
nix build '.#nixosConfigurations.{{HOST}}.config.system.build.toplevel'
# ── Stow ─────────────────────────────────────────────────────────────
# opencode is excluded from stow (via .stow-local-ignore) and symlinked
# as a directory so that its auto-installed node_modules resolves
# correctly for custom tool imports.
[private]
ensure-opencode-symlink:
#!/usr/bin/env bash
set -euo pipefail
target="$HOME/.config/opencode"
source="$HOME/workspace/dotfiles/stow/dot-config/opencode"
if [[ -L "$target" ]]; then
exit 0
fi
if [[ -d "$target" ]]; then
echo "warning: replacing ~/.config/opencode directory with symlink"
rm -rf "$target"
fi
ln -s "$source" "$target"
# symlink stow packages into $HOME
stow: ensure-opencode-symlink
stow stow
# re-stow (prune dead symlinks + restow)
restow: ensure-opencode-symlink
stow -R stow
# remove all stow symlinks
unstow:
stow -D stow
rm -f "$HOME/.config/opencode"