diff --git a/maintainers/team-list.nix b/maintainers/team-list.nix index 49ddf1f10be8..4d338675c654 100644 --- a/maintainers/team-list.nix +++ b/maintainers/team-list.nix @@ -312,6 +312,19 @@ with lib.maintainers; { enableFeatureFreezePing = true; }; + graalvm-ce = { + members = [ + bandresen + hlolli + glittershark + babariviere + ericdallo + thiagokokada + ]; + scope = "Maintain GraalVM Community Edition packages."; + shortName = "GraalVM-CE"; + }; + haskell = { members = [ cdepillabout diff --git a/pkgs/build-support/build-graalvm-native-image/default.nix b/pkgs/build-support/build-graalvm-native-image/default.nix index 64c6568e1bc2..810ef52235e1 100644 --- a/pkgs/build-support/build-graalvm-native-image/default.nix +++ b/pkgs/build-support/build-graalvm-native-image/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, graalvm, glibcLocales }: +{ lib, stdenv, graalvm-ce, glibcLocales }: { name ? "${args.pname}-${args.version}" # Final executable name @@ -19,7 +19,7 @@ # XMX size of GraalVM during build , graalvmXmx ? "-J-Xmx6g" # The GraalVM derivation to use -, graalvmDrv ? graalvm +, graalvmDrv ? graalvm-ce # Locale to be used by GraalVM compiler , LC_ALL ? "en_US.UTF-8" , meta ? { } @@ -51,12 +51,14 @@ stdenv.mkDerivation (args // { disallowedReferences = [ graalvmDrv ]; + passthru = { inherit graalvmDrv; }; + meta = { # default to graalvm's platforms platforms = graalvmDrv.meta.platforms; # default to executable name mainProgram = executable; # need to have native-image-installable-svm available - broken = !(builtins.elem "native-image-installable-svm" graalvmDrv.products); + broken = !(builtins.any (p: (p.product or "") == "native-image-installable-svm") graalvmDrv.products); } // meta; }) diff --git a/pkgs/development/compilers/graalvm/community-edition/buildGraalvm.nix b/pkgs/development/compilers/graalvm/community-edition/buildGraalvm.nix new file mode 100644 index 000000000000..f8a1e515db3b --- /dev/null +++ b/pkgs/development/compilers/graalvm/community-edition/buildGraalvm.nix @@ -0,0 +1,148 @@ +{ lib +, stdenv +, alsa-lib +, autoPatchelfHook +, cairo +, cups +, fontconfig +, Foundation +, glib +, gtk3 +, gtkSupport ? stdenv.isLinux +, makeWrapper +, setJavaClassPath +, unzip +, xorg +, zlib +}: +{ javaVersion +, meta ? { } +, products ? [ ] +, ... } @ args: + +let + runtimeLibraryPath = lib.makeLibraryPath + ([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]); + mapProducts = key: default: (map (p: p.${key} or default) products); + concatProducts = key: lib.concatStringsSep "\n" (mapProducts key ""); + + graalvmXXX-ce = stdenv.mkDerivation (args // { + pname = "graalvm${javaVersion}-ce"; + + unpackPhase = '' + runHook preUnpack + + mkdir -p "$out" + + # The tarball on Linux has the following directory structure: + # + # graalvm-ce-java11-20.3.0/* + # + # while on Darwin it looks like this: + # + # graalvm-ce-java11-20.3.0/Contents/Home/* + # + # We therefor use --strip-components=1 vs 3 depending on the platform. + tar xf "$src" -C "$out" --strip-components=${ + if stdenv.isLinux then "1" else "3" + } + + # Sanity check + if [ ! -d "$out/bin" ]; then + echo "The `bin` is directory missing after extracting the graalvm" + echo "tarball, please compare the directory structure of the" + echo "tarball with what happens in the unpackPhase (in particular" + echo "with regards to the `--strip-components` flag)." + exit 1 + fi + + runHook postUnpack + ''; + + postUnpack = '' + for product in ${toString products}; do + cp -Rv $product/* $out + done + ''; + + dontStrip = true; + + nativeBuildInputs = [ unzip makeWrapper ] + ++ lib.optional stdenv.isLinux autoPatchelfHook; + + propagatedBuildInputs = [ setJavaClassPath zlib ] + ++ lib.optional stdenv.isDarwin Foundation; + + buildInputs = lib.optionals stdenv.isLinux [ + alsa-lib # libasound.so wanted by lib/libjsound.so + fontconfig + stdenv.cc.cc.lib # libstdc++.so.6 + xorg.libX11 + xorg.libXext + xorg.libXi + xorg.libXrender + xorg.libXtst + ]; + + preInstall = concatProducts "preInstall"; + postInstall = '' + # jni.h expects jni_md.h to be in the header search path. + ln -sf $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 + '' + concatProducts "postInstall"; + + preFixup = lib.optionalString (stdenv.isLinux) '' + # Find all executables in any directory that contains '/bin/' + for bin in $(find "$out" -executable -type f -wholename '*/bin/*'); do + wrapProgram "$bin" --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}" + done + '' + concatProducts "preFixup"; + postFixup = concatProducts "postFixup"; + + doInstallCheck = true; + installCheckPhase = '' + runHook preInstallCheck + + echo ${ + lib.escapeShellArg '' + public class HelloWorld { + public static void main(String[] args) { + System.out.println("Hello World"); + } + } + '' + } > HelloWorld.java + $out/bin/javac HelloWorld.java + + # run on JVM with Graal Compiler + echo "Testing GraalVM" + $out/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler HelloWorld | fgrep 'Hello World' + + ${concatProducts "installCheckPhase"} + + runHook postInstallCheck + ''; + + passthru = { + inherit products; + home = graalvmXXX-ce; + updateScript = ./update.sh; + }; + + meta = with lib; ({ + inherit platforms; + homepage = "https://www.graalvm.org/"; + description = "High-Performance Polyglot VM"; + license = with licenses; [ upl gpl2Classpath bsd3 ]; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + mainProgram = "java"; + maintainers = with maintainers; teams.graalvm-ce.members ++ [ ]; + } // meta); + }); +in graalvmXXX-ce diff --git a/pkgs/development/compilers/graalvm/community-edition/buildGraalvmProduct.nix b/pkgs/development/compilers/graalvm/community-edition/buildGraalvmProduct.nix new file mode 100644 index 000000000000..e4b55cc756b7 --- /dev/null +++ b/pkgs/development/compilers/graalvm/community-edition/buildGraalvmProduct.nix @@ -0,0 +1,73 @@ +{ lib +, stdenv +, autoPatchelfHook +, makeWrapper +, perl +, unzip +, zlib +}: +{ product +, javaVersion +, extraNativeBuildInputs ? [ ] +, extraBuildInputs ? [ ] +, meta ? { } +, passthru ? { } +, ... } @ args: + +stdenv.mkDerivation (args // { + pname = "${product}-java${javaVersion}"; + + nativeBuildInputs = [ perl unzip makeWrapper ] + ++ lib.optional stdenv.isLinux autoPatchelfHook + ++ extraNativeBuildInputs; + + buildInputs = [ + stdenv.cc.cc.lib # libstdc++.so.6 + zlib + ] ++ extraBuildInputs; + + unpackPhase = '' + runHook preUnpack + + unpack_jar() { + local jar="$1" + unzip -q -o "$jar" -d "$out" + perl -ne 'use File::Path qw(make_path); + use File::Basename qw(dirname); + if (/^(.+) = (.+)$/) { + make_path dirname("$ENV{out}/$1"); + symlink $2, "$ENV{out}/$1"; + }' "$out/META-INF/symlinks" + perl -ne 'if (/^(.+) = ([r-])([w-])([x-])([r-])([w-])([x-])([r-])([w-])([x-])$/) { + my $mode = ($2 eq 'r' ? 0400 : 0) + ($3 eq 'w' ? 0200 : 0) + ($4 eq 'x' ? 0100 : 0) + + ($5 eq 'r' ? 0040 : 0) + ($6 eq 'w' ? 0020 : 0) + ($7 eq 'x' ? 0010 : 0) + + ($8 eq 'r' ? 0004 : 0) + ($9 eq 'w' ? 0002 : 0) + ($10 eq 'x' ? 0001 : 0); + chmod $mode, "$ENV{out}/$1"; + }' "$out/META-INF/permissions" + rm -rf "$out/META-INF" + } + + unpack_jar "$src" + + runHook postUnpack + ''; + + dontInstall = true; + dontBuild = true; + dontStrip = true; + # installCheckPhase is going to run in GraalVM main derivation (see buildGraalvm.nix) + # to make sure that it has everything it needs to run correctly. + # Other hooks like fixupPhase/installPhase are also going to run there for the + # same reason. + doInstallCheck = false; + + passthru = { inherit product; } // passthru; + + meta = with lib; ({ + homepage = "https://www.graalvm.org/"; + description = "High-Performance Polyglot VM (Product: ${product})"; + license = with licenses; [ upl gpl2Classpath bsd3 ]; + sourceProvenance = with sourceTypes; [ binaryNativeCode ]; + maintainers = with maintainers; teams.graalvm-ce.members ++ [ ]; + } // meta); +}) diff --git a/pkgs/development/compilers/graalvm/community-edition/default.nix b/pkgs/development/compilers/graalvm/community-edition/default.nix index 17ecd5060ba2..0f9cec44f18f 100644 --- a/pkgs/development/compilers/graalvm/community-edition/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/default.nix @@ -1,75 +1,52 @@ -{ callPackage, Foundation }: -/* - Add new graal versions and products here and then see update.nix on how to - generate the sources. -*/ +{ lib +, stdenv +, callPackage +, fetchurl +, Foundation +}: let - mkGraal = opts: callPackage (import ./mkGraal.nix opts) { - inherit Foundation; + buildGraalvm = callPackage ./buildGraalvm.nix { inherit Foundation; }; + buildGraalvmProduct = callPackage ./buildGraalvmProduct.nix { }; + javaPlatform = { + "aarch64-linux" = "linux-aarch64"; + "x86_64-linux" = "linux-amd64"; + "aarch64-darwin" = "darwin-aarch64"; + "x86_64-darwin" = "darwin-amd64"; }; - - /* - Looks a bit ugly but makes version update in the update script using sed - much easier - - Don't change these values! They will be updated by the update script, see ./update.nix. - */ - graalvm11-ce-release-version = "22.3.0"; - graalvm17-ce-release-version = "22.3.0"; - - products = [ - "graalvm-ce" - "native-image-installable-svm" - ]; + javaPlatformVersion = javaVersion: + "${javaVersion}-${javaPlatform.${stdenv.system} or (throw "Unsupported platform: ${stdenv.system}")}"; + source = product: javaVersion: (import ./hashes.nix).${product}.${javaPlatformVersion javaVersion}; in -{ - inherit mkGraal; +rec { + inherit buildGraalvm buildGraalvmProduct; - graalvm11-ce = mkGraal rec { - config = { - x86_64-darwin = { - inherit products; - arch = "darwin-amd64"; - }; - x86_64-linux = { - inherit products; - arch = "linux-amd64"; - }; - aarch64-darwin = { - inherit products; - arch = "darwin-aarch64"; - }; - aarch64-linux = { - inherit products; - arch = "linux-aarch64"; - }; - }; - defaultVersion = graalvm11-ce-release-version; + graalvm11-ce = buildGraalvm rec { + version = "22.3.1"; javaVersion = "11"; + src = fetchurl (source "graalvm-ce" javaVersion); + meta.platforms = builtins.attrNames javaPlatform; + products = [ native-image-installable-svm-java11 ]; }; - graalvm17-ce = mkGraal rec { - config = { - x86_64-darwin = { - inherit products; - arch = "darwin-amd64"; - }; - x86_64-linux = { - inherit products; - arch = "linux-amd64"; - }; - aarch64-darwin = { - inherit products; - arch = "darwin-aarch64"; - }; - aarch64-linux = { - inherit products; - arch = "linux-aarch64"; - }; - }; - defaultVersion = graalvm17-ce-release-version; + native-image-installable-svm-java11 = callPackage ./native-image-installable-svm.nix rec { + javaVersion = "11"; + version = "22.3.1"; + src = fetchurl (source "native-image-installable-svm" javaVersion); + }; + + graalvm17-ce = buildGraalvm rec { + version = "22.3.1"; javaVersion = "17"; + src = fetchurl (source "graalvm-ce" javaVersion); + meta.platforms = builtins.attrNames javaPlatform; + products = [ native-image-installable-svm-java17 ]; + }; + + native-image-installable-svm-java17 = callPackage ./native-image-installable-svm.nix rec { + javaVersion = "17"; + version = "22.3.1"; + src = fetchurl (source "native-image-installable-svm" javaVersion); }; } diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json b/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json deleted file mode 100644 index c9145e9654f8..000000000000 --- a/pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "darwin-aarch64": { - "graalvm-ce|java11|22.3.0": { - "sha256": "c9657e902c2ba674931c3cf233a38c4de3d5186ae5d70452f9df75ac0c4cacff", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java11-darwin-aarch64-22.3.0.tar.gz" - }, - "native-image-installable-svm|java11|22.3.0": { - "sha256": "dd9f91a970c7270b3f7fe8e711ba1ae081d34ed433c75f2bb0459aaf19e0fbe7", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/native-image-installable-svm-java11-darwin-aarch64-22.3.0.jar" - } - }, - "darwin-amd64": { - "graalvm-ce|java11|22.3.0": { - "sha256": "b8b39d6a3e3a9ed6348c2776ff071fc64ca90f98999ee846e6ca7e5fdc746a8b", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java11-darwin-amd64-22.3.0.tar.gz" - }, - "native-image-installable-svm|java11|22.3.0": { - "sha256": "00fe13c42813f581955eb35370bb8409ba17c7fdc83971d000baf695be2a0cb5", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/native-image-installable-svm-java11-darwin-amd64-22.3.0.jar" - } - }, - "linux-aarch64": { - "graalvm-ce|java11|22.3.0": { - "sha256": "c6646149dad486a0b02c5fc10649786240f275efda65aa14a25d01d2f5bafe15", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java11-linux-aarch64-22.3.0.tar.gz" - }, - "native-image-installable-svm|java11|22.3.0": { - "sha256": "0886e214f03f8a44962ecab459a94afb5c6a0f20910cb128d9ff775f4a9e4162", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/native-image-installable-svm-java11-linux-aarch64-22.3.0.jar" - } - }, - "linux-amd64": { - "graalvm-ce|java11|22.3.0": { - "sha256": "d4200bcc43e5ad4e6949c1b1edc1e59f63066e3a2280d5bd82d0c9b1d67c3f2c", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java11-linux-amd64-22.3.0.tar.gz" - }, - "native-image-installable-svm|java11|22.3.0": { - "sha256": "17843f92dc9de74b161a63c52cc2a4597e5472cf3f6f6d71930fb655b35f9208", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/native-image-installable-svm-java11-linux-amd64-22.3.0.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 deleted file mode 100644 index dc2da450b699..000000000000 --- a/pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "darwin-aarch64": { - "graalvm-ce|java17|22.3.0": { - "sha256": "dfc0c8998b8d00fcca87ef1c866c6e4985fd20b0beba3021f9677f9b166dfaf8", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java17-darwin-aarch64-22.3.0.tar.gz" - }, - "native-image-installable-svm|java17|22.3.0": { - "sha256": "b6e44cb03f560bb43db1fd0aa862af36ba1df6717765920d91c18519712adfe9", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/native-image-installable-svm-java17-darwin-aarch64-22.3.0.jar" - } - }, - "darwin-amd64": { - "graalvm-ce|java17|22.3.0": { - "sha256": "422cd6abecfb8b40238460c09c42c5a018cb92fab4165de9691be2e3c3d0e8d1", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java17-darwin-amd64-22.3.0.tar.gz" - }, - "native-image-installable-svm|java17|22.3.0": { - "sha256": "9ce13874e62877d3bbe3faa4a57fbbffc766fdc8191971e7b25de0226fe86598", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/native-image-installable-svm-java17-darwin-amd64-22.3.0.jar" - } - }, - "linux-aarch64": { - "graalvm-ce|java17|22.3.0": { - "sha256": "e27249d9eef4504deb005cf14c6a028aad1adfa37209e12e9d7407710c08ed90", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java17-linux-aarch64-22.3.0.tar.gz" - }, - "native-image-installable-svm|java17|22.3.0": { - "sha256": "d5b833c44d37fbe4df75906f73144e2db01e683bca3386fe185f4abbc8fbc798", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/native-image-installable-svm-java17-linux-aarch64-22.3.0.jar" - } - }, - "linux-amd64": { - "graalvm-ce|java17|22.3.0": { - "sha256": "3473d8b3b1bc682e95adfb3ac1d9a59b51b0f43e2b752f2a5b550e4ebfa2fd17", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java17-linux-amd64-22.3.0.tar.gz" - }, - "native-image-installable-svm|java17|22.3.0": { - "sha256": "d1f5c58b65c57ad8a0c7da0c4569ce815ebf1ae503b0741ba1facf27b816d398", - "url": "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/native-image-installable-svm-java17-linux-amd64-22.3.0.jar" - } - } -} diff --git a/pkgs/development/compilers/graalvm/community-edition/hashes.nix b/pkgs/development/compilers/graalvm/community-edition/hashes.nix new file mode 100644 index 000000000000..c0353e033ae2 --- /dev/null +++ b/pkgs/development/compilers/graalvm/community-edition/hashes.nix @@ -0,0 +1,71 @@ +# Generated by pkgs/development/compilers/graalvm/community-edition/update.sh script +{ + "native-image-installable-svm" = { + "11-linux-aarch64" = { + sha256 = "0z9rbmci6yz7f7mqd3xzsxc5ih4hq72lyzqfchan7fr6mh38d6gw"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/native-image-installable-svm-java11-linux-aarch64-22.3.1.jar"; + }; + "17-linux-aarch64" = { + sha256 = "03v20fc9famlnbrznpasnd5gdl5k9nl4dlj3pp6bad4y6l7rqnx5"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/native-image-installable-svm-java17-linux-aarch64-22.3.1.jar"; + }; + "11-linux-amd64" = { + sha256 = "1yb7kpbs7hrzlysvrqjzgfz678p1hbg6237jzb35zmwdaczav51n"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/native-image-installable-svm-java11-linux-amd64-22.3.1.jar"; + }; + "17-linux-amd64" = { + sha256 = "00fbyqsj4xj9ay8bki1190lf59bgrzvla8lzzq51p53a1bdrhhmv"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/native-image-installable-svm-java17-linux-amd64-22.3.1.jar"; + }; + "11-darwin-aarch64" = { + sha256 = "1kaqvkbhj3iifq6asyrpy225a89y7klzbh7an1ycnvc2hvqkv4nz"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/native-image-installable-svm-java11-darwin-aarch64-22.3.1.jar"; + }; + "17-darwin-aarch64" = { + sha256 = "09l7x4x8yanq55v6y6wpfx94mvsq1bpbnihknjc6dnq3vcrci77n"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/native-image-installable-svm-java17-darwin-aarch64-22.3.1.jar"; + }; + "11-darwin-amd64" = { + sha256 = "036w9dmdcs46kmjqr3086mg389fgr3h1zysavfq8cbh199x0ibia"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/native-image-installable-svm-java11-darwin-amd64-22.3.1.jar"; + }; + "17-darwin-amd64" = { + sha256 = "1hvjfvcn878bzvi944v3x23sby72hbfvg5s3zzspyc37l5cdpqi3"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/native-image-installable-svm-java17-darwin-amd64-22.3.1.jar"; + }; + }; + "graalvm-ce" = { + "11-linux-aarch64" = { + sha256 = "1g4a3z9993pq52j3jf25pbcq9rvl8jz1yar8c859jw5chaf3ysml"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-java11-linux-aarch64-22.3.1.tar.gz"; + }; + "17-linux-aarch64" = { + sha256 = "06288dwbql943nii74i9mngzb38h2nzrxzzgs346mgk2965gwm59"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-java17-linux-aarch64-22.3.1.tar.gz"; + }; + "11-linux-amd64" = { + sha256 = "1f6xkdnxn6xsm24sqw24rsca72wm7v6q96m23l5fng5ym0jpfm2m"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-java11-linux-amd64-22.3.1.tar.gz"; + }; + "17-linux-amd64" = { + sha256 = "0aci9i28rq5nk2qya9dcg5hxr3sgsbv7f5x8679hrjrqmrclmkrs"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-java17-linux-amd64-22.3.1.tar.gz"; + }; + "11-darwin-aarch64" = { + sha256 = "0cbcm9d211m4b6g1bkpfksma917lzqkl4kx38vm1nrwjkll357y5"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-java11-darwin-aarch64-22.3.1.tar.gz"; + }; + "17-darwin-aarch64" = { + sha256 = "1qbw3hlmqcrmd70xk56463scdxr50n66z2n3c24h68qlwwlpqc73"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-java17-darwin-aarch64-22.3.1.tar.gz"; + }; + "11-darwin-amd64" = { + sha256 = "0a12rzf99x5l29f6bwm6myk18dgnrx2c9rwmii2pm864y7azlnij"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-java11-darwin-amd64-22.3.1.tar.gz"; + }; + "17-darwin-amd64" = { + sha256 = "02lclv2j3v850izh84wdvksi3d3xmgpfl7x85vzifhgsvagm6sz4"; + url = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.1/graalvm-ce-java17-darwin-amd64-22.3.1.tar.gz"; + }; + }; +} diff --git a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix deleted file mode 100644 index 023fc81474ef..000000000000 --- a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix +++ /dev/null @@ -1,346 +0,0 @@ -{ - # An attrset describing each platform configuration. All values are extract - # from the GraalVM releases available on - # https://github.com/graalvm/graalvm-ce-builds/releases - # Example: - # config = { - # x86_64-linux = { - # # List of products that will be included in the GraalVM derivation - # # See `with{NativeImage,Ruby,Python,WASM,*}Svm` variables for the - # # available values - # products = [ "graalvm-ce" "native-image-installable-svm" ]; - # # GraalVM arch, not to be confused with the nix platform - # arch = "linux-amd64"; - # # GraalVM version - # version = "22.0.0.2"; - # }; - # } - config - # GraalVM version that will be used unless overridden by `config..version` -, defaultVersion - # Java version used by GraalVM -, javaVersion - # Platforms were GraalVM will be allowed to build (i.e. `meta.platforms`) -, platforms ? builtins.attrNames config - # If set to true, update script will (re-)generate the sources file even if - # there are no updates available -, forceUpdate ? false - # Path for the sources file that will be used - # See `update.nix` file for a description on how this file works -, sourcesPath ? ./. + "/graalvm${javaVersion}-ce-sources.json" -}: - -{ stdenv -, lib -, autoPatchelfHook -, fetchurl -, makeWrapper -, setJavaClassPath -, writeShellScriptBin - # minimum dependencies -, alsa-lib -, fontconfig -, Foundation -, freetype -, glibc -, openssl -, perl -, unzip -, xorg -, zlib - # runtime dependencies -, binutils -, cups -, gcc -, musl - # runtime dependencies for GTK+ Look and Feel -, gtkSupport ? stdenv.isLinux -, cairo -, glib - # updateScript deps -, gnused -, gtk3 -, jq -, writeShellScript - # Use musl instead of glibc to allow true static builds in GraalVM's - # Native Image (i.e.: `--static --libc=musl`). This will cause glibc static - # builds to fail, so it should be used with care -, useMusl ? false - # Extra libraries to be included in native-image using '-H:CLibraryPath' flag -, extraCLibs ? [ ] -}: - -assert useMusl -> stdenv.isLinux; - -let - platform = config.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); - version = platform.version or defaultVersion; - name = "graalvm${javaVersion}-ce"; - sources = builtins.fromJSON (builtins.readFile sourcesPath); - - cLibs = [ glibc zlib.static ] - ++ lib.optionals (!useMusl) [ glibc.static ] - ++ lib.optionals useMusl [ musl ] - ++ extraCLibs; - - runtimeLibraryPath = lib.makeLibraryPath - ([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]); - - runtimeDependencies = lib.makeBinPath ([ - binutils - stdenv.cc - ] ++ lib.optionals useMusl [ - (lib.getDev musl) - # GraalVM 21.3.0+ expects musl-gcc as -musl-gcc - (writeShellScriptBin "${stdenv.hostPlatform.system}-musl-gcc" ''${lib.getDev musl}/bin/musl-gcc "$@"'') - ]); - - withNativeImageSvm = builtins.elem "native-image-installable-svm" platform.products; - withRubySvm = builtins.elem "ruby-installable-svm" platform.products; - withPythonSvm = builtins.elem "python-installable-svm" platform.products; - withWasmSvm = builtins.elem "wasm-installable-svm" platform.products; - - graalvmXXX-ce = stdenv.mkDerivation rec { - inherit version; - pname = name; - - srcs = map fetchurl (builtins.attrValues sources.${platform.arch}); - - buildInputs = lib.optionals stdenv.isLinux [ - alsa-lib # libasound.so wanted by lib/libjsound.so - fontconfig - freetype - stdenv.cc.cc.lib # libstdc++.so.6 - xorg.libX11 - xorg.libXext - xorg.libXi - xorg.libXrender - xorg.libXtst - zlib - ] ++ lib.optionals withRubySvm [ - openssl # libssl.so wanted by languages/ruby/lib/mri/openssl.so - ]; - - nativeBuildInputs = [ unzip perl makeWrapper ] - ++ lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook; - - unpackPhase = '' - runHook preUnpack - - unpack_jar() { - jar=$1 - unzip -q -o $jar -d $out - perl -ne 'use File::Path qw(make_path); - use File::Basename qw(dirname); - if (/^(.+) = (.+)$/) { - make_path dirname("$ENV{out}/$1"); - system "ln -s $2 $ENV{out}/$1"; - }' $out/META-INF/symlinks - perl -ne 'if (/^(.+) = ([r-])([w-])([x-])([r-])([w-])([x-])([r-])([w-])([x-])$/) { - my $mode = ($2 eq 'r' ? 0400 : 0) + ($3 eq 'w' ? 0200 : 0) + ($4 eq 'x' ? 0100 : 0) + - ($5 eq 'r' ? 0040 : 0) + ($6 eq 'w' ? 0020 : 0) + ($7 eq 'x' ? 0010 : 0) + - ($8 eq 'r' ? 0004 : 0) + ($9 eq 'w' ? 0002 : 0) + ($10 eq 'x' ? 0001 : 0); - chmod $mode, "$ENV{out}/$1"; - }' $out/META-INF/permissions - rm -rf $out/META-INF - } - - mkdir -p $out - arr=($srcs) - - # The tarball on Linux has the following directory structure: - # - # graalvm-ce-java11-20.3.0/* - # - # while on Darwin it looks like this: - # - # graalvm-ce-java11-20.3.0/Contents/Home/* - # - # We therefor use --strip-components=1 vs 3 depending on the platform. - tar xf ''${arr[0]} -C $out --strip-components=${ - if stdenv.isLinux then "1" else "3" - } - - # Sanity check - if [ ! -d $out/bin ]; then - echo "The `bin` is directory missing after extracting the graalvm" - echo "tarball, please compare the directory structure of the" - echo "tarball with what happens in the unpackPhase (in particular" - echo "with regards to the `--strip-components` flag)." - exit 1 - fi - - for jar in "''${arr[@]:1}"; do - unpack_jar "$jar" - done - - runHook postUnpack - ''; - - installPhase = '' - runHook preInstall - - # 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 - ${ - # Wrap native-image binary to pass -H:CLibraryPath flag and find glibc - lib.optionalString (withNativeImageSvm && stdenv.isLinux) '' - wrapProgram $out/bin/native-image \ - ${lib.concatStringsSep " " - (map (l: "--add-flags '-H:CLibraryPath=${l}/lib'") cLibs)} - '' - } - - runHook postInstall - ''; - - dontStrip = true; - - # Workaround for libssl.so.10 wanted by TruffleRuby - # Resulting TruffleRuby cannot use `openssl` library. - autoPatchelfIgnoreMissingDeps = withRubySvm && stdenv.isDarwin; - - preFixup = lib.optionalString (stdenv.isLinux) '' - # Find all executables in any directory that contains '/bin/' - for bin in $(find "$out" -executable -type f -wholename '*/bin/*'); do - wrapProgram "$bin" \ - --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}" \ - --prefix PATH : "${runtimeDependencies}" - done - - find "$out" -name libfontmanager.so -exec \ - patchelf --add-needed libfontconfig.so {} \; - - ${ - lib.optionalString withRubySvm '' - # Workaround for libssl.so.10/libcrypto.so.10 wanted by TruffleRuby - patchelf $out/languages/ruby/lib/mri/openssl.so \ - --replace-needed libssl.so.10 libssl.so \ - --replace-needed libcrypto.so.10 libcrypto.so - '' - } - ''; - - # $out/bin/native-image needs zlib to build native executables. - propagatedBuildInputs = [ setJavaClassPath zlib ] ++ - # On Darwin native-image calls clang and it - # tries to include , - # and Interactive Ruby (irb) requires OpenSSL - # headers. - lib.optionals stdenv.hostPlatform.isDarwin [ Foundation openssl ]; - - doInstallCheck = true; - installCheckPhase = '' - runHook preInstallCheck - - echo ${ - lib.escapeShellArg '' - public class HelloWorld { - public static void main(String[] args) { - System.out.println("Hello World"); - } - } - '' - } > HelloWorld.java - $out/bin/javac HelloWorld.java - - # run on JVM with Graal Compiler - echo "Testing GraalVM" - $out/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler HelloWorld | fgrep 'Hello World' - - ${ - lib.optionalString withNativeImageSvm '' - echo "Ahead-Of-Time compilation" - $out/bin/native-image -H:-CheckToolchain -H:+ReportExceptionStackTraces HelloWorld - ./helloworld | fgrep 'Hello World' - '' - } - - ${# --static flag doesn't work for darwin - lib.optionalString (withNativeImageSvm && stdenv.isLinux && !useMusl) '' - echo "Ahead-Of-Time compilation with -H:+StaticExecutableWithDynamicLibC" - $out/bin/native-image -H:+StaticExecutableWithDynamicLibC HelloWorld - ./helloworld | fgrep 'Hello World' - - echo "Ahead-Of-Time compilation with --static" - $out/bin/native-image --static HelloWorld - ./helloworld | fgrep 'Hello World' - '' - } - - ${# --static flag doesn't work for darwin - lib.optionalString (withNativeImageSvm && stdenv.isLinux && useMusl) '' - echo "Ahead-Of-Time compilation with --static and --libc=musl" - $out/bin/native-image --libc=musl --static HelloWorld - ./helloworld | fgrep 'Hello World' - '' - } - - ${ - lib.optionalString withWasmSvm '' - echo "Testing Jshell" - echo '1 + 1' | $out/bin/jshell - '' - } - - ${ - lib.optionalString withPythonSvm '' - echo "Testing GraalPython" - $out/bin/graalpython -c 'print(1 + 1)' - echo '1 + 1' | $out/bin/graalpython - '' - } - - ${ - lib.optionalString withRubySvm '' - echo "Testing TruffleRuby" - # 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 - + lib.optionalString false '' - echo '1 + 1' | $out/bin/irb - '' - } - - runHook postInstallCheck - ''; - - passthru = { - inherit (platform) products; - home = graalvmXXX-ce; - updateScript = import ./update.nix { - inherit config defaultVersion forceUpdate gnused jq lib name sourcesPath writeShellScript; - graalVersion = version; - javaVersion = "java${javaVersion}"; - }; - }; - - meta = with lib; { - inherit platforms; - homepage = "https://www.graalvm.org/"; - description = "High-Performance Polyglot VM"; - license = with licenses; [ upl gpl2Classpath bsd3 ]; - sourceProvenance = with sourceTypes; [ binaryNativeCode ]; - mainProgram = "java"; - maintainers = with maintainers; [ - bandresen - hlolli - glittershark - babariviere - ericdallo - thiagokokada - ]; - }; - }; -in -graalvmXXX-ce diff --git a/pkgs/development/compilers/graalvm/community-edition/native-image-installable-svm.nix b/pkgs/development/compilers/graalvm/community-edition/native-image-installable-svm.nix new file mode 100644 index 000000000000..393a226df19c --- /dev/null +++ b/pkgs/development/compilers/graalvm/community-edition/native-image-installable-svm.nix @@ -0,0 +1,58 @@ +{ lib +, stdenv +, graalvmCEPackages +, gcc +, glibc +, javaVersion +, musl +, src +, version +, writeShellScriptBin +, zlib +, useMusl ? false +, extraCLibs ? [ ] +}: + +assert useMusl -> stdenv.isLinux; +let + cLibs = [ glibc zlib.static ] + ++ lib.optionals (!useMusl) [ glibc.static ] + ++ lib.optionals useMusl [ musl ] + ++ extraCLibs; + # GraalVM 21.3.0+ expects musl-gcc as -musl-gcc + musl-gcc = (writeShellScriptBin "${stdenv.hostPlatform.system}-musl-gcc" ''${lib.getDev musl}/bin/musl-gcc "$@"''); + binPath = lib.makeBinPath ([ gcc ] ++ lib.optionals useMusl [ musl-gcc ]); +in +graalvmCEPackages.buildGraalvmProduct rec { + inherit src javaVersion version; + product = "native-image-installable-svm"; + + postInstall = lib.optionalString stdenv.isLinux '' + wrapProgram $out/bin/native-image \ + --prefix PATH : ${binPath} \ + ${lib.concatStringsSep " " + (map (l: "--add-flags '-H:CLibraryPath=${l}/lib'") cLibs)} + ''; + + installCheckPhase = '' + echo "Ahead-Of-Time compilation" + $out/bin/native-image -H:-CheckToolchain -H:+ReportExceptionStackTraces HelloWorld + ./helloworld | fgrep 'Hello World' + + ${lib.optionalString (stdenv.isLinux && !useMusl) '' + echo "Ahead-Of-Time compilation with -H:+StaticExecutableWithDynamicLibC" + $out/bin/native-image -H:+StaticExecutableWithDynamicLibC HelloWorld + ./helloworld | fgrep 'Hello World' + + echo "Ahead-Of-Time compilation with --static" + $out/bin/native-image --static HelloWorld + ./helloworld | fgrep 'Hello World' + ''} + + ${lib.optionalString (stdenv.isLinux && useMusl) '' + echo "Ahead-Of-Time compilation with --static and --libc=musl" + $out/bin/native-image --static HelloWorld --libc=musl + ./helloworld | fgrep 'Hello World' + ''} + ''; +} diff --git a/pkgs/development/compilers/graalvm/community-edition/update.nix b/pkgs/development/compilers/graalvm/community-edition/update.nix deleted file mode 100644 index 8bb31c792dda..000000000000 --- a/pkgs/development/compilers/graalvm/community-edition/update.nix +++ /dev/null @@ -1,227 +0,0 @@ -{ config -, defaultVersion -, forceUpdate -, gnused -, graalVersion -, javaVersion -, jq -, lib -, name -, sourcesPath -, writeShellScript -}: - -/* - 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 - separator = "|"; - - # 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: - { - "aarch64-linux" = "linux-aarch64"; - "aarch64-darwin" = "darwin-aarch64"; - "x86_64-linux" = "linux-amd64"; - "x86_64-darwin" = "darwin-amd64"; - }.${nixArchString}; - - - # 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"; - "js-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"; - "js-installable-svm" = "https://github.com/oracle/graaljs/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}"; - - # getReleaseUrl :: AttrSet -> String - 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 isDev 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 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'; - - # 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 separator 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; - }; - }; - }; - - # genArchProductVersionPairs :: String -> -> String -> AttrSet -> [AttrSet] - genArchProductVersionList = javaVersion: graalVersion: archProducts: - let - arch = archProducts.arch; - products = archProducts.products; - javaGraalVersion = javaVersion + separator + (getLatestVersion (archProducts.version or graalVersion)); - productJavaGraalVersionList = - cartesianZipListsWith (a: b: a + separator + b) - products [ javaGraalVersion ]; - in - cartesianZipListsWith (genUrlAndSha256) [ arch ] productJavaGraalVersionList; - - - # genSources :: String -> String -> AttrSet -> Path String - genSources = javaVersion: defaultVersion: config: - let - archProducts = builtins.attrValues config; - sourcesList = builtins.concatMap (genArchProductVersionList javaVersion defaultVersion) archProducts; - sourcesAttr = builtins.foldl' (lib.recursiveUpdate) { } sourcesList; - in - builtins.toFile "sources.json" (builtins.toJSON sourcesAttr); - - # isNew :: String -> String -> Boolean - isNew = newVersion: currentVersion: - { - "-1" = false; - "0" = false; - "1" = true; - }.${builtins.toString (builtins.compareVersions newVersion currentVersion)}; - - newVersion = getLatestVersion graalVersion; - sourcesJson = genSources javaVersion defaultVersion config; - sourcesJsonPath = lib.strings.escapeShellArg sourcesPath; - - # versionKeyInDefaultNix String -> String - versionKeyInDefaultNix = graalVersion: - if isDev graalVersion - then "${name}-dev-version" - else "${name}-release-version"; - - /* - updateScriptText :: String -> String -> String - 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 (forceUpdate || (isNew newVersion currentVersion)) - then - let - versionKey = versionKeyInDefaultNix currentVersion; - in - '' - echo "New version found. Updating ${currentVersion} -> ${newVersion}". - export PATH="${lib.makeBinPath [ jq gnused ]}:$PATH" - jq . ${sourcesJson} > ${sourcesJsonPath} - sed -i 's|${versionKey} = "${currentVersion}";|${versionKey} = "${newVersion}";|' \ - ${lib.strings.escapeShellArg ./default.nix} - '' - else ''echo "No new version found. Skip updating."''; - -in -writeShellScript "update-graal.sh" '' - set -o errexit - set -o nounset - set -o pipefail - - ${updateScriptText newVersion graalVersion} -'' diff --git a/pkgs/development/compilers/graalvm/community-edition/update.sh b/pkgs/development/compilers/graalvm/community-edition/update.sh new file mode 100755 index 000000000000..476bd754ad50 --- /dev/null +++ b/pkgs/development/compilers/graalvm/community-edition/update.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env nix-shell +#!nix-shell -p coreutils curl.out nix jq gnused -i bash + +set -eou pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")" +tmpfile="$(mktemp --suffix=.nix)" + +info() { echo "[INFO] $*"; } + +echo_file() { echo "$@" >> "$tmpfile"; } + +verlte() { + [ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ] +} + +readonly nixpkgs=../../../../.. + +readonly current_version="$(nix-instantiate "$nixpkgs" --eval --strict -A graalvm-ce.version | tr -d \")" + +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 + +info "Current version: $current_version" +info "New version: $new_version" +if verlte "$new_version" "$current_version"; then + info "graalvm-ce $current_version is up-to-date." + [[ -z "${FORCE:-}" ]] && exit 0 +else + info "graalvm-ce $current_version is out-of-date. Updating..." +fi + +declare -r -A products_urls=( + [graalvm-ce]="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/graalvm-ce-java@platform@-${new_version}.tar.gz" + [native-image-installable-svm]="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/native-image-installable-svm-java@platform@-${new_version}.jar" + # [ruby-installable-svm]="https://github.com/oracle/truffleruby/releases/download/vm-${new_version}/ruby-installable-svm-java@platform@-${new_version}.jar" + # [wasm-installable-svm]="https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/wasm-installable-svm-java@platform@-${new_version}.jar" + # [python-installable-svm]="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-aarch64" + "17-darwin-aarch64" + "11-darwin-amd64" + "17-darwin-amd64" +) + +info "Generating hashes.nix file for 'graalvm-ce' $new_version. This will take a while..." + +# Indentation of `echo_file` function is on purpose to make it easier to visualize the output +echo_file "# Generated by $0 script" +echo_file "{" +for product in "${!products_urls[@]}"; do + url="${products_urls["${product}"]}" +echo_file " \"$product\" = {" + for platform in "${platforms[@]}"; do + if hash="$(nix-prefetch-url "${url//@platform@/$platform}")"; then +echo_file " \"$platform\" = {" +echo_file " sha256 = \"$hash\";" +echo_file " url = \"${url//@platform@/${platform}}\";" +echo_file " };" + fi + done +echo_file " };" +done +echo_file "}" + +info "Updating graalvm-ce version..." +# update-source-version does not work here since it expects src attribute +sed "s|$current_version|$new_version|" -i default.nix + +info "Moving the temporary file to hashes.nix" +mv "$tmpfile" hashes.nix + +info "Done!" diff --git a/pkgs/development/tools/bbin/default.nix b/pkgs/development/tools/bbin/default.nix index 606633fd3a1a..d0956845092f 100644 --- a/pkgs/development/tools/bbin/default.nix +++ b/pkgs/development/tools/bbin/default.nix @@ -29,7 +29,7 @@ stdenvNoCC.mkDerivation rec { mkdir -p $out/share cp -r docs $out/share/docs wrapProgram $out/bin/bbin \ - --prefix PATH : "${lib.makeBinPath [ babashka graalvm17-ce ]}" + --prefix PATH : "${lib.makeBinPath [ babashka babashka.graalvmDrv ]}" runHook postInstall ''; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8823c647a5a8..a143d5bddf97 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15013,11 +15013,10 @@ with pkgs; recurseIntoAttrs (callPackage ../development/compilers/graalvm/community-edition { inherit (darwin.apple_sdk.frameworks) Foundation; }); + graalvm-ce = graalvm11-ce; graalvm11-ce = graalvmCEPackages.graalvm11-ce; graalvm17-ce = graalvmCEPackages.graalvm17-ce; - buildGraalvmNativeImage = callPackage ../build-support/build-graalvm-native-image { - graalvm = graalvm11-ce; - }; + buildGraalvmNativeImage = callPackage ../build-support/build-graalvm-native-image { }; openshot-qt = libsForQt5.callPackage ../applications/video/openshot-qt { };