#!/usr/bin/env sh

set -eux

SCRIPT_DIR=$(dirname -- "$( readlink -f -- "$0"; )";)
ROOT_DIR="$SCRIPT_DIR"/..

cd "$ROOT_DIR"

# Fetch other changes from the central repo.
git fetch origin
git switch master
git merge --ff-only origin/master
git merge --no-edit origin/flake-update

sudo nixos-rebuild -L boot --flake .

# If everything worked, we publish our changes.
git push
git push origin master:flake-update
