carbon: +nix-diff

This commit is contained in:
Primrose 2024-08-02 12:26:19 +02:00
parent 7dbd39f87c
commit 94ac76e09d
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
4 changed files with 11 additions and 15 deletions

View file

@ -25,20 +25,6 @@
};
};
devShells.default = pkgs.mkShellNoCC {
shellHook = config.pre-commit.installationScript;
packages =
let
nix-diff = pkgs.writeShellApplication {
name = "nix-diff";
runtimeInputs = [
pkgs.nix-output-monitor
pkgs.nvd
];
text = builtins.readFile ./nix-diff.sh;
};
in
[ nix-diff ];
};
devShells.default = pkgs.mkShellNoCC { shellHook = config.pre-commit.installationScript; };
};
}

View file

@ -1,51 +0,0 @@
bold=$(tput bold)
normal=$(tput sgr0)
while [ $# -gt 0 ]; do
case "$1" in
--clean*)
for link in nix-diff*; do
set -x
unlink "$link"
set +x
done
exit 0
;;
--last*)
if [[ "$1" != *=* ]]; then shift; fi
_last_hash="${1#*=}"
;;
--hostname*)
if [[ "$1" != *=* ]]; then shift; fi
_hostname="${1#*=}"
;;
*)
printf "Error: unknown argument"
exit 1
;;
esac
shift
done
echo "Comparing ${bold}$_hostname${normal}'s configuration of ${bold}HEAD${normal} and ${bold}$_last_hash${normal}"
last_ref=".?ref=${_last_hash}#nixosConfigurations.${_hostname}.config.system.build.toplevel"
last_link="nix-diff-${_last_hash:0:7}"
if [ -L "$last_link" ]; then
echo "Found link ${bold}$last_link${normal}"
else
echo "Starting configuration build at ${bold}$_last_hash${normal}"
nix build "$last_ref" --out-link "$last_link" >/dev/null 2>&1 &
fi
echo "Starting configuration build at ${bold}HEAD${normal}"
this_ref=".#nixosConfigurations.${_hostname}.config.system.build.toplevel"
this_link="nix-diff-HEAD"
nix build "$this_ref" --out-link "$this_link" --log-format internal-json --verbose |& nom --json
echo "Waiting for all builds to complete..."
wait
echo "Completed."
echo "Diffing..."
nvd diff "$last_link" "$this_link"