From 73cdcbaaa878b3ff4bcee82c4e73f2dbb526dee4 Mon Sep 17 00:00:00 2001 From: BT Date: Tue, 10 Nov 2026 07:48:30 +0530 Subject: [PATCH] fix: messed up version numbers --- devenv.nix | 38 ++++++++++++++++++++------------------ flake.nix | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/devenv.nix b/devenv.nix index ede721e..2955b33 100644 --- a/devenv.nix +++ b/devenv.nix @@ -39,17 +39,17 @@ let bugPkg = tool "bug" "bug"; # The update check, said once per shell. It compares release numbers: the - # pinned devkit's own version (lib.version, known at evaluation) with the - # newest vX.Y.Z tag on the knot. Shell entry never waits on the network: it + # pinned devkit's release (its tag when the pinned rev is tagged, else its + # lib.version, known at evaluation) with the newest vX.Y.Z tag on the knot. Shell entry never waits on the network: it # reads the tags as last seen (~/.cache/devkit/releases, shared by every # project, one "\t" line per tag plus "\tmain"), and when # that is over a day old a detached job asks the knot again for the next # shell. Offline, it says nothing. A stale cache can only lack releases, so # it never claims an update the pin is already past. # - # Releases are made by bumping version first and tagging later, so a pin - # whose version equals the newest tag but whose rev isn't that tag is a - # pre-release of it, and is told the release is out. + # Releases are made by bumping version first and tagging later, so an + # untagged pin whose version equals the newest tag is a pre-release of it, + # and is told the release is out. locked = (inputs.devkit or { }).rev or ""; refresh = pkgs.writeShellScript "devkit-refresh-releases" '' cache=$1 url=$2 @@ -73,23 +73,25 @@ let if [ -z "$(${pkgs.findutils}/bin/find "$_devkit_cache" -mmin -1440 2>/dev/null)" ]; then ${pkgs.util-linux}/bin/setsid -f ${refresh} "$_devkit_cache" ${lib.escapeShellArg cfg.updateCheck.url} /dev/null 2>&1 fi - _devkit_have=${lib.escapeShellArg version} _devkit_latest="$(${pkgs.gawk}/bin/awk -F'\t' '$2 != "main" { print $2 }' "$_devkit_cache" 2>/dev/null | ${pkgs.coreutils}/bin/sort -V | ${pkgs.coreutils}/bin/tail -n1)" + # A tagged pin is that release, whatever its flake.nix says (a tag can + # land on a commit whose version wasn't bumped). + _devkit_released="$(${pkgs.gawk}/bin/awk -F'\t' -v s=${lib.escapeShellArg locked} '$1 == s && $2 != "main" { print $2 }' "$_devkit_cache" 2>/dev/null | ${pkgs.coreutils}/bin/sort -V | ${pkgs.coreutils}/bin/tail -n1)" _devkit_msg="" - if [ -n "$_devkit_latest" ]; then - _devkit_tag="$(${pkgs.gawk}/bin/awk -F'\t' -v v="$_devkit_latest" '$2 == v { print $1 }' "$_devkit_cache")" + if [ -z "$_devkit_latest" ]; then + : + elif [ -n "$_devkit_released" ]; then + [ "$_devkit_released" = "$_devkit_latest" ] \ + || _devkit_msg="you have v$_devkit_released, v$_devkit_latest is available" + else + # Untagged: a pre-release of its flake.nix version. + _devkit_have=${lib.escapeShellArg version} if [ "$_devkit_have" = "$_devkit_latest" ]; then - # Same number: the release itself, or one of its pre-releases. - [ "$_devkit_tag" = "${locked}" ] \ - || _devkit_msg="you have a v$_devkit_have pre-release (${builtins.substring 0 8 locked}), v$_devkit_latest is released" + _devkit_msg="you have a v$_devkit_have pre-release (${builtins.substring 0 8 locked}), v$_devkit_latest is released" elif [ "$(printf '%s\n%s\n' "$_devkit_have" "$_devkit_latest" | ${pkgs.coreutils}/bin/sort -V | ${pkgs.coreutils}/bin/tail -n1)" = "$_devkit_latest" ]; then - if ${pkgs.gawk}/bin/awk -F'\t' -v s=${lib.escapeShellArg locked} '$1 == s && $2 != "main" { f = 1 } END { exit !f }' "$_devkit_cache"; then - _devkit_msg="you have v$_devkit_have, v$_devkit_latest is available" - else - _devkit_msg="you have a v$_devkit_have pre-release (${builtins.substring 0 8 locked}), v$_devkit_latest is available" - fi + _devkit_msg="you have a v$_devkit_have pre-release (${builtins.substring 0 8 locked}), v$_devkit_latest is available" fi - # else the pin is ahead of every release (a pre-release of the next): quiet. + # else it is ahead of every release (a pre-release of the next): quiet. fi # Once per shell: nested shells inherit the export and stay quiet, and so # do the shells delegate starts for tasks and checks (it sets "nested"). @@ -99,7 +101,7 @@ let echo "devkit: $_devkit_msg: run \`devenv update devkit\` and commit devenv.lock" >&2 export DEVKIT_UPDATE_WARNED="$_devkit_latest-${locked}" fi - unset _devkit_cache _devkit_have _devkit_latest _devkit_tag _devkit_msg + unset _devkit_cache _devkit_have _devkit_latest _devkit_released _devkit_msg ''; # This devkit's release, from flake.nix (the one place to bump it). Projects # see it as $DEVKIT_VERSION (unset before v1.3.0). diff --git a/flake.nix b/flake.nix index 13d42f5..75cfec4 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,7 @@ let # devkit's release: bump with each tag (vX.Y.Z). devenv.nix reads it as # inputs.devkit.lib.version and exports it as $DEVKIT_VERSION. - version = "1.7.1"; + version = "1.7.3"; systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; forAll = f: builtins.listToAttrs (map (system: { name = system; value = f system; }) systems); in { -- knotmirror 0.0.1