README: add deploy-flake.sh for non-nixos users

This commit is contained in:
Astro 2021-03-28 21:11:13 +02:00
parent f2fc6a1762
commit 427e4ede0d
2 changed files with 25 additions and 0 deletions

View File

@ -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 to show what is available. Note that the deploy scripts only work if
the target machines already has flakes enabled. 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 ## Mit NixOps

15
deploy-flake.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e
TARGET=$1
if [ -z "$TARGET" ]; then
echo "Usage: $0 <host.hq.c3d2.de>"
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"