#! /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..." echo "Removed exit below if you really want... " exit NIX_TOP_LEVEL_PATH=$(nix build --impure -I nixos-config=./machines/gerd.nix --json --expr "(import {}).config.system.build.toplevel" | jq -r '.[].outputs.out') NIX_DISKO_SCRIPT=$(nix build --impure -I nixos-config=./machines/gerd.nix --json --expr "(import {}).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" # -I "nixpkgs=$(jq -r '.nixpkgs.url' ./shared/sources/sources.json)" \ fi