diff options
| author | David Morgan <djm_uk@protonmail.com> | 2026-05-22 08:07:18 +0100 |
|---|---|---|
| committer | David Morgan <djm_uk@protonmail.com> | 2026-05-22 08:07:18 +0100 |
| commit | 1b8e0f4b90f0e5a8ad0f007cc4c89717e0e0e186 (patch) | |
| tree | 54751fa514549573a468c4d23d5d69660ad2aa3d | |
| parent | bbd18458c73b8647c10f4a0a139cb8a6324d37f4 (diff) | |
| download | dotfiles-1b8e0f4b90f0e5a8ad0f007cc4c89717e0e0e186.tar.gz | |
check-versions: remove overrides when nixpkgs catches up
| -rw-r--r-- | nix-conf/flake.lock | 12 | ||||
| -rw-r--r-- | nix-conf/overlays/_version-overrides.nix | 35 | ||||
| -rw-r--r-- | nix-conf/overlays/modifications.nix | 186 | ||||
| -rw-r--r-- | nix-conf/pkgs/scripts/check-versions.nix | 96 |
4 files changed, 218 insertions, 111 deletions
diff --git a/nix-conf/flake.lock b/nix-conf/flake.lock index 73ae99c..4d5a7c7 100644 --- a/nix-conf/flake.lock +++ b/nix-conf/flake.lock @@ -192,11 +192,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1779341808, - "narHash": "sha256-RC3GaOxJ/fQtXTw+km1fPAGso09+Jn/LCfiESZ/fxy0=", + "lastModified": 1779427831, + "narHash": "sha256-n+TRxgTBGwOSqmPGhh9gqtFd9oIHadiQI7KUhpKLd04=", "owner": "numtide", "repo": "llm-agents.nix", - "rev": "339239b8e071b0294cc5b49b555d724761a68bf0", + "rev": "20e430bd6bc68a3e76f16a31a19504971b1832bd", "type": "github" }, "original": { @@ -294,11 +294,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1778869304, - "narHash": "sha256-30sZNZoA1cqF5JNO9fVX+wgiQYjB7HJqqJ4ztCDeBZE=", + "lastModified": 1779351318, + "narHash": "sha256-f+JACbTqzZ+G92DSnXOUGRhGANb8Blh7CoeYOeBF8/U=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d233902339c02a9c334e7e593de68855ad26c4cb", + "rev": "4a29d733e8a7d5b824c3d8c958a946a9867b3eb2", "type": "github" }, "original": { diff --git a/nix-conf/overlays/_version-overrides.nix b/nix-conf/overlays/_version-overrides.nix index 933ca60..ad1c3c6 100644 --- a/nix-conf/overlays/_version-overrides.nix +++ b/nix-conf/overlays/_version-overrides.nix @@ -1,20 +1,29 @@ { - brave.version = "1.90.124"; - brave.hash = "sha256-u3KmZffPQpHzS9IxZ7UsL7D6ETGJxExil20vmD6flMo="; + brave = { + version = "1.90.124"; + hash = "sha256-u3KmZffPQpHzS9IxZ7UsL7D6ETGJxExil20vmD6flMo="; + }; - google-chrome.version = "148.0.7778.179"; - google-chrome.slug = "adxxii2zvsza6zjfnjbfh6fn4tqq"; - google-chrome.hash = "sha256-QBHyF222wnaEmI79CQFOXQl5WkRNwneCYd/JFNMEEWU="; + google-chrome = { + version = "148.0.7778.179"; + slug = "adxxii2zvsza6zjfnjbfh6fn4tqq"; + hash = "sha256-QBHyF222wnaEmI79CQFOXQl5WkRNwneCYd/JFNMEEWU="; + }; - firefox.version = "150.0.3"; - firefox.sha512 = "150mdz3q67n366679sr6qh0z83zf2xhdx3875wvx7hwzrizjjs6yg6573wm0v2833h5faxgj69arcl4r8qg5zykj1kyd3hg41hxlll4"; + firefox = { + version = "151.0.1"; + sha512 = "1vp5iqd8dfp6r3pqy031rzipxm2w412kjxnffm0hlja6ab3q3anix68d0kvq0jynhbj1g1a1nns9qqq1s5x32wkacqkff3bjnxs34l4"; + }; - orbstack.version = "2.1.3-20115"; - orbstack.hash = "sha256-9JTbgE/Ehu8viOq5A9GGpph8eG3jmGj/iDQWpeuacxc="; + orbstack = null; - slack.version = "4.50.121"; - slack.hash = "sha256-X2eGM50AQiKT8B2tefaNNcikACDcoEpfHo3YDgGnSWY="; + slack = { + version = "4.50.121"; + hash = "sha256-X2eGM50AQiKT8B2tefaNNcikACDcoEpfHo3YDgGnSWY="; + }; - zoom-us.version = "7.0.5.81138"; - zoom-us.hash = "sha256-uFnwBVZn5iUTIHNYG2WqiULA8siGWJaqY0BcRCoU6gg="; + zoom-us = { + version = "7.0.5.81138"; + hash = "sha256-uFnwBVZn5iUTIHNYG2WqiULA8siGWJaqY0BcRCoU6gg="; + }; } diff --git a/nix-conf/overlays/modifications.nix b/nix-conf/overlays/modifications.nix index c63fcd6..9641184 100644 --- a/nix-conf/overlays/modifications.nix +++ b/nix-conf/overlays/modifications.nix @@ -32,89 +32,103 @@ in ) ]; } -// prev.lib.optionalAttrs (prev.stdenv.isDarwin && prev.stdenv.isAarch64) { - brave = prev.brave.overrideAttrs ( - finalAttrs: _: { - inherit (v.brave) version; - src = prev.fetchurl { - url = "https://github.com/brave/brave-browser/releases/download/v${finalAttrs.version}/brave-v${finalAttrs.version}-darwin-arm64.zip"; - inherit (v.brave) hash; - }; - } - ); - google-chrome = prev.google-chrome.overrideAttrs ( - finalAttrs: _: { - inherit (v.google-chrome) version slug; - src = prev.fetchurl { - url = "http://dl.google.com/release2/chrome/${finalAttrs.slug}_${finalAttrs.version}/GoogleChrome-${finalAttrs.version}.dmg"; - inherit (v.google-chrome) hash; - }; - } - ); - orbstack = prev.orbstack.overrideAttrs ( - finalAttrs: _: { - inherit (v.orbstack) version; - src = prev.fetchurl { - url = "https://cdn-updates.orbstack.dev/arm64/OrbStack_v${ - prev.lib.replaceString "-" "_" finalAttrs.version - }_arm64.dmg"; - inherit (v.orbstack) hash; - }; - } - ); - slack = prev.slack.overrideAttrs ( - finalAttrs: _: { - inherit (v.slack) version; - src = prev.fetchurl { - url = "https://downloads.slack-edge.com/desktop-releases/mac/arm64/${finalAttrs.version}/Slack-${finalAttrs.version}-macOS.dmg"; - inherit (v.slack) hash; - }; - } - ); - zoom-us = prev.zoom-us.overrideAttrs ( - finalAttrs: _: { - inherit (v.zoom-us) version; - src = prev.fetchurl { - url = "https://zoom.us/client/${finalAttrs.version}/zoomusInstallerFull.pkg?archType=arm64"; - name = "zoomusInstallerFull.pkg"; - inherit (v.zoom-us) hash; - }; - } - ); -} -// prev.lib.optionalAttrs prev.stdenv.isDarwin { - elinks = prev.elinks.overrideAttrs (oldAttrs: { - postPatch = (oldAttrs.postPatch or "") + '' - substituteInPlace configure.ac \ - --replace-fail "AM_GNU_GETTEXT" "AM_GNU_GETTEXT([external])" \ - --replace-fail "AC_DEFINE([HAVE_ALLOCA])" "AC_DEFINE([HAVE_ALLOCA], [1], [Define if alloca is available.])" - substituteInPlace Makefile.config.in \ - --replace-fail "\$(PATHPREFIX)@MKINSTALLDIRS@" "mkdir -p" - ''; - }); - firefox-unwrapped = - import (prev.path + "/pkgs/applications/networking/browsers/firefox/packages/firefox.nix") - { - inherit (final) - stdenv - lib - callPackage - fetchurl - nixosTests - ; - buildMozillaMach = - args: - final.buildMozillaMach ( - args - // { - version = v.firefox.version; - packageVersion = v.firefox.version; - src = prev.fetchurl { - url = "mirror://mozilla/firefox/releases/${v.firefox.version}/source/firefox-${v.firefox.version}.source.tar.xz"; - inherit (v.firefox) sha512; - }; - } - ); - }; - firefox = final.wrapFirefox final.firefox-unwrapped { }; -} +// prev.lib.optionalAttrs (prev.stdenv.isDarwin && prev.stdenv.isAarch64) ( + prev.lib.optionalAttrs (v.brave != null) { + brave = prev.brave.overrideAttrs ( + finalAttrs: _: { + inherit (v.brave) version; + src = prev.fetchurl { + url = "https://github.com/brave/brave-browser/releases/download/v${finalAttrs.version}/brave-v${finalAttrs.version}-darwin-arm64.zip"; + inherit (v.brave) hash; + }; + } + ); + } + // prev.lib.optionalAttrs (v.google-chrome != null) { + google-chrome = prev.google-chrome.overrideAttrs ( + finalAttrs: _: { + inherit (v.google-chrome) version slug; + src = prev.fetchurl { + url = "http://dl.google.com/release2/chrome/${finalAttrs.slug}_${finalAttrs.version}/GoogleChrome-${finalAttrs.version}.dmg"; + inherit (v.google-chrome) hash; + }; + } + ); + } + // prev.lib.optionalAttrs (v.orbstack != null) { + orbstack = prev.orbstack.overrideAttrs ( + finalAttrs: _: { + inherit (v.orbstack) version; + src = prev.fetchurl { + url = "https://cdn-updates.orbstack.dev/arm64/OrbStack_v${ + prev.lib.replaceString "-" "_" finalAttrs.version + }_arm64.dmg"; + inherit (v.orbstack) hash; + }; + } + ); + } + // prev.lib.optionalAttrs (v.slack != null) { + slack = prev.slack.overrideAttrs ( + finalAttrs: _: { + inherit (v.slack) version; + src = prev.fetchurl { + url = "https://downloads.slack-edge.com/desktop-releases/mac/arm64/${finalAttrs.version}/Slack-${finalAttrs.version}-macOS.dmg"; + inherit (v.slack) hash; + }; + } + ); + } + // prev.lib.optionalAttrs (v.zoom-us != null) { + zoom-us = prev.zoom-us.overrideAttrs ( + finalAttrs: _: { + inherit (v.zoom-us) version; + src = prev.fetchurl { + url = "https://zoom.us/client/${finalAttrs.version}/zoomusInstallerFull.pkg?archType=arm64"; + name = "zoomusInstallerFull.pkg"; + inherit (v.zoom-us) hash; + }; + } + ); + } +) +// prev.lib.optionalAttrs prev.stdenv.isDarwin ( + { + elinks = prev.elinks.overrideAttrs (oldAttrs: { + postPatch = (oldAttrs.postPatch or "") + '' + substituteInPlace configure.ac \ + --replace-fail "AM_GNU_GETTEXT" "AM_GNU_GETTEXT([external])" \ + --replace-fail "AC_DEFINE([HAVE_ALLOCA])" "AC_DEFINE([HAVE_ALLOCA], [1], [Define if alloca is available.])" + substituteInPlace Makefile.config.in \ + --replace-fail "\$(PATHPREFIX)@MKINSTALLDIRS@" "mkdir -p" + ''; + }); + } + // prev.lib.optionalAttrs (v.firefox != null) { + firefox-unwrapped = + import (prev.path + "/pkgs/applications/networking/browsers/firefox/packages/firefox.nix") + { + inherit (final) + stdenv + lib + callPackage + fetchurl + nixosTests + ; + buildMozillaMach = + args: + final.buildMozillaMach ( + args + // { + version = v.firefox.version; + packageVersion = v.firefox.version; + src = prev.fetchurl { + url = "mirror://mozilla/firefox/releases/${v.firefox.version}/source/firefox-${v.firefox.version}.source.tar.xz"; + inherit (v.firefox) sha512; + }; + } + ); + }; + firefox = final.wrapFirefox final.firefox-unwrapped { }; + } +) diff --git a/nix-conf/pkgs/scripts/check-versions.nix b/nix-conf/pkgs/scripts/check-versions.nix index e84cd4e..6047e33 100644 --- a/nix-conf/pkgs/scripts/check-versions.nix +++ b/nix-conf/pkgs/scripts/check-versions.nix @@ -68,6 +68,41 @@ pkgs.writeShellScriptBin "check-versions" '' [[ "$1" == "$2" ]] || [[ "$(printf '%s\n%s\n' "$1" "$2" | ${sort} -V | ${tail} -1)" == "$1" ]] } + # Update a field within a nested-style entry, e.g. update_field "brave.version" "1.0" + # Will be a no-op if the package is currently set to null. + update_field() { + local path="$1" value="$2" + local pkg="''${path%%.*}" key="''${path#*.}" + ${sed} -i "/^ $pkg = {/,/^ };/ s|^\( $key = \)\"[^\"]*\";|\1\"$value\";|" "$overrides_file" + } + + # Replace a non-null entry block with `pkg = null;` + null_entry() { + local pkg="$1" + ${sed} -i "/^ $pkg = {/,/^ };/c\\ +\ $pkg = null;" "$overrides_file" + } + + # Read the override version directly from the file (returns "null", "missing", or the version) + override_version() { + local pkg="$1" + ${nix} eval --raw --impure --expr " + let v = import $overrides_file; + in if !(v ? \"$pkg\") then \"missing\" + else if v.\"$pkg\" == null then \"null\" + else v.\"$pkg\".version + " 2>/dev/null || echo "missing" + } + + # Returns "true" if the override has preserve = true (won't be auto-nulled) + override_preserved() { + local pkg="$1" + ${nix} eval --impure --expr " + let v = import $overrides_file; + in if v ? \"$pkg\" && v.\"$pkg\" != null then (v.\"$pkg\".preserve or false) else false + " 2>/dev/null + } + # Returns 0 (true) if a package should be updated, considering mode and downgrade policy should_update() { local local_v="$1" latest="$2" @@ -165,7 +200,44 @@ pkgs.writeShellScriptBin "check-versions" '' should_update "$local_slack" "$latest_slack" && outdated+=(slack) should_update "$local_zoom" "$latest_zoom" && outdated+=(zoom) - if [[ ''${#outdated[@]} -eq 0 ]]; then + # Compute auto-null candidates: active overrides where nixpkgs has caught up. + # Skipped in check mode (would need to read the file) and force mode (force is + # explicitly about refreshing, not deactivating). + declare -a to_null=() + should_null() { + local short="$1" override_key="$2" + local nixpkgs_var="nixpkgs_$short" + local latest_var="latest_$short" + local nixpkgs_v="''${!nixpkgs_var}" + local latest_v="''${!latest_var}" + [[ "$nixpkgs_v" == "error" || "$latest_v" == "error" ]] && return 1 + local ov + ov=$(override_version "$override_key") + case "$ov" in + null|missing|error) return 1 ;; + esac + [[ "$(override_preserved "$override_key")" == "true" ]] && return 1 + # Null only when nixpkgs has caught up to both our override and the latest version. + version_ge "$nixpkgs_v" "$ov" && version_ge "$nixpkgs_v" "$latest_v" + } + if [[ "$mode" != "check" && "$mode" != "force" ]]; then + should_null brave brave && to_null+=(brave) + should_null chrome google-chrome && to_null+=(chrome) + should_null firefox firefox && to_null+=(firefox) + should_null orbstack orbstack && to_null+=(orbstack) + should_null slack slack && to_null+=(slack) + should_null zoom zoom-us && to_null+=(zoom) + # If a package is being nulled, don't also try to update it + declare -a filtered_outdated=() + for pkg in "''${outdated[@]}"; do + skip=false + for n in "''${to_null[@]}"; do [[ "$n" == "$pkg" ]] && skip=true && break; done + $skip || filtered_outdated+=("$pkg") + done + outdated=("''${filtered_outdated[@]}") + fi + + if [[ ''${#outdated[@]} -eq 0 && ''${#to_null[@]} -eq 0 ]]; then echo "" echo "''${green}All packages up to date.''${reset}" exit 0 @@ -245,6 +317,9 @@ pkgs.writeShellScriptBin "check-versions" '' change_summary "$pkg" printf '\n' done + for pkg in "''${to_null[@]}"; do + printf " %s: ''${dim}null (nixpkgs caught up)''${reset}\n" "$pkg" + done echo "" printf "Proceed? [y/N] " read -r answer @@ -259,11 +334,6 @@ pkgs.writeShellScriptBin "check-versions" '' exit 1 fi - update_field() { - local key="$1" value="$2" - ${sed} -i "s|^\( $key = \)\".*\";|\1\"$value\";|" "$overrides_file" - } - for pkg in "''${outdated[@]}"; do case "$pkg" in brave) @@ -322,6 +392,20 @@ pkgs.writeShellScriptBin "check-versions" '' esac done + for pkg in "''${to_null[@]}"; do + case "$pkg" in + brave) key=brave ;; + chrome) key=google-chrome ;; + firefox) key=firefox ;; + orbstack) key=orbstack ;; + slack) key=slack ;; + zoom) key=zoom-us ;; + esac + echo "" + echo "''${bold}$pkg''${reset}: nulling override (nixpkgs caught up)" + null_entry "$key" + done + echo "" echo "''${green}Updated $overrides_file''${reset}" '' |