feat(*): initialize new Snix infrastructure
Co-Authored-By: edef <edef@edef.eu> Co-Authored-by: Ryan Lahfa <raito@lix.systems> Change-Id: Ica1cda177a236814de900f50a8a61d288f58f519
This commit is contained in:
parent
067eff3427
commit
a52ea3675c
124 changed files with 27723 additions and 1631 deletions
52
ops/deploy-machine/deploy-machine.sh
Executable file
52
ops/deploy-machine/deploy-machine.sh
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env bash
|
||||
set -Ceuo pipefail
|
||||
|
||||
DOMAIN="snix.dev"
|
||||
FORGE_URL="cl.snix.dev"
|
||||
REPO="tvix"
|
||||
TARGET_SYSTEM="gerrit01"
|
||||
TARGET_IRC_CHANNEL="#tvix-dev"
|
||||
|
||||
HTML_ROOT="${HTML_ROOT:-/var/html/deploys."$DOMAIN"}"
|
||||
URL_BASE="${URL_BASE:-https://deploys."$DOMAIN"/diff}"
|
||||
IRCCAT_PORT="${IRCCAT_PORT:-4722}"
|
||||
|
||||
drv_hash() {
|
||||
basename "$1" | sed 's/-.*//'
|
||||
}
|
||||
|
||||
new_rev="$1"
|
||||
|
||||
if [ -z "$new_rev" ]; then
|
||||
>&2 echo "Usage: $0 <new_rev>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d "/tmp/deploy.worktree" ]; then
|
||||
>&2 echo "/tmp/deploy.worktree exists - exiting in case another deploy is currently running"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
worktree_dir=/tmp/worktree_dir
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$worktree_dir"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
git clone https://"$FORGE_URL"/"$REPO" "$worktree_dir" --reference /"$REPO"
|
||||
git -C "$worktree_dir" checkout "$new_rev"
|
||||
|
||||
current=$(nix show-derivation /run/current-system | jq -r 'keys | .[0]')
|
||||
new=$(nix-instantiate -A ops.nixos."$TARGET_SYSTEM" "$worktree_dir")
|
||||
|
||||
diff_filename="$(drv_hash "$current")..$(drv_hash "$new").html"
|
||||
nvd --color always diff "$current" "$new" \
|
||||
| ansi2html \
|
||||
>| "$HTML_ROOT/diff/$diff_filename"
|
||||
chmod a+r "$HTML_ROOT/diff/$diff_filename"
|
||||
|
||||
echo "$TARGET_IRC_CHANNEL $TARGET_SYSTEM is being deployed! system diff: $URL_BASE/$diff_filename" \
|
||||
| nc -w 5 -N localhost "$IRCCAT_PORT"
|
||||
|
||||
# TODO(grfn): Actually do the deploy
|
||||
Loading…
Add table
Add a link
Reference in a new issue