Jack O'Sullivan
f617ba07c3
Some checks failed
CI / Check, build and cache Nix flake (push) Failing after 1m41s
27 lines
730 B
Bash
Executable File
27 lines
730 B
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
REMOTE_STORE=/var/lib/harmonia
|
|
HOST="harmonia@object-ctr.ams1.int.nul.ie"
|
|
SSH_HOST="harmonia@$HOST"
|
|
SSH_KEY=/tmp/harmonia.key
|
|
STORE_URI="ssh-ng://$SSH_HOST?ssh-key=$SSH_KEY&remote-store=$REMOTE_STORE"
|
|
|
|
remote_cmd() {
|
|
ssh -i "$SSH_KEY" "$SSH_HOST" env NIX_REMOTE="$REMOTE_STORE" "$@"
|
|
}
|
|
|
|
echo "$HARMONIA_SSH_KEY" | base64 -d > "$SSH_KEY"
|
|
mkdir -p ~/.ssh
|
|
awk "{ print \"$HOST \" \$1 \" \" \$2 }" < .keys/harmonia.pub >> ~/.ssh/known_hosts
|
|
path="$1"
|
|
|
|
echo "Pushing $path to cache..."
|
|
nix copy --to "$STORE_URI" "$path"
|
|
|
|
echo "Updating profile..."
|
|
remote_cmd nix-env -p "$REMOTE_STORE"/nix/var/nix/profiles/nixfiles --set "$path"
|
|
|
|
echo "Collecting garbage..."
|
|
remote_cmd nix-collect-garbage --delete-older-than 30d
|