diff --git a/README.md b/README.md index ea05fca2..80969bec 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,17 @@ for example: `nix run c3d2#glotzbert-nixos-rebuild switch`. Use `nix flake show to show what is available. Note that the deploy scripts only work if the target machines already has flakes enabled. +### Remote deployment from non-NixOS +A shell script that copies the current working tree, and runs +`nixos-rebuild switch` on the target: + +```shell +./deploy-flake.sh hydra.hq.c3d2.de +``` + +It cannot not lookup hostnames in `host-registry.nix`. +It will not take extra care of the *secrets*. ## Mit NixOps diff --git a/deploy-flake.sh b/deploy-flake.sh new file mode 100755 index 00000000..9cec78e2 --- /dev/null +++ b/deploy-flake.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +set -e + +TARGET=$1 +if [ -z "$TARGET" ]; then + echo "Usage: $0 " + exit 1 +fi +HOSTNAME=$(echo $TARGET|cut -d . -f 1) + +rsync -az $(dirname $0) root@$TARGET:nix-config + +echo "$HOSTNAME> nixos-rebuild switch" +exec ssh root@$TARGET "nixos-rebuild --flake ./nix-config#$HOSTNAME switch"