diff --git a/pkgs/development/compilers/graalvm/community-edition/default.nix b/pkgs/development/compilers/graalvm/community-edition/default.nix index d45b600d8401..d480c29317f0 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 9a4d31dbc93a..d12df716e05a 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 fba77c58b74a..000000000000 --- 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 b4bfde2dc50c..ebc87f1e7970 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 ea4fd89bbcbe..7642f25ac2ca 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 e9d32cf7bdeb..724282e7b92c 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 64bfff82d9c2..5d52bf43efcb 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 { })