-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshared.just
More file actions
89 lines (77 loc) · 2.29 KB
/
shared.just
File metadata and controls
89 lines (77 loc) · 2.29 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
# generate a keypair, rekey all secrets
[group('deployment')]
@bootstrap host: _add
echo "Loading the bootstrap script..."
nix run .#bootstrap-{{host}}
# install with nixos-anywhere or LXC in PVE
[group('deployment')]
@install host build="local": _add
if [[ "{{host}}" == lxc-* ]]; then \
just _install-lxc {{host}}; \
else \
just _install-anywhere {{host}} {{build}}; \
fi
@_install-lxc host:
echo "Loading the install script..."
nix run .#install-{{host}}
@_install-anywhere host build:
test -d .bootstrap/extra && [ "$(ls -A .bootstrap/extra)" ] \
|| { echo "Can't find the keypair. Did you bootstrap?"; exit 1; }
nix run nixos-anywhere -- \
--extra-files '.bootstrap/extra' \
--build-on '{{build}}' \
--flake '.#{{host}}' \
root@{{host}}.{{landomain}}
# use deploy-rs to update existing hosts
[group('deployment')]
deploy *args: _add
#!/usr/bin/env sh
set -euo pipefail
MODE=auto
TARGETS=""
for arg in {{args}}; do
case "$arg" in
--remote) MODE=remote ;;
--local) MODE=local ;;
*) TARGETS="${TARGETS} .#${arg}" ;;
esac
done
if [ -z "$TARGETS" ]; then
echo "usage: just deploy <host...> [--remote|--local]" >&2
exit 2
fi
DEPLOY_ARG=--remote-build
case "$MODE" in
local) DEPLOY_ARG= ;;
remote) ;;
*) case "$TARGETS" in *".#lxc-"*) ;;
*) DEPLOY_ARG=--remote-build ;;
esac ;;
esac
if [ "$MODE" = "auto" ] && printf '%s' "$TARGETS" | grep -q '\.#lxc-' && \
! printf '%s' "$TARGETS" | grep -qv '\.#lxc-'; then
DEPLOY_ARG=
fi
nix run nixpkgs#deploy-rs -- -s ${DEPLOY_ARG} --targets ${TARGETS}
# create/edit agenix secret
[group('secrets')]
@secret secret: _add && rekey
nix run github:oddlama/agenix-rekey -- edit ./secrets/secrets/{{secret}}.age
# rekey all agenix secrets
[group('secrets')]
@rekey: _add
nix run github:oddlama/agenix-rekey -- rekey -a
# navigate config tree
[group('tools')]
@inspect:
nix run nixpkgs#nix-inspect -- -p .
# rebuild and switch this host to new configuration
[group('tools')]
@rebuild: _add
if [ -f /etc/NIXOS ]; then \
sudo nixos-rebuild switch --option always-allow-substitutes true --flake .; \
else \
sudo darwin-rebuild switch --option always-allow-substitutes true --flake .; \
fi
@_add:
git add --all