aboutsummaryrefslogtreecommitdiffstats
path: root/nix-conf/pkgs/scripts
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2026-07-24 17:20:02 +0100
committerDavid Morgan <djm_uk@protonmail.com>2026-07-24 17:20:02 +0100
commit348e0a64a53c853bdf4922be1162518f9b615f61 (patch)
tree28766f7460b275b0f442f064b61a225c376c14e3 /nix-conf/pkgs/scripts
parent314e5c827abe785f3ec640210e7fc92f97e754a2 (diff)
downloaddotfiles-348e0a64a53c853bdf4922be1162518f9b615f61.tar.gz
Integrate system-update and check-versions
Diffstat (limited to 'nix-conf/pkgs/scripts')
-rw-r--r--nix-conf/pkgs/scripts/system-update.nix27
1 files changed, 27 insertions, 0 deletions
diff --git a/nix-conf/pkgs/scripts/system-update.nix b/nix-conf/pkgs/scripts/system-update.nix
index 0625793..37a5b2f 100644
--- a/nix-conf/pkgs/scripts/system-update.nix
+++ b/nix-conf/pkgs/scripts/system-update.nix
@@ -10,10 +10,19 @@
let
nixpkgsInput = "nixpkgs-${version}";
homeManagerInput = "home-manager-${version}";
+ check-versions = pkgs.callPackage ./check-versions.nix { };
in
pkgs.writeShellScriptBin "system-update" ''
set -euo pipefail
+ RUN_CHECK_VERSIONS=false
+ for arg in "$@"; do
+ case "$arg" in
+ -c|--check-versions) RUN_CHECK_VERSIONS=true ;;
+ *) echo "Usage: system-update [-c|--check-versions]" >&2; exit 1 ;;
+ esac
+ done
+
NIX_CONF="''${NH_FLAKE:-$HOME/dotfiles/nix-conf}"
FLAKE_LOCK="$NIX_CONF/flake.lock"
OS="${os}"
@@ -23,6 +32,8 @@ pkgs.writeShellScriptBin "system-update" ''
JQ=${lib.getExe pkgs.jq}
NH=${lib.getExe pkgs.nh}
NIX=${lib.getExe pkgs.nix}
+ CHECK_VERSIONS=${lib.getExe check-versions}
+ SHA256SUM=${lib.getExe' pkgs.coreutils "sha256sum"}
BACKUP_DIR="''${XDG_STATE_HOME:-$HOME/.local/state}/lock-backups/flake"
mkdir -p "$BACKUP_DIR"
@@ -62,6 +73,22 @@ pkgs.writeShellScriptBin "system-update" ''
HOME_NEEDS_UPDATE=true
fi
+ if [ "$RUN_CHECK_VERSIONS" = true ]; then
+ OVERRIDES_FILE="$NIX_CONF/overlays/_version-overrides.nix"
+ OVERRIDES_BEFORE=$($SHA256SUM "$OVERRIDES_FILE" 2>/dev/null || true)
+ $CHECK_VERSIONS "$NIX_CONF" -i
+ OVERRIDES_AFTER=$($SHA256SUM "$OVERRIDES_FILE" 2>/dev/null || true)
+ # A version-override change may not move any flake input, so force a
+ # rebuild when the overrides file was actually modified.
+ if [ "$OVERRIDES_BEFORE" != "$OVERRIDES_AFTER" ]; then
+ echo "Version overrides changed; rebuilding."
+ if [ -n "$OS" ]; then
+ OS_NEEDS_UPDATE=true
+ fi
+ HOME_NEEDS_UPDATE=true
+ fi
+ fi
+
case "$OS" in
darwin)
if [ "$OS_NEEDS_UPDATE" = true ]; then