update deploy script
This commit is contained in:
parent
08cb02d7d9
commit
035b623b42
1 changed files with 13 additions and 3 deletions
16
deploy.sh
16
deploy.sh
|
@ -12,15 +12,25 @@ fi
|
||||||
|
|
||||||
mode="${1:-switch}"
|
mode="${1:-switch}"
|
||||||
host="${2:-nuc}"
|
host="${2:-nuc}"
|
||||||
target="${3:-$host.c3h}"
|
target="${3:-c3h@$host.c3h}"
|
||||||
|
|
||||||
|
if ! [ -d "hosts/$host" ]
|
||||||
|
then
|
||||||
|
echo "Host $host does not exist. Choose from:"
|
||||||
|
ls hosts
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
echo "deploying $host to $target"
|
echo "deploying $host to $target"
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
sources=$(nix-build nix/sources-dir.nix --no-out-link)
|
tmp=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$tmp"' EXIT
|
||||||
|
sources="$tmp/sources"
|
||||||
|
cp -r $(nix-build nix/sources-dir.nix --no-out-link) $tmp/sources
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
system_drv=$(nix-instantiate "<nixpkgs/nixos>" -I $sources -I "nixos-config=$PWD/hosts/$host/configuration.nix" | head -n1)
|
system_drv=$(nix-instantiate "<nixpkgs/nixos>" -A config.system.build.toplevel -I $sources -I "nixos-config=$PWD/hosts/$host/configuration.nix")
|
||||||
nix-copy-closure --to $target $system_drv
|
nix-copy-closure --to $target $system_drv
|
||||||
system=$(ssh $target "nix-store --realise $system_drv")
|
system=$(ssh $target "nix-store --realise $system_drv")
|
||||||
ssh $target "sudo nix-env -p /nix/var/nix/profiles/system -i $system && sudo /nix/var/nix/profiles/system/bin/switch-to-configuration $mode"
|
ssh $target "sudo nix-env -p /nix/var/nix/profiles/system -i $system && sudo /nix/var/nix/profiles/system/bin/switch-to-configuration $mode"
|
||||||
|
|
Loading…
Reference in a new issue