2024-08-08 12:16:04 +00:00
|
|
|
#! /usr/bin/env nix-shell
|
|
|
|
#! nix-shell -i bash -p jq nixos-anywhere
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
USERNAME="root"
|
|
|
|
IP="gerd.fricloud.dk"
|
|
|
|
NIXPKGS=$(jq -r '.nixpkgs.url' ./shared/sources/sources.json)
|
|
|
|
|
|
|
|
export NIX_PATH="nixpkgs=$NIXPKGS"
|
|
|
|
|
|
|
|
if [ "$1" == "initial-deploy" ]; then
|
|
|
|
echo "Initial deployment..."
|
2024-08-08 16:59:58 +00:00
|
|
|
echo "Removed exit below if you really want... "
|
|
|
|
exit
|
2024-08-08 12:16:04 +00:00
|
|
|
NIX_TOP_LEVEL_PATH=$(nix build --impure -I nixos-config=./machines/gerd.nix --json --expr "(import <nixpkgs/nixos> {}).config.system.build.toplevel" | jq -r '.[].outputs.out')
|
|
|
|
NIX_DISKO_SCRIPT=$(nix build --impure -I nixos-config=./machines/gerd.nix --json --expr "(import <nixpkgs/nixos> {}).config.system.build.diskoScript" | jq -r '.[].outputs.out')
|
|
|
|
|
|
|
|
nixos-anywhere --store-paths "$NIX_DISKO_SCRIPT" "$NIX_TOP_LEVEL_PATH" "$USERNAME@$IP"
|
|
|
|
else
|
|
|
|
echo "Deploying..."
|
|
|
|
REBUILD_ACTION="switch"
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
REBUILD_ACTION="$1"
|
|
|
|
fi
|
|
|
|
nixos-rebuild \
|
|
|
|
-I nixos-config=./machines/gerd.nix \
|
|
|
|
"$REBUILD_ACTION" --target-host "$USERNAME@$IP"
|
|
|
|
fi
|