#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' export SHELL=`which bash` function usage() { cat < Watch for any changes between the flake nixosConfiguration for at time of invocation versus subsequent writes to the flake and its related files. Example use: ${0} The command watches until terminated with Ctrl-C or the `q` key. EOF } function spin() { while :;do for s in / - \\ \|; do printf "\r$s ...building...";sleep 0.2;done;done } if [[ $# -lt 1 ]] then usage exit 1 else system=$1 ; shift fi function drv() { nix --no-warn-dirty path-info --derivation \ ".#nixosConfigurations.${1}.config.system.build.toplevel" } original=$(drv ${system}) function drvdiff() { spin & spinner=$! revised=$(drv ${system}) kill $spinner if [[ $original == $revised ]] then echo "✅ Identical" else nvd diff ${original} ${revised} fi } export original system export -f drv drvdiff spin echo "Entering watch. Hit q to exit loop" fd | entr -s drvdiff