#!/bin/sh set -eux target=${target:-root@losurdo.sourcephile.fr} # Compile the derivation of the new system system=$(nix-instantiate "${0%/*}".nix -A config.system.build.toplevel) # Compile the build products of the new system nix-store --realise "$system" # Send the system nix-copy-closure --to "$target" --use-substitutes --gzip "$system" # Register the new system profile=/nix/var/nix/profiles/system ssh "$target" nix-env --profile "$profile" --set "$system" \ '&&' nix-env --profile "$profile" --delete-generations +5 # Send secrets pass "servers/losurdo/root/ssh/id_ed25519" | ssh "$target" install -m 0400 -o root -g root /dev/stdin \ /root/.ssh/id_ed25519 # Switch to the new system ssh "$target" "$profile"/bin/switch-to-configuration switch