From fa5712c0b77803bbebf8b5652c86c5eb1b2b002c Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Mon, 28 Mar 2022 08:06:08 +0200 Subject: [PATCH 1/8] graalvmXX-ce: new update script --- .../graalvm/community-edition/default.nix | 36 ++++- .../graalvm11-ce-sources.json | 64 +++++++++ .../graalvm17-ce-sources.json | 64 +++++++++ .../graalvm/community-edition/mkGraal.nix | 53 ++++--- .../graalvm/community-edition/update.nix | 129 ++++++++++++++++++ 5 files changed, 323 insertions(+), 23 deletions(-) create mode 100644 pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json create mode 100644 pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json create mode 100644 pkgs/development/compilers/graalvm/community-edition/update.nix diff --git a/pkgs/development/compilers/graalvm/community-edition/default.nix b/pkgs/development/compilers/graalvm/community-edition/default.nix index f53e9a03896..fa1d074866c 100644 --- a/pkgs/development/compilers/graalvm/community-edition/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/default.nix @@ -4,14 +4,36 @@ let mkGraal = opts: callPackage (import ./mkGraal.nix opts) { inherit Foundation; }; + + commonProducts = [ + "graalvm-ce" + "native-image-installable-svm" + "ruby-installable-svm" + "wasm-installable-svm" + ]; + in { inherit mkGraal; graalvm11-ce = mkGraal rec { + config = { + x86_64-darwin = { + arch = "darwin-amd64"; + products = commonProducts ++ [ "python-installable-svm" ]; + }; + x86_64-linux = { + arch = "linux-amd64"; + products = commonProducts ++ [ "python-installable-svm" ]; + }; + aarch64-linux = { + arch = "linux-aarch64"; + products = commonProducts; + }; + }; version = "22.0.0.2"; javaVersion = "11"; - platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; + platforms = builtins.attrNames config; }; # TODO: fix aarch64-linux, failing during Native Image compilation @@ -20,8 +42,18 @@ in # directory"/tmp/SVM-4194439592488143713"): error=0, Failed to exec spawn # helper: pid: 19865, exit value: 1" graalvm17-ce = mkGraal rec { + config = { + x86_64-darwin = { + arch = "darwin-amd64"; + products = commonProducts ++ [ "python-installable-svm" ]; + }; + x86_64-linux = { + arch = "linux-amd64"; + products = commonProducts ++ [ "python-installable-svm" ]; + }; + }; version = "22.0.0.2"; javaVersion = "17"; - platforms = [ "x86_64-linux" "x86_64-darwin" ]; + platforms = builtins.attrNames config; }; } diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json new file mode 100644 index 00000000000..deb4c59a1b2 --- /dev/null +++ b/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json @@ -0,0 +1,64 @@ +{ + "darwin-amd64": { + "graalvm-ce_java11_22.0.0.2": { + "sha256": "8280159b8a66c51a839c8079d885928a7f759d5da0632f3af7300df2b63a6323", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-darwin-amd64-22.0.0.2.tar.gz" + }, + "native-image-installable-svm_java11_22.0.0.2": { + "sha256": "03c27de6cce61ee8073e89252212457f3fbac2c0bc9bfa4acbff12176476c176", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java11-darwin-amd64-22.0.0.2.jar" + }, + "python-installable-svm_java11_22.0.0.2": { + "sha256": "67ee2f1cc10b0189e359344c31b22f423e636ff4ec2dd7d9437c3eb0ef54e601", + "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java11-darwin-amd64-22.0.0.2.jar" + }, + "ruby-installable-svm_java11_22.0.0.2": { + "sha256": "a25c0099a21ca1ca9904dd3acdeef509f67a13b96c6135b6de199e9805330df9", + "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java11-darwin-amd64-22.0.0.2.jar" + }, + "wasm-installable-svm_java11_22.0.0.2": { + "sha256": "d74c210a8a87b8eb0c4d18a65fde6f2c03ebc94d9bf7ed87bbb9cacc460006d7", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java11-darwin-amd64-22.0.0.2.jar" + } + }, + "linux-aarch64": { + "graalvm-ce_java11_22.0.0.2": { + "sha256": "1cc0263d95f642dada4e290dca7f49c0456cefa7b690b67e3e5c159b537b2c58", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-linux-aarch64-22.0.0.2.tar.gz" + }, + "native-image-installable-svm_java11_22.0.0.2": { + "sha256": "51d41e890a5aabf8e7b9d4f4e0f88206ee70a261f7dbb0315d51770ab8f3009e", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java11-linux-aarch64-22.0.0.2.jar" + }, + "ruby-installable-svm_java11_22.0.0.2": { + "sha256": "e0fb582a9c6b4167e7dc267c58ca1968bd1c471b3bc5c56061b436f175486d80", + "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java11-linux-aarch64-22.0.0.2.jar" + }, + "wasm-installable-svm_java11_22.0.0.2": { + "sha256": "a48470ae391c75cb2805b7fe27cde2c925c0466fdbc0623dfbb67c54f19dbf8c", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java11-linux-aarch64-22.0.0.2.jar" + } + }, + "linux-amd64": { + "graalvm-ce_java11_22.0.0.2": { + "sha256": "bc86083bb7e2778c7e4fe4f55d74790e42255b96f7806a7fefa51d06f3bc7103", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz" + }, + "native-image-installable-svm_java11_22.0.0.2": { + "sha256": "8504a3441f5b28b8fd625f676674a9216f082ae63a4e30d43930c80f9672e71d", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java11-linux-amd64-22.0.0.2.jar" + }, + "python-installable-svm_java11_22.0.0.2": { + "sha256": "2f01d1bbc2ed2c507952d8ceaab1cb2176fc67e2d8c4b3bf5864e8d930c60c55", + "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java11-linux-amd64-22.0.0.2.jar" + }, + "ruby-installable-svm_java11_22.0.0.2": { + "sha256": "e90f7ebc13b6c1f8e3f98881bb4fe2336870744174b2b6d41dc672d15f0b9a40", + "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java11-linux-amd64-22.0.0.2.jar" + }, + "wasm-installable-svm_java11_22.0.0.2": { + "sha256": "c0fdfc40374b70f6f1597dd21660535c813dc5c3948c8a6ea9559a20f4d3fb5e", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java11-linux-amd64-22.0.0.2.jar" + } + } +} diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json new file mode 100644 index 00000000000..8712d25c9e3 --- /dev/null +++ b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json @@ -0,0 +1,64 @@ +{ + "darwin-amd64": { + "graalvm-ce_java17_22.0.0.2": { + "sha256": "d54af9d1f4d0d351827395a714ed84d2489b023b74a9c13a431cc9d31d1e8f9a", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz" + }, + "native-image-installable-svm_java17_22.0.0.2": { + "sha256": "007fa742cd139d447f83d776b6d78e717c9df11d56a61061a5937547c20028b7", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java17-darwin-amd64-22.0.0.2.jar" + }, + "python-installable-svm_java17_22.0.0.2": { + "sha256": "af887b0304d5ec98fab1be2cd1fca2aa3b10e84e823142a7f274560b1e0ea7c1", + "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java17-darwin-amd64-22.0.0.2.jar" + }, + "ruby-installable-svm_java17_22.0.0.2": { + "sha256": "fc5eb6f833136ae3fda61f46fe0af66a8454ca2f803ca35eaff7336521cb468d", + "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java17-darwin-amd64-22.0.0.2.jar" + }, + "wasm-installable-svm_java17_22.0.0.2": { + "sha256": "b76e6d872ce07ca9facd5b997dbb6e557ba72aa369ddd5f1664431bd11b98796", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java17-darwin-amd64-22.0.0.2.jar" + } + }, + "linux-aarch64": { + "graalvm-ce_java17_22.0.0.2": { + "sha256": "c7d78387d2a144944f26773697c1b61d3478a081a1c5e7fc20f47f1f5f3c82c7", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java17-linux-aarch64-22.0.0.2.tar.gz" + }, + "native-image-installable-svm_java17_22.0.0.2": { + "sha256": "798947d0a93988929d2b8e3555f7c65225e789124cd99fbc0c3aae5f350175db", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java17-linux-aarch64-22.0.0.2.jar" + }, + "ruby-installable-svm_java17_22.0.0.2": { + "sha256": "38cd733334efdecb040087341bccf0aed8031d70eccd857695eaee6b274a5a6d", + "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java17-linux-aarch64-22.0.0.2.jar" + }, + "wasm-installable-svm_java17_22.0.0.2": { + "sha256": "5a4d85324b0565c647b0a31f2a12c9192c9bdc49fca3fe57fdb95370e01c325e", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java17-linux-aarch64-22.0.0.2.jar" + } + }, + "linux-amd64": { + "graalvm-ce_java17_22.0.0.2": { + "sha256": "4f743e0ed3d974b7d619ca2ed6014554e8c12e5ebbb38b9bc9e820b182169bd4", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java17-linux-amd64-22.0.0.2.tar.gz" + }, + "native-image-installable-svm_java17_22.0.0.2": { + "sha256": "8c25f650d58c2649c97061cb806dfaec9e685d5d2b80afc7cf72fe61d6891831", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java17-linux-amd64-22.0.0.2.jar" + }, + "python-installable-svm_java17_22.0.0.2": { + "sha256": "b3b78a15bd29b4eaaf0f2607e21181ca2a5b41b38ba43a3ff2656c2f6effda8a", + "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java17-linux-amd64-22.0.0.2.jar" + }, + "ruby-installable-svm_java17_22.0.0.2": { + "sha256": "d86c9ad50cbed980fa69d69b2eccd47d31880d8c55553483f59ce9eda15628bd", + "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java17-linux-amd64-22.0.0.2.jar" + }, + "wasm-installable-svm_java17_22.0.0.2": { + "sha256": "7f7e51e4a24384b3dd960c12ab9b05b1fea58a0457d6b80e3797228fab93c0bd", + "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java17-linux-amd64-22.0.0.2.jar" + } + } +} diff --git a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix index ee016e71d31..3c45c9c8a7b 100644 --- a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix +++ b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix @@ -1,7 +1,7 @@ { version , javaVersion , platforms -, hashes ? import ./hashes.nix +, config , useMusl ? false }: @@ -33,16 +33,19 @@ , cairo , glib , gtk3 +, writeScript +, jq +, runtimeShell +, callPackage }: assert useMusl -> stdenv.isLinux; let - platform = { - aarch64-linux = "linux-aarch64"; - x86_64-linux = "linux-amd64"; - x86_64-darwin = "darwin-amd64"; - }.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}"); + platform = config.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + name = "graalvm${javaVersion}-ce"; + sourcesFilename = "${name}-sources.json"; + sources = builtins.fromJSON (builtins.readFile (./. + "/${sourcesFilename}")); runtimeLibraryPath = lib.makeLibraryPath ([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]); @@ -56,21 +59,20 @@ let (writeShellScriptBin "${stdenv.system}-musl-gcc" ''${lib.getDev musl}/bin/musl-gcc "$@"'') ]); - javaVersionPlatform = "${javaVersion}-${platform}"; + javaVersionPlatform = "${javaVersion}-${platform.arch}"; graalvmXXX-ce = stdenv.mkDerivation rec { - inherit version; - name = "graalvm${javaVersion}-ce"; - srcs = - let - # Some platforms doesn't have all GraalVM features - # e.g.: GraalPython on aarch64-linux - # When the platform doesn't have a feature, sha256 is null on hashes.nix - # To update hashes.nix file, run `./update.sh ` - maybeFetchUrl = url: if url.sha256 != null then (fetchurl url) else null; + inherit version name; + srcs = map fetchurl (builtins.attrValues sources.${platform.arch}); + /*let + # Some platforms doesn't have all GraalVM features + # e.g.: GraalPython on aarch64-linux + # When the platform doesn't have a feature, sha256 is null on hashes.nix + # To update hashes.nix file, run `./update.sh ` + maybeFetchUrl = url: if url.sha256 != null then (fetchurl url) else null; in (lib.remove null - (map maybeFetchUrl (hashes { inherit javaVersionPlatform; }))); + (map maybeFetchUrl (hashes { inherit javaVersionPlatform; })));*/ buildInputs = lib.optionals stdenv.isLinux [ alsa-lib # libasound.so wanted by lib/libjsound.so @@ -86,7 +88,7 @@ let zlib ]; - nativeBuildInputs = [ unzip perl autoPatchelfHook makeWrapper ]; + nativeBuildInputs = [ unzip perl makeWrapper ] ++ lib.optional stdenv.isLinux [ autoPatchelfHook ]; unpackPhase = '' unpack_jar() { @@ -149,7 +151,7 @@ let else "for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do" } - ln -s $f ${basepath}/${platform}/$(basename $f) + ln -s $f ${basepath}/${platform.arch}/$(basename $f) done ''; copyClibrariesToLib = '' @@ -185,6 +187,7 @@ let ''; "11-darwin-amd64" = ""; "17-darwin-amd64" = ""; + "17-darwin-aarch64" = ""; }.${javaVersionPlatform} + '' # ensure that $lib/lib exists to avoid breaking builds mkdir -p $lib/lib @@ -281,7 +284,7 @@ let } ${ - lib.optionalString (platform != "linux-aarch64") '' + lib.optionalString (platform.arch != "linux-aarch64" && platform.arch != "darwin-aarch64") '' echo "Testing GraalPython" $out/bin/graalpython -c 'print(1 + 1)' echo '1 + 1' | $out/bin/graalpython @@ -289,10 +292,14 @@ let } echo "Testing TruffleRuby" + ${ + lib.optionalString (platform != "darwin-aarch64") '' # Hide warnings about wrong locale export LANG=C export LC_ALL=C $out/bin/ruby -e 'puts(1 + 1)' + '' + } ${# FIXME: irb is broken in all platforms # TODO: `irb` on MacOS gives an error saying "Could not find OpenSSL # headers, install via Homebrew or MacPorts or set OPENSSL_PREFIX", even @@ -311,7 +318,11 @@ let passthru = { home = graalvmXXX-ce; - updateScript = ./update.sh; + updateScript = import ./update.nix { + inherit lib writeScript jq runtimeShell sourcesFilename config; + graalVersion = version; + javaVersion = "java${javaVersion}"; + }; }; meta = with lib; { diff --git a/pkgs/development/compilers/graalvm/community-edition/update.nix b/pkgs/development/compilers/graalvm/community-edition/update.nix new file mode 100644 index 00000000000..2be8fff134f --- /dev/null +++ b/pkgs/development/compilers/graalvm/community-edition/update.nix @@ -0,0 +1,129 @@ +{ + javaVersion, + graalVersion, + config, + sourcesFilename, + lib, + writeScript, + jq, + runtimeShell +}: + +let + # getArchString :: String -> String + getArchString = nixArchString: + { + "aarch64-linux" = "linux-aarch64"; + "x86_64-linux" = "linux-amd64"; + "x86_64-darwin" = "darwin-amd64"; + }.${nixArchString}; + + + # getProductSuffix :: String -> String + getProductSuffix = productName: + let suffixes = { + "graalvm-ce" = ".tar.gz"; + "native-image-installable-svm" = ".jar"; + "ruby-installable-svm" = ".jar"; + "wasm-installable-svm" = ".jar"; + "python-installable-svm" = ".jar"; + }; + in + suffixes.${productName}; + + # getProductSuffix :: String -> String + getProductBaseUrl = productName: + let baseUrls = { + "graalvm-ce" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; + "native-image-installable-svm" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; + "ruby-installable-svm" = "https://github.com/oracle/truffleruby/releases/download"; + "wasm-installable-svm" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; + "python-installable-svm" = "https://github.com/graalvm/graalpython/releases/download"; + }; + in + baseUrls.${productName}; + + # generateUrl :: AttrSet -> String + generateUrl = { arch, graalVersion, product, javaVersion }: + + let baseUrl = getProductBaseUrl product; + in + "${baseUrl}/vm-${graalVersion}/${product}-${javaVersion}-${arch}-${graalVersion}${getProductSuffix product}"; + + # downloadSha256 :: AttrSet -> String + downloadSha256 = args@{ arch, graalVersion, product, javaVersion }: + let url = generateUrl args + ".sha256"; + in + builtins.readFile (builtins.fetchurl url); + + # cartesianZipListsWith :: (a -> b -> c) -> [a] -> [b] -> [c] + cartesianZipListsWith = f: fst: snd: + let cartesianProduct = lib.cartesianProductOfSets { a = fst; b = snd; }; + fst' = builtins.catAttrs "a" cartesianProduct; + snd' = builtins.catAttrs "b" cartesianProduct; + in + lib.zipListsWith f fst' snd'; + + # zipListsToAttrs :: [a] -> [b] -> AttrSet + zipListsToAttrs = names: values: + lib.listToAttrs ( + lib.zipListsWith (name: value: { inherit name value; }) names values + ); + + # genProductJavaVersionGraalVersionAttrSet :: String -> AttrSet + genProductJavaVersionGraalVersionAttrSet = product_javaVersion_graalVersion: + let attrNames = [ "product" "javaVersion" "graalVersion" ]; + attrValues = lib.splitString "_" product_javaVersion_graalVersion; + in zipListsToAttrs attrNames attrValues; + + # genUrlAndSha256 :: String -> String -> AttrSet + genUrlAndSha256 = arch: product_javaVersion_graalVersion: + let + productJavaVersionGraalVersion = + (genProductJavaVersionGraalVersionAttrSet product_javaVersion_graalVersion) + // { inherit arch; }; + url = generateUrl productJavaVersionGraalVersion; + sha256 = downloadSha256 productJavaVersionGraalVersion; + in + { + ${arch} = { + ${product_javaVersion_graalVersion} = { + inherit sha256 url; + }; + }; + }; + + # genArchProductVersionPairs :: String -> AttrSet -> [AttrSet] + genArchProductVersionList = javaGraalVersion: archProducts: + let + arch = archProducts.arch; + products = archProducts.products; + productJavaGraalVersionList = + cartesianZipListsWith (a: b: a + "_" + b) products [ javaGraalVersion ]; + in + cartesianZipListsWith (genUrlAndSha256) [ arch ] productJavaGraalVersionList; + + + # genSources :: String -> String -> AttrSet -> Path String + genSources = graalVersion: javaVersion: config: + let + javaGraalVersion = javaVersion + "_" + graalVersion; # java17_20.2.0.2 + archProducts = builtins.attrValues config; + sourcesList = builtins.concatMap (genArchProductVersionList javaGraalVersion) archProducts; + sourcesAttr = builtins.foldl' (lib.recursiveUpdate) {} sourcesList; + in + builtins.toFile "sources.json" (builtins.toJSON sourcesAttr); + + sourcesJson = genSources graalVersion javaVersion config; + +in + writeScript "update-graal.sh" '' + #!${runtimeShell} + set -o errexit + set -o nounset + set -o pipefail + + export PATH="${lib.makeBinPath [ jq ]}:$PATH" + + jq . ${sourcesJson} > ${lib.strings.escapeShellArg ./.}/${sourcesFilename} + '' From c6203291c8226d2e52b2a64074f4a626475d07f3 Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Tue, 29 Mar 2022 12:36:39 +0200 Subject: [PATCH 2/8] graalvm17-ce-dev: init with aarch64-darwin --- .../graalvm/community-edition/default.nix | 15 +++++ .../graalvm11-ce-sources.json | 28 ++++---- .../graalvm17-ce-dev-sources.json | 12 ++++ .../graalvm17-ce-sources.json | 38 +++-------- .../graalvm/community-edition/mkGraal.nix | 60 +++++++---------- .../graalvm/community-edition/update.nix | 66 ++++++++++++------- pkgs/top-level/all-packages.nix | 1 + 7 files changed, 117 insertions(+), 103 deletions(-) create mode 100644 pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json diff --git a/pkgs/development/compilers/graalvm/community-edition/default.nix b/pkgs/development/compilers/graalvm/community-edition/default.nix index fa1d074866c..5a3a9e4d6ca 100644 --- a/pkgs/development/compilers/graalvm/community-edition/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/default.nix @@ -56,4 +56,19 @@ in javaVersion = "17"; platforms = builtins.attrNames config; }; + + graalvm17-ce-dev = mkGraal rec { + config = { + aarch64-darwin = { + arch = "darwin-aarch64"; + products = [ + "graalvm-ce" + "native-image-installable-svm" + ]; + }; + }; + version = "22.2.0-dev-20220326_0133"; + javaVersion = "17"; + platforms = builtins.attrNames config; + }; } diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json index deb4c59a1b2..9a4d31dbc93 100644 --- a/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json +++ b/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json @@ -1,62 +1,62 @@ { "darwin-amd64": { - "graalvm-ce_java11_22.0.0.2": { + "graalvm-ce|java11|22.0.0.2": { "sha256": "8280159b8a66c51a839c8079d885928a7f759d5da0632f3af7300df2b63a6323", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-darwin-amd64-22.0.0.2.tar.gz" }, - "native-image-installable-svm_java11_22.0.0.2": { + "native-image-installable-svm|java11|22.0.0.2": { "sha256": "03c27de6cce61ee8073e89252212457f3fbac2c0bc9bfa4acbff12176476c176", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java11-darwin-amd64-22.0.0.2.jar" }, - "python-installable-svm_java11_22.0.0.2": { + "python-installable-svm|java11|22.0.0.2": { "sha256": "67ee2f1cc10b0189e359344c31b22f423e636ff4ec2dd7d9437c3eb0ef54e601", "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java11-darwin-amd64-22.0.0.2.jar" }, - "ruby-installable-svm_java11_22.0.0.2": { + "ruby-installable-svm|java11|22.0.0.2": { "sha256": "a25c0099a21ca1ca9904dd3acdeef509f67a13b96c6135b6de199e9805330df9", "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java11-darwin-amd64-22.0.0.2.jar" }, - "wasm-installable-svm_java11_22.0.0.2": { + "wasm-installable-svm|java11|22.0.0.2": { "sha256": "d74c210a8a87b8eb0c4d18a65fde6f2c03ebc94d9bf7ed87bbb9cacc460006d7", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java11-darwin-amd64-22.0.0.2.jar" } }, "linux-aarch64": { - "graalvm-ce_java11_22.0.0.2": { + "graalvm-ce|java11|22.0.0.2": { "sha256": "1cc0263d95f642dada4e290dca7f49c0456cefa7b690b67e3e5c159b537b2c58", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-linux-aarch64-22.0.0.2.tar.gz" }, - "native-image-installable-svm_java11_22.0.0.2": { + "native-image-installable-svm|java11|22.0.0.2": { "sha256": "51d41e890a5aabf8e7b9d4f4e0f88206ee70a261f7dbb0315d51770ab8f3009e", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java11-linux-aarch64-22.0.0.2.jar" }, - "ruby-installable-svm_java11_22.0.0.2": { + "ruby-installable-svm|java11|22.0.0.2": { "sha256": "e0fb582a9c6b4167e7dc267c58ca1968bd1c471b3bc5c56061b436f175486d80", "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java11-linux-aarch64-22.0.0.2.jar" }, - "wasm-installable-svm_java11_22.0.0.2": { + "wasm-installable-svm|java11|22.0.0.2": { "sha256": "a48470ae391c75cb2805b7fe27cde2c925c0466fdbc0623dfbb67c54f19dbf8c", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java11-linux-aarch64-22.0.0.2.jar" } }, "linux-amd64": { - "graalvm-ce_java11_22.0.0.2": { + "graalvm-ce|java11|22.0.0.2": { "sha256": "bc86083bb7e2778c7e4fe4f55d74790e42255b96f7806a7fefa51d06f3bc7103", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java11-linux-amd64-22.0.0.2.tar.gz" }, - "native-image-installable-svm_java11_22.0.0.2": { + "native-image-installable-svm|java11|22.0.0.2": { "sha256": "8504a3441f5b28b8fd625f676674a9216f082ae63a4e30d43930c80f9672e71d", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java11-linux-amd64-22.0.0.2.jar" }, - "python-installable-svm_java11_22.0.0.2": { + "python-installable-svm|java11|22.0.0.2": { "sha256": "2f01d1bbc2ed2c507952d8ceaab1cb2176fc67e2d8c4b3bf5864e8d930c60c55", "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java11-linux-amd64-22.0.0.2.jar" }, - "ruby-installable-svm_java11_22.0.0.2": { + "ruby-installable-svm|java11|22.0.0.2": { "sha256": "e90f7ebc13b6c1f8e3f98881bb4fe2336870744174b2b6d41dc672d15f0b9a40", "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java11-linux-amd64-22.0.0.2.jar" }, - "wasm-installable-svm_java11_22.0.0.2": { + "wasm-installable-svm|java11|22.0.0.2": { "sha256": "c0fdfc40374b70f6f1597dd21660535c813dc5c3948c8a6ea9559a20f4d3fb5e", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java11-linux-amd64-22.0.0.2.jar" } diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json new file mode 100644 index 00000000000..f3f15fdbc2c --- /dev/null +++ b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json @@ -0,0 +1,12 @@ +{ + "darwin-aarch64": { + "graalvm-ce|java17|22.2.0-dev-20220326_0133": { + "sha256": "72bab733783684dba422d9e04eb4fbd9103adb21db6937cf204c0c46e6ce5b7d", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220326_0133/graalvm-ce-java17-darwin-aarch64-dev.tar.gz" + }, + "native-image-installable-svm|java17|22.2.0-dev-20220326_0133": { + "sha256": "397fd17fef67456f66820cbdae9493d16785499b91002d20fdef6e5aaf067ba7", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220326_0133/native-image-installable-svm-java17-darwin-aarch64-dev.jar" + } + } +} diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json index 8712d25c9e3..b4bfde2dc50 100644 --- a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json +++ b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json @@ -1,62 +1,44 @@ { "darwin-amd64": { - "graalvm-ce_java17_22.0.0.2": { + "graalvm-ce|java17|22.0.0.2": { "sha256": "d54af9d1f4d0d351827395a714ed84d2489b023b74a9c13a431cc9d31d1e8f9a", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java17-darwin-amd64-22.0.0.2.tar.gz" }, - "native-image-installable-svm_java17_22.0.0.2": { + "native-image-installable-svm|java17|22.0.0.2": { "sha256": "007fa742cd139d447f83d776b6d78e717c9df11d56a61061a5937547c20028b7", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java17-darwin-amd64-22.0.0.2.jar" }, - "python-installable-svm_java17_22.0.0.2": { + "python-installable-svm|java17|22.0.0.2": { "sha256": "af887b0304d5ec98fab1be2cd1fca2aa3b10e84e823142a7f274560b1e0ea7c1", "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java17-darwin-amd64-22.0.0.2.jar" }, - "ruby-installable-svm_java17_22.0.0.2": { + "ruby-installable-svm|java17|22.0.0.2": { "sha256": "fc5eb6f833136ae3fda61f46fe0af66a8454ca2f803ca35eaff7336521cb468d", "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java17-darwin-amd64-22.0.0.2.jar" }, - "wasm-installable-svm_java17_22.0.0.2": { + "wasm-installable-svm|java17|22.0.0.2": { "sha256": "b76e6d872ce07ca9facd5b997dbb6e557ba72aa369ddd5f1664431bd11b98796", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java17-darwin-amd64-22.0.0.2.jar" } }, - "linux-aarch64": { - "graalvm-ce_java17_22.0.0.2": { - "sha256": "c7d78387d2a144944f26773697c1b61d3478a081a1c5e7fc20f47f1f5f3c82c7", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java17-linux-aarch64-22.0.0.2.tar.gz" - }, - "native-image-installable-svm_java17_22.0.0.2": { - "sha256": "798947d0a93988929d2b8e3555f7c65225e789124cd99fbc0c3aae5f350175db", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java17-linux-aarch64-22.0.0.2.jar" - }, - "ruby-installable-svm_java17_22.0.0.2": { - "sha256": "38cd733334efdecb040087341bccf0aed8031d70eccd857695eaee6b274a5a6d", - "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java17-linux-aarch64-22.0.0.2.jar" - }, - "wasm-installable-svm_java17_22.0.0.2": { - "sha256": "5a4d85324b0565c647b0a31f2a12c9192c9bdc49fca3fe57fdb95370e01c325e", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java17-linux-aarch64-22.0.0.2.jar" - } - }, "linux-amd64": { - "graalvm-ce_java17_22.0.0.2": { + "graalvm-ce|java17|22.0.0.2": { "sha256": "4f743e0ed3d974b7d619ca2ed6014554e8c12e5ebbb38b9bc9e820b182169bd4", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java17-linux-amd64-22.0.0.2.tar.gz" }, - "native-image-installable-svm_java17_22.0.0.2": { + "native-image-installable-svm|java17|22.0.0.2": { "sha256": "8c25f650d58c2649c97061cb806dfaec9e685d5d2b80afc7cf72fe61d6891831", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java17-linux-amd64-22.0.0.2.jar" }, - "python-installable-svm_java17_22.0.0.2": { + "python-installable-svm|java17|22.0.0.2": { "sha256": "b3b78a15bd29b4eaaf0f2607e21181ca2a5b41b38ba43a3ff2656c2f6effda8a", "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java17-linux-amd64-22.0.0.2.jar" }, - "ruby-installable-svm_java17_22.0.0.2": { + "ruby-installable-svm|java17|22.0.0.2": { "sha256": "d86c9ad50cbed980fa69d69b2eccd47d31880d8c55553483f59ce9eda15628bd", "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java17-linux-amd64-22.0.0.2.jar" }, - "wasm-installable-svm_java17_22.0.0.2": { + "wasm-installable-svm|java17|22.0.0.2": { "sha256": "7f7e51e4a24384b3dd960c12ab9b05b1fea58a0457d6b80e3797228fab93c0bd", "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java17-linux-amd64-22.0.0.2.jar" } diff --git a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix index 3c45c9c8a7b..cc8027dd128 100644 --- a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix +++ b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix @@ -43,7 +43,9 @@ assert useMusl -> stdenv.isLinux; let platform = config.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); - name = "graalvm${javaVersion}-ce"; + name = if lib.hasInfix "dev" version + then "graalvm${javaVersion}-ce-dev" + else "graalvm${javaVersion}-ce"; sourcesFilename = "${name}-sources.json"; sources = builtins.fromJSON (builtins.readFile (./. + "/${sourcesFilename}")); @@ -164,43 +166,25 @@ let done ''; in - { - "11-linux-amd64" = '' - ${copyClibrariesToOut "$out/lib/svm/clibraries"} + '' + # ensure that $lib/lib exists to avoid breaking builds + mkdir -p $lib/lib + # jni.h expects jni_md.h to be in the header search path. + ln -s $out/include/linux/*_md.h $out/include/ - ${copyClibrariesToLib} + # copy-paste openjdk's preFixup + # Set JAVA_HOME automatically. + mkdir -p $out/nix-support + cat > $out/nix-support/setup-hook << EOF + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi + EOF + ${ + lib.optionalString (stdenv.isLinux) '' + ${copyClibrariesToOut "$out/lib/svm/clibraries"} + ${copyClibrariesToLib} + '' + } ''; - "17-linux-amd64" = '' - ${copyClibrariesToOut "$out/lib/svm/clibraries"} - - ${copyClibrariesToLib} - ''; - "11-linux-aarch64" = '' - ${copyClibrariesToOut "$out/lib/svm/clibraries"} - - ${copyClibrariesToLib} - ''; - "17-linux-aarch64" = '' - ${copyClibrariesToOut "$out/lib/svm/clibraries"} - - ${copyClibrariesToLib} - ''; - "11-darwin-amd64" = ""; - "17-darwin-amd64" = ""; - "17-darwin-aarch64" = ""; - }.${javaVersionPlatform} + '' - # ensure that $lib/lib exists to avoid breaking builds - mkdir -p $lib/lib - # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/linux/*_md.h $out/include/ - - # copy-paste openjdk's preFixup - # Set JAVA_HOME automatically. - mkdir -p $out/nix-support - cat < $out/nix-support/setup-hook - if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi - EOF - ''; dontStrip = true; @@ -284,7 +268,7 @@ let } ${ - lib.optionalString (platform.arch != "linux-aarch64" && platform.arch != "darwin-aarch64") '' + lib.optionalString (builtins.any (a: a == "python-installable-svm") platform.products) '' echo "Testing GraalPython" $out/bin/graalpython -c 'print(1 + 1)' echo '1 + 1' | $out/bin/graalpython @@ -293,7 +277,7 @@ let echo "Testing TruffleRuby" ${ - lib.optionalString (platform != "darwin-aarch64") '' + lib.optionalString (builtins.any (a: a == "ruby-installable-svm") platform.products) '' # Hide warnings about wrong locale export LANG=C export LC_ALL=C diff --git a/pkgs/development/compilers/graalvm/community-edition/update.nix b/pkgs/development/compilers/graalvm/community-edition/update.nix index 2be8fff134f..efb46fe838d 100644 --- a/pkgs/development/compilers/graalvm/community-edition/update.nix +++ b/pkgs/development/compilers/graalvm/community-edition/update.nix @@ -10,6 +10,7 @@ }: let + productJavaVersionGraalVersionSep = "|"; # getArchString :: String -> String getArchString = nixArchString: { @@ -21,40 +22,58 @@ let # getProductSuffix :: String -> String getProductSuffix = productName: - let suffixes = { + { "graalvm-ce" = ".tar.gz"; "native-image-installable-svm" = ".jar"; "ruby-installable-svm" = ".jar"; "wasm-installable-svm" = ".jar"; "python-installable-svm" = ".jar"; - }; - in - suffixes.${productName}; + }.${productName}; # getProductSuffix :: String -> String getProductBaseUrl = productName: - let baseUrls = { + { "graalvm-ce" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; "native-image-installable-svm" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; "ruby-installable-svm" = "https://github.com/oracle/truffleruby/releases/download"; "wasm-installable-svm" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; "python-installable-svm" = "https://github.com/graalvm/graalpython/releases/download"; - }; + }.${productName}; + + # getDevUrl :: String + getDevUrl = { arch, graalVersion, product, javaVersion }: + let + baseUrl = https://github.com/graalvm/graalvm-ce-dev-builds/releases/download; in - baseUrls.${productName}; + "${baseUrl}/${graalVersion}/${product}-${javaVersion}-${arch}-dev${getProductSuffix product}"; - # generateUrl :: AttrSet -> String - generateUrl = { arch, graalVersion, product, javaVersion }: - - let baseUrl = getProductBaseUrl product; - in - "${baseUrl}/vm-${graalVersion}/${product}-${javaVersion}-${arch}-${graalVersion}${getProductSuffix product}"; - - # downloadSha256 :: AttrSet -> String - downloadSha256 = args@{ arch, graalVersion, product, javaVersion }: - let url = generateUrl args + ".sha256"; + # getReleaseUrl :: AttrSet -> String + getReleaseUrl = { arch, graalVersion, product, javaVersion }: + let baseUrl = getProductBaseUrl product; in - builtins.readFile (builtins.fetchurl url); + "${baseUrl}/vm-${graalVersion}/${product}-${javaVersion}-${arch}-${graalVersion}${getProductSuffix product}"; + + # getUrl :: AttrSet -> String + getUrl = args@{ arch, graalVersion, product, javaVersion }: + if lib.hasInfix "dev" graalVersion + then getDevUrl args + else getReleaseUrl args; + + # computeSha256 :: String -> String + computeSha256 = url: + builtins.hashFile "sha256" (builtins.fetchurl url); + + # downloadSha256 :: String -> String + downloadSha256 = url: + let sha256Url = url + ".sha256"; + in + builtins.readFile (builtins.fetchurl sha256Url); + + # getSha256 :: String -> String -> String + getSha256 = graalVersion: url: + if lib.hasInfix "dev" graalVersion + then computeSha256 url + else downloadSha256 url; # cartesianZipListsWith :: (a -> b -> c) -> [a] -> [b] -> [c] cartesianZipListsWith = f: fst: snd: @@ -73,7 +92,7 @@ let # genProductJavaVersionGraalVersionAttrSet :: String -> AttrSet genProductJavaVersionGraalVersionAttrSet = product_javaVersion_graalVersion: let attrNames = [ "product" "javaVersion" "graalVersion" ]; - attrValues = lib.splitString "_" product_javaVersion_graalVersion; + attrValues = lib.splitString productJavaVersionGraalVersionSep product_javaVersion_graalVersion; in zipListsToAttrs attrNames attrValues; # genUrlAndSha256 :: String -> String -> AttrSet @@ -82,8 +101,8 @@ let productJavaVersionGraalVersion = (genProductJavaVersionGraalVersionAttrSet product_javaVersion_graalVersion) // { inherit arch; }; - url = generateUrl productJavaVersionGraalVersion; - sha256 = downloadSha256 productJavaVersionGraalVersion; + url = getUrl productJavaVersionGraalVersion; + sha256 = getSha256 productJavaVersionGraalVersion.graalVersion url; in { ${arch} = { @@ -99,7 +118,8 @@ let arch = archProducts.arch; products = archProducts.products; productJavaGraalVersionList = - cartesianZipListsWith (a: b: a + "_" + b) products [ javaGraalVersion ]; + cartesianZipListsWith (a: b: a + productJavaVersionGraalVersionSep + b) + products [ javaGraalVersion ]; in cartesianZipListsWith (genUrlAndSha256) [ arch ] productJavaGraalVersionList; @@ -107,7 +127,7 @@ let # genSources :: String -> String -> AttrSet -> Path String genSources = graalVersion: javaVersion: config: let - javaGraalVersion = javaVersion + "_" + graalVersion; # java17_20.2.0.2 + javaGraalVersion = javaVersion + productJavaVersionGraalVersionSep + graalVersion; archProducts = builtins.attrValues config; sourcesList = builtins.concatMap (genArchProductVersionList javaGraalVersion) archProducts; sourcesAttr = builtins.foldl' (lib.recursiveUpdate) {} sourcesList; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5d52bf43efc..64bfff82d9c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12864,6 +12864,7 @@ with pkgs; }); graalvm11-ce = graalvmCEPackages.graalvm11-ce; graalvm17-ce = graalvmCEPackages.graalvm17-ce; + graalvm17-ce-dev = graalvmCEPackages.graalvm17-ce-dev; buildGraalvmNativeImage = callPackage ../build-support/build-graalvm-native-image { }; inherit (callPackages ../development/compilers/graalvm/enterprise-edition.nix { }) From 50f6c0dfa78b0ef081059953df6aad0769c7a0e1 Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Tue, 29 Mar 2022 16:59:42 +0200 Subject: [PATCH 3/8] graalvmXX-ce: refactor and clean up of update.nix The update script fetches the latest versions and only computes/downloads the sha256 if there is a new version to improve runtime. --- .../graalvm/community-edition/default.nix | 6 +- .../graalvm17-ce-dev-sources.json | 12 +- .../graalvm/community-edition/hashes.nix | 57 ---- .../graalvm/community-edition/mkGraal.nix | 55 ++-- .../graalvm/community-edition/update.nix | 272 +++++++++++------- .../graalvm/community-edition/update.sh | 81 ------ 6 files changed, 204 insertions(+), 279 deletions(-) delete mode 100644 pkgs/development/compilers/graalvm/community-edition/hashes.nix delete mode 100755 pkgs/development/compilers/graalvm/community-edition/update.sh diff --git a/pkgs/development/compilers/graalvm/community-edition/default.nix b/pkgs/development/compilers/graalvm/community-edition/default.nix index 5a3a9e4d6ca..d45b600d840 100644 --- a/pkgs/development/compilers/graalvm/community-edition/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/default.nix @@ -1,4 +1,8 @@ { lib, callPackage, Foundation }: +/* +Add new graal versions and products here and then see update.nix on how to +generate the sources. +*/ let mkGraal = opts: callPackage (import ./mkGraal.nix opts) { @@ -67,7 +71,7 @@ in ]; }; }; - version = "22.2.0-dev-20220326_0133"; + version = "22.2.0-dev-20220330_2302"; javaVersion = "17"; platforms = builtins.attrNames config; }; diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json index f3f15fdbc2c..fba77c58b74 100644 --- a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json +++ b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json @@ -1,12 +1,12 @@ { "darwin-aarch64": { - "graalvm-ce|java17|22.2.0-dev-20220326_0133": { - "sha256": "72bab733783684dba422d9e04eb4fbd9103adb21db6937cf204c0c46e6ce5b7d", - "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220326_0133/graalvm-ce-java17-darwin-aarch64-dev.tar.gz" + "graalvm-ce|java17|22.2.0-dev-20220330_2302": { + "sha256": "e072cdcdf1dcc7884cfe53806e997649ae829a30e1efe19b0b77a91800da79c3", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220330_2302/graalvm-ce-java17-darwin-aarch64-dev.tar.gz" }, - "native-image-installable-svm|java17|22.2.0-dev-20220326_0133": { - "sha256": "397fd17fef67456f66820cbdae9493d16785499b91002d20fdef6e5aaf067ba7", - "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220326_0133/native-image-installable-svm-java17-darwin-aarch64-dev.jar" + "native-image-installable-svm|java17|22.2.0-dev-20220330_2302": { + "sha256": "fb554d9de8252630e8bde122ca98a75d39e200390384ddb410b3c3af3898ba6a", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220330_2302/native-image-installable-svm-java17-darwin-aarch64-dev.jar" } } } diff --git a/pkgs/development/compilers/graalvm/community-edition/hashes.nix b/pkgs/development/compilers/graalvm/community-edition/hashes.nix deleted file mode 100644 index f21fdb25270..00000000000 --- a/pkgs/development/compilers/graalvm/community-edition/hashes.nix +++ /dev/null @@ -1,57 +0,0 @@ -# Generated by ./update.sh script -{ javaVersionPlatform, ... }: -[ - { - sha256 = { - "11-linux-aarch64" = "0n1cgd9rn5aw7rzbd45nlzpnqif095zwl3999vddlhpnjlyjdh0w"; - "17-linux-aarch64" = "1iw27igiyzzl43yfgid1h6h7hd0xnv0rfdkp4r7r8i51sa3q7my7"; - "11-linux-amd64" = "00vipkrhc7d5xxznm07pjrdjahhfg5s5vxg49xz8qxz2nwxhi1mw"; - "17-linux-amd64" = "1m4v2s1b2878r6dqpcxvbqpc3s2l8l0xcbna37bbfx6rsc73wx2g"; - "11-darwin-amd64" = "08v37avg439hywx2yqx0bnfpazwaja2xhyc0kj1imib6iadib042"; - "17-darwin-amd64" = "16lg3qfx7j8w8cxc3abl7c19nj6jhkni99wmff153lyhyk8zjjnm"; - }.${javaVersionPlatform} or null; - url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/graalvm-ce-java${javaVersionPlatform}-22.0.0.2.tar.gz"; - } - { - sha256 = { - "11-linux-aarch64" = "17h0yfw0lxsiblqv1nzpc6i71vh6hbwf1x6lp7kziass1a4ixm2i"; - "17-linux-aarch64" = "1nvm04smzbis1jy9znac2a4yf9ajqvvmadcf5ffr521rm784g2br"; - "11-linux-amd64" = "07g7fab0zj1h77a30kiswqm0hvr1m5s6crszcbyvha2v3x2a6145"; - "17-linux-amd64" = "0c8qi7b63zkjrz3sz01bbmfni7pcz9nq1jv1f34lj9lcsm8gc9cc"; - "11-darwin-amd64" = "0xn1frj1f4pzrd5gm6xwq31blgvz8l9249c97q3yh7p6rkk7vhh3"; - "17-darwin-amd64" = "1dr80314fxcklmhi19jn3pqrsz3iivbvcxnphdzl978krm1afzq0"; - }.${javaVersionPlatform} or null; - url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/native-image-installable-svm-java${javaVersionPlatform}-22.0.0.2.jar"; - } - { - sha256 = { - "11-linux-aarch64" = "103d91sz2dmlc5hcbi9v3d3irgb83755hz16vkknfhbbkhm5iyz0"; - "17-linux-aarch64" = "0vas98knpvpajmv8bkgcf0fh7n5fy361nd47002cpppg6hrp7k9q"; - "11-linux-amd64" = "0h4s1dgx2wn63pabdckl85s70s1kw97vp0c8z7izihdn2fy7w3z9"; - "17-linux-amd64" = "1g98ashyvscwyn1k8mamih6qhcbxsk62x6ynd7x81ndy1karlv6q"; - "11-darwin-amd64" = "1y8d6c2ri7hrvsv3aqbcp49pmxh9yppcsfnx0jcwm88wlach0p52"; - "17-darwin-amd64" = "13a6rchnaczpmxga6g405z55913ayq5gwihzlvyy6shk6gwbcppw"; - }.${javaVersionPlatform} or null; - url = "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java${javaVersionPlatform}-22.0.0.2.jar"; - } - { - sha256 = { - "11-linux-aarch64" = "135zkpqm8z5nzcyn5h6vdx3c09f9wb6jgzmp0llcnx8w76p71154"; - "17-linux-aarch64" = "0pij3kh70lxrzmbzx8zw97f9nb0rr492l7x3n13wcr859cr8akas"; - "11-linux-amd64" = "0ppvsgs216jmm5p8m34lqg2kv0awadh1dlkxb7qzcw2b6x0grzf0"; - "17-linux-amd64" = "1gf0jfmqy8lp6w7bimjp0j5abzmi0ndsn4hcjvfv7123lbj52zkz"; - "11-darwin-amd64" = "1mq6013crjmrpf3yvxwv9p4yn0rcdzg5z9hq9l6fpf47i8522k6p"; - "17-darwin-amd64" = "15l7p48vsca4cvqxbpb9lcmafysmdsxpv6avrpxajz705j3nsvmp"; - }.${javaVersionPlatform} or null; - url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.0.0.2/wasm-installable-svm-java${javaVersionPlatform}-22.0.0.2.jar"; - } - { - sha256 = { - "11-linux-amd64" = "0m8cqqqdks34b2zv7i6qw9kzqxi1rfqsmknqa9wm0b7dqaxx209g"; - "17-linux-amd64" = "12nszxp2yv35y8zkm94bnd0mnanah48y41r61ypymd19plaqmdxk"; - "11-darwin-amd64" = "00g6akpv0gkw8gcxfbgcyipn6gj25yr32k1lb7iqj08bq4f2zvk7"; - "17-darwin-amd64" = "1hd71qg0nmklyakl4cc29vl10fxalbyd2b5yn7x9iv6m0h1pp25g"; - }.${javaVersionPlatform} or null; - url = "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java${javaVersionPlatform}-22.0.0.2.jar"; - } -] diff --git a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix index cc8027dd128..ea4fd89bbcb 100644 --- a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix +++ b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix @@ -36,14 +36,15 @@ , writeScript , jq , runtimeShell -, callPackage +, gawk }: assert useMusl -> stdenv.isLinux; let platform = config.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); - name = if lib.hasInfix "dev" version + name = + if lib.hasInfix "dev" version then "graalvm${javaVersion}-ce-dev" else "graalvm${javaVersion}-ce"; sourcesFilename = "${name}-sources.json"; @@ -61,20 +62,10 @@ let (writeShellScriptBin "${stdenv.system}-musl-gcc" ''${lib.getDev musl}/bin/musl-gcc "$@"'') ]); - javaVersionPlatform = "${javaVersion}-${platform.arch}"; - graalvmXXX-ce = stdenv.mkDerivation rec { inherit version name; + srcs = map fetchurl (builtins.attrValues sources.${platform.arch}); - /*let - # Some platforms doesn't have all GraalVM features - # e.g.: GraalPython on aarch64-linux - # When the platform doesn't have a feature, sha256 is null on hashes.nix - # To update hashes.nix file, run `./update.sh ` - maybeFetchUrl = url: if url.sha256 != null then (fetchurl url) else null; - in - (lib.remove null - (map maybeFetchUrl (hashes { inherit javaVersionPlatform; })));*/ buildInputs = lib.optionals stdenv.isLinux [ alsa-lib # libasound.so wanted by lib/libjsound.so @@ -166,25 +157,25 @@ let done ''; in - '' - # ensure that $lib/lib exists to avoid breaking builds - mkdir -p $lib/lib - # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/linux/*_md.h $out/include/ + '' + # ensure that $lib/lib exists to avoid breaking builds + mkdir -p $lib/lib + # jni.h expects jni_md.h to be in the header search path. + ln -s $out/include/linux/*_md.h $out/include/ - # copy-paste openjdk's preFixup - # Set JAVA_HOME automatically. - mkdir -p $out/nix-support - cat > $out/nix-support/setup-hook << EOF - if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi - EOF - ${ - lib.optionalString (stdenv.isLinux) '' - ${copyClibrariesToOut "$out/lib/svm/clibraries"} - ${copyClibrariesToLib} - '' - } - ''; + # copy-paste openjdk's preFixup + # Set JAVA_HOME automatically. + mkdir -p $out/nix-support + cat > $out/nix-support/setup-hook << EOF + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi + EOF + ${ + lib.optionalString (stdenv.isLinux) '' + ${copyClibrariesToOut "$out/lib/svm/clibraries"} + ${copyClibrariesToLib} + '' + } + ''; dontStrip = true; @@ -303,7 +294,7 @@ let passthru = { home = graalvmXXX-ce; updateScript = import ./update.nix { - inherit lib writeScript jq runtimeShell sourcesFilename config; + inherit lib writeScript jq runtimeShell sourcesFilename name config gawk; graalVersion = version; javaVersion = "java${javaVersion}"; }; diff --git a/pkgs/development/compilers/graalvm/community-edition/update.nix b/pkgs/development/compilers/graalvm/community-edition/update.nix index efb46fe838d..e9d32cf7bde 100644 --- a/pkgs/development/compilers/graalvm/community-edition/update.nix +++ b/pkgs/development/compilers/graalvm/community-edition/update.nix @@ -1,16 +1,53 @@ -{ - javaVersion, - graalVersion, - config, - sourcesFilename, - lib, - writeScript, - jq, - runtimeShell +{ javaVersion +, graalVersion +, config +, sourcesFilename +, name +, lib +, writeScript +, jq +, runtimeShell +, gawk }: +/* + How to use: + run `nix-shell maintainers/scripts/update.nix --argstr package graalvmXX-ce` + to update the graalvmXX-ce-sources.json file. + E.g: nix-shell maintainers/scripts/update.nix --argstr package graalvm17-ce + + Basic idea: + If we know the platform, product, javaVersion and graalVersion + we can create the url. This leads to the following json structure: + { + "platform/arch1": { + "product1|javaVersion|graalVersion": { "sha256": "...", "url": "..."}, + "product2|javaVersion|graalVersion": { "sha256": "...", "url": "..."}, + ... + }, + "platform/arch2": { + ... + } + } +*/ + let productJavaVersionGraalVersionSep = "|"; + + # isDev :: String -> Boolean + isDev = version: + lib.hasInfix "dev" version; + + # getLatestVersion :: String -> String + getLatestVersion = currentVersion: + let + dev = if isDev currentVersion then "dev-" else ""; + url = "https://api.github.com/repos/graalvm/graalvm-ce-${dev}builds/releases/latest"; + file = builtins.fetchurl url; + json = builtins.fromJSON (builtins.readFile file); + in + lib.removePrefix "vm-" json.tag_name; + # getArchString :: String -> String getArchString = nixArchString: { @@ -21,129 +58,160 @@ let # getProductSuffix :: String -> String - getProductSuffix = productName: - { - "graalvm-ce" = ".tar.gz"; - "native-image-installable-svm" = ".jar"; - "ruby-installable-svm" = ".jar"; - "wasm-installable-svm" = ".jar"; - "python-installable-svm" = ".jar"; - }.${productName}; + getProductSuffix = productName: + { + "graalvm-ce" = ".tar.gz"; + "native-image-installable-svm" = ".jar"; + "ruby-installable-svm" = ".jar"; + "wasm-installable-svm" = ".jar"; + "python-installable-svm" = ".jar"; + }.${productName}; # getProductSuffix :: String -> String - getProductBaseUrl = productName: - { - "graalvm-ce" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; - "native-image-installable-svm" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; - "ruby-installable-svm" = "https://github.com/oracle/truffleruby/releases/download"; - "wasm-installable-svm" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; - "python-installable-svm" = "https://github.com/graalvm/graalpython/releases/download"; - }.${productName}; + getProductBaseUrl = productName: + { + "graalvm-ce" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; + "native-image-installable-svm" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; + "ruby-installable-svm" = "https://github.com/oracle/truffleruby/releases/download"; + "wasm-installable-svm" = "https://github.com/graalvm/graalvm-ce-builds/releases/download"; + "python-installable-svm" = "https://github.com/graalvm/graalpython/releases/download"; + }.${productName}; # getDevUrl :: String - getDevUrl = { arch, graalVersion, product, javaVersion }: - let - baseUrl = https://github.com/graalvm/graalvm-ce-dev-builds/releases/download; - in - "${baseUrl}/${graalVersion}/${product}-${javaVersion}-${arch}-dev${getProductSuffix product}"; + getDevUrl = { arch, graalVersion, product, javaVersion }: + let + baseUrl = https://github.com/graalvm/graalvm-ce-dev-builds/releases/download; + in + "${baseUrl}/${graalVersion}/${product}-${javaVersion}-${arch}-dev${getProductSuffix product}"; # getReleaseUrl :: AttrSet -> String - getReleaseUrl = { arch, graalVersion, product, javaVersion }: - let baseUrl = getProductBaseUrl product; - in - "${baseUrl}/vm-${graalVersion}/${product}-${javaVersion}-${arch}-${graalVersion}${getProductSuffix product}"; + getReleaseUrl = { arch, graalVersion, product, javaVersion }: + let baseUrl = getProductBaseUrl product; + in + "${baseUrl}/vm-${graalVersion}/${product}-${javaVersion}-${arch}-${graalVersion}${getProductSuffix product}"; # getUrl :: AttrSet -> String - getUrl = args@{ arch, graalVersion, product, javaVersion }: - if lib.hasInfix "dev" graalVersion - then getDevUrl args - else getReleaseUrl args; + getUrl = args@{ arch, graalVersion, product, javaVersion }: + if isDev graalVersion + then getDevUrl args + else getReleaseUrl args; # computeSha256 :: String -> String - computeSha256 = url: - builtins.hashFile "sha256" (builtins.fetchurl url); + computeSha256 = url: + builtins.hashFile "sha256" (builtins.fetchurl url); # downloadSha256 :: String -> String - downloadSha256 = url: - let sha256Url = url + ".sha256"; - in - builtins.readFile (builtins.fetchurl sha256Url); + downloadSha256 = url: + let sha256Url = url + ".sha256"; + in + builtins.readFile (builtins.fetchurl sha256Url); # getSha256 :: String -> String -> String - getSha256 = graalVersion: url: - if lib.hasInfix "dev" graalVersion - then computeSha256 url - else downloadSha256 url; + getSha256 = graalVersion: url: + if isDev graalVersion + then computeSha256 url + else downloadSha256 url; # cartesianZipListsWith :: (a -> b -> c) -> [a] -> [b] -> [c] - cartesianZipListsWith = f: fst: snd: - let cartesianProduct = lib.cartesianProductOfSets { a = fst; b = snd; }; - fst' = builtins.catAttrs "a" cartesianProduct; - snd' = builtins.catAttrs "b" cartesianProduct; - in - lib.zipListsWith f fst' snd'; + cartesianZipListsWith = f: fst: snd: + let + cartesianProduct = lib.cartesianProductOfSets { a = fst; b = snd; }; + fst' = builtins.catAttrs "a" cartesianProduct; + snd' = builtins.catAttrs "b" cartesianProduct; + in + lib.zipListsWith f fst' snd'; # zipListsToAttrs :: [a] -> [b] -> AttrSet - zipListsToAttrs = names: values: - lib.listToAttrs ( - lib.zipListsWith (name: value: { inherit name value; }) names values - ); + zipListsToAttrs = names: values: + lib.listToAttrs ( + lib.zipListsWith (name: value: { inherit name value; }) names values + ); # genProductJavaVersionGraalVersionAttrSet :: String -> AttrSet - genProductJavaVersionGraalVersionAttrSet = product_javaVersion_graalVersion: - let attrNames = [ "product" "javaVersion" "graalVersion" ]; - attrValues = lib.splitString productJavaVersionGraalVersionSep product_javaVersion_graalVersion; - in zipListsToAttrs attrNames attrValues; + genProductJavaVersionGraalVersionAttrSet = product_javaVersion_graalVersion: + let + attrNames = [ "product" "javaVersion" "graalVersion" ]; + attrValues = lib.splitString productJavaVersionGraalVersionSep product_javaVersion_graalVersion; + in + zipListsToAttrs attrNames attrValues; # genUrlAndSha256 :: String -> String -> AttrSet - genUrlAndSha256 = arch: product_javaVersion_graalVersion: - let - productJavaVersionGraalVersion = - (genProductJavaVersionGraalVersionAttrSet product_javaVersion_graalVersion) - // { inherit arch; }; - url = getUrl productJavaVersionGraalVersion; - sha256 = getSha256 productJavaVersionGraalVersion.graalVersion url; - in - { - ${arch} = { - ${product_javaVersion_graalVersion} = { - inherit sha256 url; - }; + genUrlAndSha256 = arch: product_javaVersion_graalVersion: + let + productJavaVersionGraalVersion = + (genProductJavaVersionGraalVersionAttrSet product_javaVersion_graalVersion) + // { inherit arch; }; + url = getUrl productJavaVersionGraalVersion; + sha256 = getSha256 productJavaVersionGraalVersion.graalVersion url; + in + { + ${arch} = { + ${product_javaVersion_graalVersion} = { + inherit sha256 url; }; }; + }; # genArchProductVersionPairs :: String -> AttrSet -> [AttrSet] - genArchProductVersionList = javaGraalVersion: archProducts: - let - arch = archProducts.arch; - products = archProducts.products; - productJavaGraalVersionList = - cartesianZipListsWith (a: b: a + productJavaVersionGraalVersionSep + b) - products [ javaGraalVersion ]; - in - cartesianZipListsWith (genUrlAndSha256) [ arch ] productJavaGraalVersionList; + genArchProductVersionList = javaGraalVersion: archProducts: + let + arch = archProducts.arch; + products = archProducts.products; + productJavaGraalVersionList = + cartesianZipListsWith (a: b: a + productJavaVersionGraalVersionSep + b) + products [ javaGraalVersion ]; + in + cartesianZipListsWith (genUrlAndSha256) [ arch ] productJavaGraalVersionList; # genSources :: String -> String -> AttrSet -> Path String - genSources = graalVersion: javaVersion: config: - let - javaGraalVersion = javaVersion + productJavaVersionGraalVersionSep + graalVersion; - archProducts = builtins.attrValues config; - sourcesList = builtins.concatMap (genArchProductVersionList javaGraalVersion) archProducts; - sourcesAttr = builtins.foldl' (lib.recursiveUpdate) {} sourcesList; - in - builtins.toFile "sources.json" (builtins.toJSON sourcesAttr); + genSources = graalVersion: javaVersion: config: + let + javaGraalVersion = javaVersion + productJavaVersionGraalVersionSep + graalVersion; + archProducts = builtins.attrValues config; + sourcesList = builtins.concatMap (genArchProductVersionList javaGraalVersion) archProducts; + sourcesAttr = builtins.foldl' (lib.recursiveUpdate) { } sourcesList; + in + builtins.toFile "sources.json" (builtins.toJSON sourcesAttr); - sourcesJson = genSources graalVersion javaVersion config; + # isNew :: String -> String -> Boolean + isNew = newVersion: currentVersion: + { + "-1" = false; + "0" = false; + "1" = true; + }.${builtins.toString (builtins.compareVersions newVersion currentVersion)}; + + newVersion = getLatestVersion graalVersion; + sourcesJson = genSources newVersion javaVersion config; + sourcesJsonPath = lib.strings.escapeShellArg ././${sourcesFilename}; + defaultNixPath = lib.strings.escapeShellArg ././default.nix; + + /* + updateScriptText :: String -> String -> String + Writes the json file, finds the line number of the current derivation + name, which wants to update with awk and replace the first version match + after that line. + */ + updateScriptText = newVersion: currentVersion: + if isNew newVersion currentVersion + then + '' + echo "New version found. Updating ${currentVersion} -> ${newVersion}". + export PATH="${lib.makeBinPath [ jq gawk ]}:$PATH" + jq . ${sourcesJson} > ${sourcesJsonPath} + drvName=$(awk '/${name}/{ print NR; exit }' ${defaultNixPath}) + awk -v drvName="$drvName" -i inplace \ + 'NR>drvName {sub(/${graalVersion}/, "${newVersion}")} 1' ${defaultNixPath} + '' + else ''echo "No new version found. Skip updating."''; in - writeScript "update-graal.sh" '' - #!${runtimeShell} - set -o errexit - set -o nounset - set -o pipefail +writeScript "update-graal.sh" '' + #!${runtimeShell} + set -o errexit + set -o nounset + set -o pipefail - export PATH="${lib.makeBinPath [ jq ]}:$PATH" - - jq . ${sourcesJson} > ${lib.strings.escapeShellArg ./.}/${sourcesFilename} - '' + ${updateScriptText newVersion graalVersion} +'' diff --git a/pkgs/development/compilers/graalvm/community-edition/update.sh b/pkgs/development/compilers/graalvm/community-edition/update.sh deleted file mode 100755 index c821c83a59c..00000000000 --- a/pkgs/development/compilers/graalvm/community-edition/update.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -p coreutils curl nix jq gnused -i bash - -set -eou pipefail - -cd "$(dirname "${BASH_SOURCE[0]}")" - -info() { echo "[INFO] $*"; } - -echo_file() { echo "$@" >> hashes.nix; } - -verlte() { - [ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ] -} - -readonly nixpkgs=../../../../.. - -readonly old_version="$(nix-instantiate "$nixpkgs" --eval --strict -A graalvm11-ce.version)" - -if [[ -z "${1:-}" ]]; then - readonly gh_version="$(curl \ - ${GITHUB_TOKEN:+"-u \":$GITHUB_TOKEN\""} \ - -s https://api.github.com/repos/graalvm/graalvm-ce-builds/releases/latest | \ - jq --raw-output .tag_name)" - readonly new_version="${gh_version//vm-/}" -else - readonly new_version="$1" -fi - -if verlte "$old_version" "$new_version"; then - info "graalvm-ce $old_version is up-to-date." - [[ -z "${FORCE:-}" ]] && exit 0 -else - info "graalvm-ce $old_version is out-of-date. Updating..." -fi - -readonly urls=( - "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/graalvm-ce-java@platform@-${new_version}.tar.gz" - "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/native-image-installable-svm-java@platform@-${new_version}.jar" - "https://github.com/oracle/truffleruby/releases/download/vm-${new_version}/ruby-installable-svm-java@platform@-${new_version}.jar" - "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/wasm-installable-svm-java@platform@-${new_version}.jar" - "https://github.com/graalvm/graalpython/releases/download/vm-${new_version}/python-installable-svm-java@platform@-${new_version}.jar" -) - -readonly platforms=( - "11-linux-aarch64" - "17-linux-aarch64" - "11-linux-amd64" - "17-linux-amd64" - "11-darwin-amd64" - "17-darwin-amd64" -) - -info "Deleting old hashes.nix file..." -rm -f hashes.nix -info "Generating hashes.nix file for 'graalvm-ce' $new_version. This will take a while..." - -echo_file "# Generated by $0 script" -echo_file "{ javaVersionPlatform, ... }:" -echo_file "[" - -for url in "${urls[@]}"; do - echo_file " {" - echo_file " sha256 = {" - for platform in "${platforms[@]}"; do - if hash="$(nix-prefetch-url "${url//@platform@/$platform}")"; then - echo_file " \"$platform\" = \"$hash\";" - fi - done - echo_file ' }.${javaVersionPlatform} or null;' - echo_file " url = \"${url//@platform@/\$\{javaVersionPlatform\}}\";" - echo_file " }" -done - -echo_file "]" - -info "Updating graalvm-ce version..." -# update-source-version does not work here since it expects src attribute -sed "s|$old_version|\"$new_version\"|" -i default.nix - -info "Done!" From 4b4d3759e96624c72fc7dfe9a52295998fb0cf49 Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Fri, 1 Apr 2022 12:59:37 +0200 Subject: [PATCH 4/8] graalvmXX-ce: remove graalvmXX-ce-dev and use dev version in graalvmXX-ce on aarch64-darwin --- .../graalvm/community-edition/default.nix | 39 ++++++++++----- .../graalvm11-ce-sources.json | 10 ++++ .../graalvm17-ce-dev-sources.json | 12 ----- .../graalvm17-ce-sources.json | 10 ++++ .../graalvm/community-edition/mkGraal.nix | 22 ++++----- .../graalvm/community-edition/update.nix | 49 ++++++++++--------- pkgs/top-level/all-packages.nix | 1 - 7 files changed, 83 insertions(+), 60 deletions(-) delete mode 100644 pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json diff --git a/pkgs/development/compilers/graalvm/community-edition/default.nix b/pkgs/development/compilers/graalvm/community-edition/default.nix index d45b600d840..d480c29317f 100644 --- a/pkgs/development/compilers/graalvm/community-edition/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/default.nix @@ -1,7 +1,7 @@ -{ lib, callPackage, Foundation }: +{ callPackage, Foundation }: /* -Add new graal versions and products here and then see update.nix on how to -generate the sources. + Add new graal versions and products here and then see update.nix on how to + generate the sources. */ let @@ -16,6 +16,15 @@ let "wasm-installable-svm" ]; + /* + Looks a bit ugly but makes version update in the update script using sed + much easier + */ + graalvm11-ce-release-version = "22.0.0.2"; + graalvm17-ce-release-version = "22.0.0.2"; + graalvm11-ce-dev-version = "22.2.0-dev-20220331_1955"; + graalvm17-ce-dev-version = "22.2.0-dev-20220331_1955"; + in { inherit mkGraal; @@ -25,17 +34,27 @@ in x86_64-darwin = { arch = "darwin-amd64"; products = commonProducts ++ [ "python-installable-svm" ]; + version = graalvm11-ce-release-version; }; x86_64-linux = { arch = "linux-amd64"; products = commonProducts ++ [ "python-installable-svm" ]; + version = graalvm11-ce-release-version; }; aarch64-linux = { arch = "linux-aarch64"; products = commonProducts; + version = graalvm11-ce-release-version; + }; + aarch64-darwin = { + arch = "darwin-aarch64"; + products = [ + "graalvm-ce" + "native-image-installable-svm" + ]; + version = graalvm11-ce-dev-version; }; }; - version = "22.0.0.2"; javaVersion = "11"; platforms = builtins.attrNames config; }; @@ -50,28 +69,22 @@ in x86_64-darwin = { arch = "darwin-amd64"; products = commonProducts ++ [ "python-installable-svm" ]; + version = graalvm17-ce-release-version; }; x86_64-linux = { arch = "linux-amd64"; products = commonProducts ++ [ "python-installable-svm" ]; + version = graalvm17-ce-release-version; }; - }; - version = "22.0.0.2"; - javaVersion = "17"; - platforms = builtins.attrNames config; - }; - - graalvm17-ce-dev = mkGraal rec { - config = { aarch64-darwin = { arch = "darwin-aarch64"; products = [ "graalvm-ce" "native-image-installable-svm" ]; + version = graalvm17-ce-dev-version; }; }; - version = "22.2.0-dev-20220330_2302"; javaVersion = "17"; platforms = builtins.attrNames config; }; diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json index 9a4d31dbc93..d12df716e05 100644 --- a/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json +++ b/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json @@ -1,4 +1,14 @@ { + "darwin-aarch64": { + "graalvm-ce|java11|22.2.0-dev-20220331_1955": { + "sha256": "a1229931575bd90256f5453ce9c880cf2286db117d4cbfec92c033813b017035", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220331_1955/graalvm-ce-java11-darwin-aarch64-dev.tar.gz" + }, + "native-image-installable-svm|java11|22.2.0-dev-20220331_1955": { + "sha256": "813f9cc417415801e3d7d6468bb06e45487c76fe35b56202b66b6c9fa3ce3456", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220331_1955/native-image-installable-svm-java11-darwin-aarch64-dev.jar" + } + }, "darwin-amd64": { "graalvm-ce|java11|22.0.0.2": { "sha256": "8280159b8a66c51a839c8079d885928a7f759d5da0632f3af7300df2b63a6323", diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json deleted file mode 100644 index fba77c58b74..00000000000 --- a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-dev-sources.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "darwin-aarch64": { - "graalvm-ce|java17|22.2.0-dev-20220330_2302": { - "sha256": "e072cdcdf1dcc7884cfe53806e997649ae829a30e1efe19b0b77a91800da79c3", - "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220330_2302/graalvm-ce-java17-darwin-aarch64-dev.tar.gz" - }, - "native-image-installable-svm|java17|22.2.0-dev-20220330_2302": { - "sha256": "fb554d9de8252630e8bde122ca98a75d39e200390384ddb410b3c3af3898ba6a", - "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220330_2302/native-image-installable-svm-java17-darwin-aarch64-dev.jar" - } - } -} diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json index b4bfde2dc50..ebc87f1e797 100644 --- a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json +++ b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json @@ -1,4 +1,14 @@ { + "darwin-aarch64": { + "graalvm-ce|java17|22.2.0-dev-20220331_1955": { + "sha256": "bb217a3bd53a488ef3672920fd47b9a0d800243eb385a7ceae9ddbd4350c0b27", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220331_1955/graalvm-ce-java17-darwin-aarch64-dev.tar.gz" + }, + "native-image-installable-svm|java17|22.2.0-dev-20220331_1955": { + "sha256": "eee405e704792794f45e619372e72e0343ba2caf8ace0e4c7abd8baa69e56bcf", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220331_1955/native-image-installable-svm-java17-darwin-aarch64-dev.jar" + } + }, "darwin-amd64": { "graalvm-ce|java17|22.0.0.2": { "sha256": "d54af9d1f4d0d351827395a714ed84d2489b023b74a9c13a431cc9d31d1e8f9a", diff --git a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix index ea4fd89bbcb..7642f25ac2c 100644 --- a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix +++ b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix @@ -1,5 +1,4 @@ -{ version -, javaVersion +{ javaVersion , platforms , config , useMusl ? false @@ -33,20 +32,17 @@ , cairo , glib , gtk3 -, writeScript +, writeShellScript , jq -, runtimeShell -, gawk +, gnused }: assert useMusl -> stdenv.isLinux; let platform = config.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); - name = - if lib.hasInfix "dev" version - then "graalvm${javaVersion}-ce-dev" - else "graalvm${javaVersion}-ce"; + version = platform.version; + name = "graalvm${javaVersion}-ce"; sourcesFilename = "${name}-sources.json"; sources = builtins.fromJSON (builtins.readFile (./. + "/${sourcesFilename}")); @@ -63,7 +59,8 @@ let ]); graalvmXXX-ce = stdenv.mkDerivation rec { - inherit version name; + inherit version; + pname = name; srcs = map fetchurl (builtins.attrValues sources.${platform.arch}); @@ -81,7 +78,8 @@ let zlib ]; - nativeBuildInputs = [ unzip perl makeWrapper ] ++ lib.optional stdenv.isLinux [ autoPatchelfHook ]; + nativeBuildInputs = [ unzip perl makeWrapper ] + ++ lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook; unpackPhase = '' unpack_jar() { @@ -294,7 +292,7 @@ let passthru = { home = graalvmXXX-ce; updateScript = import ./update.nix { - inherit lib writeScript jq runtimeShell sourcesFilename name config gawk; + inherit lib writeShellScript jq sourcesFilename name config gnused; graalVersion = version; javaVersion = "java${javaVersion}"; }; diff --git a/pkgs/development/compilers/graalvm/community-edition/update.nix b/pkgs/development/compilers/graalvm/community-edition/update.nix index e9d32cf7bde..724282e7b92 100644 --- a/pkgs/development/compilers/graalvm/community-edition/update.nix +++ b/pkgs/development/compilers/graalvm/community-edition/update.nix @@ -4,10 +4,9 @@ , sourcesFilename , name , lib -, writeScript +, writeShellScript , jq -, runtimeShell -, gawk +, gnused }: /* @@ -32,7 +31,7 @@ */ let - productJavaVersionGraalVersionSep = "|"; + separator = "|"; # isDev :: String -> Boolean isDev = version: @@ -131,7 +130,7 @@ let genProductJavaVersionGraalVersionAttrSet = product_javaVersion_graalVersion: let attrNames = [ "product" "javaVersion" "graalVersion" ]; - attrValues = lib.splitString productJavaVersionGraalVersionSep product_javaVersion_graalVersion; + attrValues = lib.splitString separator product_javaVersion_graalVersion; in zipListsToAttrs attrNames attrValues; @@ -153,23 +152,23 @@ let }; # genArchProductVersionPairs :: String -> AttrSet -> [AttrSet] - genArchProductVersionList = javaGraalVersion: archProducts: + genArchProductVersionList = javaVersion: archProducts: let arch = archProducts.arch; products = archProducts.products; + javaGraalVersion = javaVersion + separator + (getLatestVersion archProducts.version); productJavaGraalVersionList = - cartesianZipListsWith (a: b: a + productJavaVersionGraalVersionSep + b) + cartesianZipListsWith (a: b: a + separator + b) products [ javaGraalVersion ]; in cartesianZipListsWith (genUrlAndSha256) [ arch ] productJavaGraalVersionList; - # genSources :: String -> String -> AttrSet -> Path String - genSources = graalVersion: javaVersion: config: + # genSources :: String -> AttrSet -> Path String + genSources = javaVersion: config: let - javaGraalVersion = javaVersion + productJavaVersionGraalVersionSep + graalVersion; archProducts = builtins.attrValues config; - sourcesList = builtins.concatMap (genArchProductVersionList javaGraalVersion) archProducts; + sourcesList = builtins.concatMap (genArchProductVersionList javaVersion) archProducts; sourcesAttr = builtins.foldl' (lib.recursiveUpdate) { } sourcesList; in builtins.toFile "sources.json" (builtins.toJSON sourcesAttr); @@ -183,32 +182,38 @@ let }.${builtins.toString (builtins.compareVersions newVersion currentVersion)}; newVersion = getLatestVersion graalVersion; - sourcesJson = genSources newVersion javaVersion config; + sourcesJson = genSources javaVersion config; sourcesJsonPath = lib.strings.escapeShellArg ././${sourcesFilename}; - defaultNixPath = lib.strings.escapeShellArg ././default.nix; + + # versionKeyInDefaultNix String -> String + versionKeyInDefaultNix = graalVersion: + if isDev graalVersion + then "${name}-dev-version" + else "${name}-release-version"; /* updateScriptText :: String -> String -> String - Writes the json file, finds the line number of the current derivation - name, which wants to update with awk and replace the first version match - after that line. + Writes the json file and updates the version in default.nix using sed + because update-source-version does not work srcs. */ updateScriptText = newVersion: currentVersion: + if isNew newVersion currentVersion then + let + versionKey = versionKeyInDefaultNix currentVersion; + in '' echo "New version found. Updating ${currentVersion} -> ${newVersion}". - export PATH="${lib.makeBinPath [ jq gawk ]}:$PATH" + export PATH="${lib.makeBinPath [ jq gnused ]}:$PATH" jq . ${sourcesJson} > ${sourcesJsonPath} - drvName=$(awk '/${name}/{ print NR; exit }' ${defaultNixPath}) - awk -v drvName="$drvName" -i inplace \ - 'NR>drvName {sub(/${graalVersion}/, "${newVersion}")} 1' ${defaultNixPath} + sed -i 's|${versionKey} = "${currentVersion}";|${versionKey} = "${newVersion}";|' \ + ${lib.strings.escapeShellArg ././default.nix} '' else ''echo "No new version found. Skip updating."''; in -writeScript "update-graal.sh" '' - #!${runtimeShell} +writeShellScript "update-graal.sh" '' set -o errexit set -o nounset set -o pipefail diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 64bfff82d9c..5d52bf43efc 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12864,7 +12864,6 @@ with pkgs; }); graalvm11-ce = graalvmCEPackages.graalvm11-ce; graalvm17-ce = graalvmCEPackages.graalvm17-ce; - graalvm17-ce-dev = graalvmCEPackages.graalvm17-ce-dev; buildGraalvmNativeImage = callPackage ../build-support/build-graalvm-native-image { }; inherit (callPackages ../development/compilers/graalvm/enterprise-edition.nix { }) From 440d4f9ff71f173ebcc6f0c878681eac8006459c Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Fri, 1 Apr 2022 18:38:26 +0200 Subject: [PATCH 5/8] graalvmXX-ce: extract common config --- .../graalvm/community-edition/default.nix | 76 ++++++++----------- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/pkgs/development/compilers/graalvm/community-edition/default.nix b/pkgs/development/compilers/graalvm/community-edition/default.nix index d480c29317f..634844a2b20 100644 --- a/pkgs/development/compilers/graalvm/community-edition/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/default.nix @@ -9,13 +9,6 @@ let inherit Foundation; }; - commonProducts = [ - "graalvm-ce" - "native-image-installable-svm" - "ruby-installable-svm" - "wasm-installable-svm" - ]; - /* Looks a bit ugly but makes version update in the update script using sed much easier @@ -25,35 +18,45 @@ let graalvm11-ce-dev-version = "22.2.0-dev-20220331_1955"; graalvm17-ce-dev-version = "22.2.0-dev-20220331_1955"; + commonProducts = [ + "graalvm-ce" + "native-image-installable-svm" + "ruby-installable-svm" + "wasm-installable-svm" + ]; + + baseConfig = { + x86_64-darwin = { + arch = "darwin-amd64"; + products = commonProducts ++ [ "python-installable-svm" ]; + version = graalvm17-ce-release-version; + }; + x86_64-linux = { + arch = "linux-amd64"; + products = commonProducts ++ [ "python-installable-svm" ]; + version = graalvm17-ce-release-version; + }; + aarch64-darwin = { + arch = "darwin-aarch64"; + products = [ + "graalvm-ce" + "native-image-installable-svm" + ]; + version = graalvm17-ce-dev-version; + }; + }; + in { inherit mkGraal; graalvm11-ce = mkGraal rec { - config = { - x86_64-darwin = { - arch = "darwin-amd64"; - products = commonProducts ++ [ "python-installable-svm" ]; - version = graalvm11-ce-release-version; - }; - x86_64-linux = { - arch = "linux-amd64"; - products = commonProducts ++ [ "python-installable-svm" ]; - version = graalvm11-ce-release-version; - }; + config = baseConfig // { aarch64-linux = { arch = "linux-aarch64"; products = commonProducts; version = graalvm11-ce-release-version; }; - aarch64-darwin = { - arch = "darwin-aarch64"; - products = [ - "graalvm-ce" - "native-image-installable-svm" - ]; - version = graalvm11-ce-dev-version; - }; }; javaVersion = "11"; platforms = builtins.attrNames config; @@ -65,26 +68,7 @@ in # directory"/tmp/SVM-4194439592488143713"): error=0, Failed to exec spawn # helper: pid: 19865, exit value: 1" graalvm17-ce = mkGraal rec { - config = { - x86_64-darwin = { - arch = "darwin-amd64"; - products = commonProducts ++ [ "python-installable-svm" ]; - version = graalvm17-ce-release-version; - }; - x86_64-linux = { - arch = "linux-amd64"; - products = commonProducts ++ [ "python-installable-svm" ]; - version = graalvm17-ce-release-version; - }; - aarch64-darwin = { - arch = "darwin-aarch64"; - products = [ - "graalvm-ce" - "native-image-installable-svm" - ]; - version = graalvm17-ce-dev-version; - }; - }; + config = baseConfig; javaVersion = "17"; platforms = builtins.attrNames config; }; From bfc501493fd792d5e9a874db54e15d4f51dfe5b7 Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Sat, 2 Apr 2022 10:54:44 +0200 Subject: [PATCH 6/8] graalvmXX-ce: add review suggestions Co-authored-by: Thiago Kenji Okada --- .../graalvm/community-edition/mkGraal.nix | 72 +++++++++---------- .../graalvm/community-edition/update.nix | 4 +- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix index 7642f25ac2c..2986baca4e9 100644 --- a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix +++ b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix @@ -44,7 +44,7 @@ let version = platform.version; name = "graalvm${javaVersion}-ce"; sourcesFilename = "${name}-sources.json"; - sources = builtins.fromJSON (builtins.readFile (./. + "/${sourcesFilename}")); + sources = builtins.fromJSON (builtins.readFile (./${sourcesFilename})); runtimeLibraryPath = lib.makeLibraryPath ([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]); @@ -132,48 +132,40 @@ let outputs = [ "out" "lib" ]; - installPhase = - let - copyClibrariesToOut = basepath: '' - # provide libraries needed for static compilation - ${ - if useMusl then - "for f in ${musl.stdenv.cc.cc}/lib/* ${musl}/lib/* ${zlib.static}/lib/*; do" - else - "for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do" - } - ln -s $f ${basepath}/${platform.arch}/$(basename $f) - done - ''; - copyClibrariesToLib = '' - # add those libraries to $lib output too, so we can use them with - # `native-image -H:CLibraryPath=''${lib.getLib graalvm11-ce}/lib ...` and reduce - # closure size by not depending on GraalVM $out (that is much bigger) - mkdir -p $lib/lib - for f in ${glibc}/lib/*; do - ln -s $f $lib/lib/$(basename $f) - done - ''; - in - '' - # ensure that $lib/lib exists to avoid breaking builds - mkdir -p $lib/lib - # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/linux/*_md.h $out/include/ + installPhase = '' + # ensure that $lib/lib exists to avoid breaking builds + mkdir -p $lib/lib + # jni.h expects jni_md.h to be in the header search path. + ln -s $out/include/linux/*_md.h $out/include/ - # copy-paste openjdk's preFixup - # Set JAVA_HOME automatically. - mkdir -p $out/nix-support - cat > $out/nix-support/setup-hook << EOF - if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi - EOF + # copy-paste openjdk's preFixup + # Set JAVA_HOME automatically. + mkdir -p $out/nix-support + cat > $out/nix-support/setup-hook << EOF + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi + EOF + ${ + lib.optionalString (stdenv.isLinux) '' + # provide libraries needed for static compilation ${ - lib.optionalString (stdenv.isLinux) '' - ${copyClibrariesToOut "$out/lib/svm/clibraries"} - ${copyClibrariesToLib} - '' + if useMusl then + "for f in ${musl.stdenv.cc.cc}/lib/* ${musl}/lib/* ${zlib.static}/lib/*; do" + else + "for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do" } - ''; + ln -s $f $out/lib/svm/clibraries/${platform.arch}/$(basename $f) + done + + # add those libraries to $lib output too, so we can use them with + # `native-image -H:CLibraryPath=''${lib.getLib graalvmXX-ce}/lib ...` and reduce + # closure size by not depending on GraalVM $out (that is much bigger) + mkdir -p $lib/lib + for f in ${glibc}/lib/*; do + ln -s $f $lib/lib/$(basename $f) + done + '' + } + ''; dontStrip = true; diff --git a/pkgs/development/compilers/graalvm/community-edition/update.nix b/pkgs/development/compilers/graalvm/community-edition/update.nix index 724282e7b92..a687667eff5 100644 --- a/pkgs/development/compilers/graalvm/community-edition/update.nix +++ b/pkgs/development/compilers/graalvm/community-edition/update.nix @@ -183,7 +183,7 @@ let newVersion = getLatestVersion graalVersion; sourcesJson = genSources javaVersion config; - sourcesJsonPath = lib.strings.escapeShellArg ././${sourcesFilename}; + sourcesJsonPath = lib.strings.escapeShellArg ./${sourcesFilename}; # versionKeyInDefaultNix String -> String versionKeyInDefaultNix = graalVersion: @@ -208,7 +208,7 @@ let export PATH="${lib.makeBinPath [ jq gnused ]}:$PATH" jq . ${sourcesJson} > ${sourcesJsonPath} sed -i 's|${versionKey} = "${currentVersion}";|${versionKey} = "${newVersion}";|' \ - ${lib.strings.escapeShellArg ././default.nix} + ${lib.strings.escapeShellArg ./default.nix} '' else ''echo "No new version found. Skip updating."''; From 2d7d3692c125cc07954b342f84c797019c37633c Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Sat, 2 Apr 2022 11:33:07 +0200 Subject: [PATCH 7/8] graalvmXX-ce: use the release version as `defaultVersion` --- .../graalvm/community-edition/default.nix | 65 +++++++++++-------- .../graalvm11-ce-sources.json | 12 ++-- .../graalvm17-ce-sources.json | 12 ++-- .../graalvm/community-edition/mkGraal.nix | 5 +- .../graalvm/community-edition/update.nix | 15 +++-- 5 files changed, 62 insertions(+), 47 deletions(-) diff --git a/pkgs/development/compilers/graalvm/community-edition/default.nix b/pkgs/development/compilers/graalvm/community-edition/default.nix index 634844a2b20..6f42bfcc453 100644 --- a/pkgs/development/compilers/graalvm/community-edition/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/default.nix @@ -15,8 +15,8 @@ let */ graalvm11-ce-release-version = "22.0.0.2"; graalvm17-ce-release-version = "22.0.0.2"; - graalvm11-ce-dev-version = "22.2.0-dev-20220331_1955"; - graalvm17-ce-dev-version = "22.2.0-dev-20220331_1955"; + graalvm11-ce-dev-version = "22.2.0-dev-20220401_1942"; + graalvm17-ce-dev-version = "22.2.0-dev-20220401_1942"; commonProducts = [ "graalvm-ce" @@ -25,39 +25,34 @@ let "wasm-installable-svm" ]; - baseConfig = { - x86_64-darwin = { - arch = "darwin-amd64"; - products = commonProducts ++ [ "python-installable-svm" ]; - version = graalvm17-ce-release-version; - }; - x86_64-linux = { - arch = "linux-amd64"; - products = commonProducts ++ [ "python-installable-svm" ]; - version = graalvm17-ce-release-version; - }; - aarch64-darwin = { - arch = "darwin-aarch64"; - products = [ - "graalvm-ce" - "native-image-installable-svm" - ]; - version = graalvm17-ce-dev-version; - }; - }; - in { inherit mkGraal; graalvm11-ce = mkGraal rec { - config = baseConfig // { + config = { + x86_64-darwin = { + arch = "darwin-amd64"; + products = commonProducts ++ [ "python-installable-svm" ]; + }; + x86_64-linux = { + arch = "linux-amd64"; + products = commonProducts ++ [ "python-installable-svm" ]; + }; + aarch64-darwin = { + arch = "darwin-aarch64"; + products = [ + "graalvm-ce" + "native-image-installable-svm" + ]; + version = graalvm11-ce-dev-version; + }; aarch64-linux = { arch = "linux-aarch64"; products = commonProducts; - version = graalvm11-ce-release-version; }; }; + defaultVersion = graalvm11-ce-release-version; javaVersion = "11"; platforms = builtins.attrNames config; }; @@ -68,7 +63,25 @@ in # directory"/tmp/SVM-4194439592488143713"): error=0, Failed to exec spawn # helper: pid: 19865, exit value: 1" graalvm17-ce = mkGraal rec { - config = baseConfig; + config = { + x86_64-darwin = { + arch = "darwin-amd64"; + products = commonProducts ++ [ "python-installable-svm" ]; + }; + x86_64-linux = { + arch = "linux-amd64"; + products = commonProducts ++ [ "python-installable-svm" ]; + }; + aarch64-darwin = { + arch = "darwin-aarch64"; + products = [ + "graalvm-ce" + "native-image-installable-svm" + ]; + version = graalvm17-ce-dev-version; + }; + }; + defaultVersion = graalvm17-ce-release-version; javaVersion = "17"; platforms = builtins.attrNames config; }; diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json index d12df716e05..070c783d033 100644 --- a/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json +++ b/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json @@ -1,12 +1,12 @@ { "darwin-aarch64": { - "graalvm-ce|java11|22.2.0-dev-20220331_1955": { - "sha256": "a1229931575bd90256f5453ce9c880cf2286db117d4cbfec92c033813b017035", - "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220331_1955/graalvm-ce-java11-darwin-aarch64-dev.tar.gz" + "graalvm-ce|java11|22.2.0-dev-20220401_1942": { + "sha256": "c83dee740ae148486598759e44a717b09d8124e4ea50f9da1e7d49d016572b89", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220401_1942/graalvm-ce-java11-darwin-aarch64-dev.tar.gz" }, - "native-image-installable-svm|java11|22.2.0-dev-20220331_1955": { - "sha256": "813f9cc417415801e3d7d6468bb06e45487c76fe35b56202b66b6c9fa3ce3456", - "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220331_1955/native-image-installable-svm-java11-darwin-aarch64-dev.jar" + "native-image-installable-svm|java11|22.2.0-dev-20220401_1942": { + "sha256": "661311ae26bfd6c46360b9e65aabe9361dc5cd05878a404343adf16925ae78fa", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220401_1942/native-image-installable-svm-java11-darwin-aarch64-dev.jar" } }, "darwin-amd64": { diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json index ebc87f1e797..65e28b8b11c 100644 --- a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json +++ b/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json @@ -1,12 +1,12 @@ { "darwin-aarch64": { - "graalvm-ce|java17|22.2.0-dev-20220331_1955": { - "sha256": "bb217a3bd53a488ef3672920fd47b9a0d800243eb385a7ceae9ddbd4350c0b27", - "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220331_1955/graalvm-ce-java17-darwin-aarch64-dev.tar.gz" + "graalvm-ce|java17|22.2.0-dev-20220401_1942": { + "sha256": "f0409c59adbce62da7be46ab7d0e01abe5c080ef97d0b555e6c773f94dbfdecf", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220401_1942/graalvm-ce-java17-darwin-aarch64-dev.tar.gz" }, - "native-image-installable-svm|java17|22.2.0-dev-20220331_1955": { - "sha256": "eee405e704792794f45e619372e72e0343ba2caf8ace0e4c7abd8baa69e56bcf", - "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220331_1955/native-image-installable-svm-java17-darwin-aarch64-dev.jar" + "native-image-installable-svm|java17|22.2.0-dev-20220401_1942": { + "sha256": "3770dc4810d7ebae8f9ca2212e91112629096a964d3caea1667b0aaf5f70c1e0", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220401_1942/native-image-installable-svm-java17-darwin-aarch64-dev.jar" } }, "darwin-amd64": { diff --git a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix index 2986baca4e9..be4a0dc6dab 100644 --- a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix +++ b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix @@ -1,4 +1,5 @@ { javaVersion +, defaultVersion , platforms , config , useMusl ? false @@ -41,7 +42,7 @@ assert useMusl -> stdenv.isLinux; let platform = config.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); - version = platform.version; + version = platform.version or defaultVersion; name = "graalvm${javaVersion}-ce"; sourcesFilename = "${name}-sources.json"; sources = builtins.fromJSON (builtins.readFile (./${sourcesFilename})); @@ -284,7 +285,7 @@ let passthru = { home = graalvmXXX-ce; updateScript = import ./update.nix { - inherit lib writeShellScript jq sourcesFilename name config gnused; + inherit lib writeShellScript jq sourcesFilename name config gnused defaultVersion; graalVersion = version; javaVersion = "java${javaVersion}"; }; diff --git a/pkgs/development/compilers/graalvm/community-edition/update.nix b/pkgs/development/compilers/graalvm/community-edition/update.nix index a687667eff5..42c128cb4fb 100644 --- a/pkgs/development/compilers/graalvm/community-edition/update.nix +++ b/pkgs/development/compilers/graalvm/community-edition/update.nix @@ -1,5 +1,6 @@ { javaVersion , graalVersion +, defaultVersion , config , sourcesFilename , name @@ -151,12 +152,12 @@ let }; }; - # genArchProductVersionPairs :: String -> AttrSet -> [AttrSet] - genArchProductVersionList = javaVersion: archProducts: + # genArchProductVersionPairs :: String -> -> String -> AttrSet -> [AttrSet] + genArchProductVersionList = javaVersion: graalVersion: archProducts: let arch = archProducts.arch; products = archProducts.products; - javaGraalVersion = javaVersion + separator + (getLatestVersion archProducts.version); + javaGraalVersion = javaVersion + separator + (getLatestVersion (archProducts.version or graalVersion)); productJavaGraalVersionList = cartesianZipListsWith (a: b: a + separator + b) products [ javaGraalVersion ]; @@ -164,11 +165,11 @@ let cartesianZipListsWith (genUrlAndSha256) [ arch ] productJavaGraalVersionList; - # genSources :: String -> AttrSet -> Path String - genSources = javaVersion: config: + # genSources :: String -> String -> AttrSet -> Path String + genSources = javaVersion: defaultVersion: config: let archProducts = builtins.attrValues config; - sourcesList = builtins.concatMap (genArchProductVersionList javaVersion) archProducts; + sourcesList = builtins.concatMap (genArchProductVersionList javaVersion defaultVersion) archProducts; sourcesAttr = builtins.foldl' (lib.recursiveUpdate) { } sourcesList; in builtins.toFile "sources.json" (builtins.toJSON sourcesAttr); @@ -182,7 +183,7 @@ let }.${builtins.toString (builtins.compareVersions newVersion currentVersion)}; newVersion = getLatestVersion graalVersion; - sourcesJson = genSources javaVersion config; + sourcesJson = genSources javaVersion defaultVersion config; sourcesJsonPath = lib.strings.escapeShellArg ./${sourcesFilename}; # versionKeyInDefaultNix String -> String From be1232ea2ff017f22ce3d37ba0edc9667f9cb4ee Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Sat, 2 Apr 2022 13:09:33 +0200 Subject: [PATCH 8/8] graalvmXX-ce: fix relative paths --- .../development/compilers/graalvm/community-edition/mkGraal.nix | 2 +- pkgs/development/compilers/graalvm/community-edition/update.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix index be4a0dc6dab..5b20890ced1 100644 --- a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix +++ b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix @@ -45,7 +45,7 @@ let version = platform.version or defaultVersion; name = "graalvm${javaVersion}-ce"; sourcesFilename = "${name}-sources.json"; - sources = builtins.fromJSON (builtins.readFile (./${sourcesFilename})); + sources = builtins.fromJSON (builtins.readFile (./. + "/${sourcesFilename}")); runtimeLibraryPath = lib.makeLibraryPath ([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]); diff --git a/pkgs/development/compilers/graalvm/community-edition/update.nix b/pkgs/development/compilers/graalvm/community-edition/update.nix index 42c128cb4fb..191f3cb45a1 100644 --- a/pkgs/development/compilers/graalvm/community-edition/update.nix +++ b/pkgs/development/compilers/graalvm/community-edition/update.nix @@ -184,7 +184,7 @@ let newVersion = getLatestVersion graalVersion; sourcesJson = genSources javaVersion defaultVersion config; - sourcesJsonPath = lib.strings.escapeShellArg ./${sourcesFilename}; + sourcesJsonPath = lib.strings.escapeShellArg ./. + "/${sourcesFilename}"; # versionKeyInDefaultNix String -> String versionKeyInDefaultNix = graalVersion: