ninja: refactor version,src

This patch fixes a problem with nix-prefetch (and thus a number of update
scripts) where it would throw the following error when run in nixpkgs:

```
error: attribute 'rev' missing
at pkgs/by-name/ni/ninja/package.nix:19:34:
   18|   pname = "ninja";
   19|   version = lib.removePrefix "v" finalAttrs.src.rev;
     |                                  ^
```

This seems to be caused by an oversight where nix-prefetch overrides
fetchFromGitHub in a weird way, where rev is not returned, but so far this
is the only package that is triggering this bug. The related issue in
nix-prefetch is still unhandled, hence this change.

See: msteen/nix-prefetch#54 #403032
This commit is contained in:
Tom van Dijk
2025-05-01 18:48:41 +02:00
parent 89159c150e
commit c9a8d756d5
+17 -18
View File
@@ -17,26 +17,25 @@
stdenv.mkDerivation (finalAttrs: {
pname = "ninja";
version = lib.removePrefix "v" finalAttrs.src.rev;
src =
version =
{
# TODO: Remove Ninja 1.11 as soon as possible.
"1.11" = fetchFromGitHub {
owner = "ninja-build";
repo = "ninja";
rev = "v1.11.1";
hash = "sha256-LvV/Fi2ARXBkfyA1paCRmLUwCh/rTyz+tGMg2/qEepI=";
};
latest = fetchFromGitHub {
owner = "ninja-build";
repo = "ninja";
rev = "v1.12.1";
hash = "sha256-RT5u+TDvWxG5EVQEYj931EZyrHUSAqK73OKDAascAwA=";
};
"1.11" = "1.11.1";
latest = "1.12.1";
}
.${ninjaRelease} or (throw "Unsupported Ninja release: ${ninjaRelease}");
.${ninjaRelease};
src = fetchFromGitHub {
owner = "ninja-build";
repo = "ninja";
rev = "v${finalAttrs.version}";
hash =
{
# TODO: Remove Ninja 1.11 as soon as possible.
"1.11" = "sha256-LvV/Fi2ARXBkfyA1paCRmLUwCh/rTyz+tGMg2/qEepI=";
latest = "sha256-RT5u+TDvWxG5EVQEYj931EZyrHUSAqK73OKDAascAwA=";
}
.${ninjaRelease} or (throw "Unsupported Ninja release: ${ninjaRelease}");
};
depsBuildBuild = [ buildPackages.stdenv.cc ];