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