gnat-bootstrap: parameterize better

This commit makes `url` dependent on the gnat version, and allows
for `alireRevision` to be empty (in which case no hyphen is added
after ${gccVersion} in `version`).

This should cause no changes to eval on `gnat11` or `gnat12`.

This is submitted in order to reduce the size of #225191
This commit is contained in:
Adam Joseph 2023-04-14 10:57:30 -07:00
parent 9e3b2a5822
commit 605ccc8296

View File

@ -5,17 +5,22 @@
let let
throwUnsupportedSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}"; throwUnsupportedSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
in
versionMap = rec { stdenv.mkDerivation(finalAttrs:
let versionMap =
let url = "https://github.com/alire-project/GNAT-FSF-builds/releases/download/gnat-${finalAttrs.version}/gnat-${stdenv.hostPlatform.system}-${finalAttrs.version}.tar.gz";
in {
"11" = { "11" = {
gccVersion = "11.2.0"; gccVersion = "11.2.0";
alireRevision = "4"; alireRevision = "4";
} // { } // {
x86_64-darwin = { x86_64-darwin = {
inherit url;
hash = "sha256-FmBgD20PPQlX/ddhJliCTb/PRmKxe9z7TFPa2/SK4GY="; hash = "sha256-FmBgD20PPQlX/ddhJliCTb/PRmKxe9z7TFPa2/SK4GY=";
upstreamTriplet = "x86_64-apple-darwin19.6.0"; upstreamTriplet = "x86_64-apple-darwin19.6.0";
}; };
x86_64-linux = { x86_64-linux = {
inherit url;
hash = "sha256-8fMBJp6igH+Md5jE4LMubDmC4GLt4A+bZG/Xcz2LAJQ="; hash = "sha256-8fMBJp6igH+Md5jE4LMubDmC4GLt4A+bZG/Xcz2LAJQ=";
upstreamTriplet = "x86_64-pc-linux-gnu"; upstreamTriplet = "x86_64-pc-linux-gnu";
}; };
@ -25,27 +30,26 @@ let
alireRevision = "2"; alireRevision = "2";
} // { } // {
x86_64-darwin = { x86_64-darwin = {
inherit url;
hash = "sha256-zrcVFvFZMlGUtkG0p1wST6kGInRI64Icdsvkcf25yVs="; hash = "sha256-zrcVFvFZMlGUtkG0p1wST6kGInRI64Icdsvkcf25yVs=";
upstreamTriplet = "x86_64-apple-darwin19.6.0"; upstreamTriplet = "x86_64-apple-darwin19.6.0";
}; };
x86_64-linux = { x86_64-linux = {
inherit url;
hash = "sha256-EPDPOOjWJnJsUM7GGxj20/PXumjfLoMIEFX1EDtvWVY="; hash = "sha256-EPDPOOjWJnJsUM7GGxj20/PXumjfLoMIEFX1EDtvWVY=";
upstreamTriplet = "x86_64-pc-linux-gnu"; upstreamTriplet = "x86_64-pc-linux-gnu";
}; };
}.${stdenv.hostPlatform.system} or throwUnsupportedSystem; }.${stdenv.hostPlatform.system} or throwUnsupportedSystem;
}; };
inherit (versionMap.${majorVersion}) gccVersion alireRevision upstreamTriplet;
in with versionMap.${majorVersion}; in {
stdenv.mkDerivation rec {
pname = "gnat-bootstrap"; pname = "gnat-bootstrap";
inherit gccVersion alireRevision; inherit (versionMap.${majorVersion}) gccVersion alireRevision;
version = "${gccVersion}-${alireRevision}"; version = "${gccVersion}${lib.optionalString (alireRevision!="") "-"}${alireRevision}";
src = fetchzip { src = fetchzip {
url = "https://github.com/alire-project/GNAT-FSF-builds/releases/download/gnat-${version}/gnat-${stdenv.hostPlatform.system}-${version}.tar.gz"; inherit (versionMap.${majorVersion}) url hash;
inherit hash;
}; };
nativeBuildInputs = [ nativeBuildInputs = [
@ -141,4 +145,4 @@ stdenv.mkDerivation rec {
maintainers = with maintainers; [ ethindp ]; maintainers = with maintainers; [ ethindp ];
platforms = [ "x86_64-linux" "x86_64-darwin" ]; platforms = [ "x86_64-linux" "x86_64-darwin" ];
}; };
} })