Nix-update-script version regex mismatch

I can’t seem to get the default update script to detect URLs properly (relevant PR). I’ve set the following:

  passthru.updateScript = nix-update-script {
    extraArgs = [ "--version-regex=^v(\d+(\.\d+)*)$" ];
  };

That is, the tag should match a “v” followed by at least one number, all numbers separated by a dot. Despite such tags existing, the script says none of them match:

❯ yes '' | nix-shell maintainers/scripts/update.nix --argstr package daggerfall-unity

Going to be running update for following packages:
 - daggerfall-unity-1.1.1

Press Enter key to continue...
Running update for:
 - daggerfall-unity-1.1.1: UPDATING ...
 - daggerfall-unity-1.1.1: ERROR

--- SHOWING ERROR LOG FOR daggerfall-unity-1.1.1 ----------------------

Traceback (most recent call last):
  File "/nix/store/min41kwjprwl6cqrqjami1m3ajvg7ipb-nix-update-1.5.2/bin/.nix-update-wrapped", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/nix/store/min41kwjprwl6cqrqjami1m3ajvg7ipb-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/__init__.py", line 311, in main
    package = update(options)
              ^^^^^^^^^^^^^^^
  File "/nix/store/min41kwjprwl6cqrqjami1m3ajvg7ipb-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/update.py", line 449, in update
    update_hash = update_version(
                  ^^^^^^^^^^^^^^^
  File "/nix/store/min41kwjprwl6cqrqjami1m3ajvg7ipb-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/update.py", line 383, in update_version
    new_version = fetch_latest_version(
                  ^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/min41kwjprwl6cqrqjami1m3ajvg7ipb-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/version/__init__.py", line 128, in fetch_latest_version
    raise VersionError(
nix_update.errors.VersionError: Not version matched the regex. The following versions were found:
v1.1.1-pac
v1.1.1
v1.1.1-test
v1.1.0-rc
v1.0.0
v0.16.3-rc
v0.16.2-rc
v0.16.1-rc
v0.16.0-rc
v0.15.4a-beta


--- SHOWING ERROR LOG FOR daggerfall-unity-1.1.1 ----------------------
The update script for daggerfall-unity-1.1.1 failed with exit code 1

That is how escaping in double quoted strings works:

nix-repl>  "--version-regex=^v(\d+(\.\d+)*)$"
"--version-regex=^v(d+(.d+)*)$"

If I use "--version-regex=^v(\\d+(\\.\\d+)*)$" instead, the update script crashes and deletes the contents of my package.nix:

❯ yes '' | nix-shell maintainers/scripts/update.nix --argstr package daggerfall-unity
this derivation will be built:
  /nix/store/r3zmfppk11zd9jrjic9r5vzfr1cx4m1z-packages.json.drv
building '/nix/store/r3zmfppk11zd9jrjic9r5vzfr1cx4m1z-packages.json.drv'...

Going to be running update for following packages:
 - daggerfall-unity-1.1.1

Press Enter key to continue...
Running update for:
 - daggerfall-unity-1.1.1: UPDATING ...
 - daggerfall-unity-1.1.1: ERROR

--- SHOWING ERROR LOG FOR daggerfall-unity-1.1.1 ----------------------

Traceback (most recent call last):
  File "/nix/store/min41kwjprwl6cqrqjami1m3ajvg7ipb-nix-update-1.5.2/bin/.nix-update-wrapped", line 9, in <module>
    sys.exit(main())
             ^^^^^^
  File "/nix/store/min41kwjprwl6cqrqjami1m3ajvg7ipb-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/__init__.py", line 311, in main
    package = update(options)
              ^^^^^^^^^^^^^^^
  File "/nix/store/min41kwjprwl6cqrqjami1m3ajvg7ipb-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/update.py", line 449, in update
    update_hash = update_version(
                  ^^^^^^^^^^^^^^^
  File "/nix/store/min41kwjprwl6cqrqjami1m3ajvg7ipb-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/update.py", line 422, in update_version
    return replace_version(package)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/min41kwjprwl6cqrqjami1m3ajvg7ipb-nix-update-1.5.2/lib/python3.12/site-packages/nix_update/update.py", line 41, in replace_version
    line = line.replace(package.rev, package.new_version.rev)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: replace() argument 1 must be str, not None


--- SHOWING ERROR LOG FOR daggerfall-unity-1.1.1 ----------------------
The update script for daggerfall-unity-1.1.1 failed with exit code 1

Sounds like a bug in nix-updatenix-update-script just runs nix-update '--version-regex=^v(\d+(\.\d+)*)$' daggerfall-unity and I can reproduce it by running the command manually.

1 Like

D’oh! I already reported it.