diff --git a/neo-tree filesystem [1] b/neo-tree filesystem [1] new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/pkgs/by-name/cq/cq/package.nix b/pkgs/by-name/cq/cq/package.nix index 82fc31a7bbdd3..25c2b9c94656b 100644 --- a/pkgs/by-name/cq/cq/package.nix +++ b/pkgs/by-name/cq/cq/package.nix @@ -2,7 +2,7 @@ , fetchFromGitHub , fetchurl , buildGraalvmNativeImage -, graalvmCEPackages +, graalvmPackages }: buildGraalvmNativeImage rec { @@ -23,7 +23,7 @@ buildGraalvmNativeImage rec { hash = "sha256-yjAC2obipdmh+JlHzVUTMtTXN2VKe4WKkyJyu2Q93c8="; }; - graalvmDrv = graalvmCEPackages.graalvm-ce; + graalvmDrv = graalvmPackages.graalvm-ce; executable = "cq"; diff --git a/pkgs/development/compilers/graalvm/buildGraalvm.nix b/pkgs/development/compilers/graalvm/buildGraalvm.nix new file mode 100644 index 0000000000000..b465dda84113c --- /dev/null +++ b/pkgs/development/compilers/graalvm/buildGraalvm.nix @@ -0,0 +1,241 @@ +{ + lib, + stdenv, + alsa-lib, + autoPatchelfHook, + cairo, + cups, + darwin, + fontconfig, + glib, + glibc, + gtk3, + makeWrapper, + musl, + runCommandCC, + setJavaClassPath, + unzip, + xorg, + zlib, + # extra params + extraCLibs ? [ ], + gtkSupport ? stdenv.isLinux, + useMusl ? false, + ... +}@args: + +assert useMusl -> stdenv.isLinux; +let + extraArgs = builtins.removeAttrs args [ + "lib" + "stdenv" + "alsa-lib" + "autoPatchelfHook" + "cairo" + "cups" + "darwin" + "fontconfig" + "glib" + "glibc" + "gtk3" + "makeWrapper" + "musl" + "runCommandCC" + "setJavaClassPath" + "unzip" + "xorg" + "zlib" + "extraCLibs" + "gtkSupport" + "useMusl" + "passthru" + "meta" + ]; + + cLibs = lib.optionals stdenv.isLinux ( + [ + 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 = ( + runCommandCC "musl-gcc" { } '' + mkdir -p $out/bin + ln -s ${lib.getDev musl}/bin/musl-gcc $out/bin/${stdenv.hostPlatform.system}-musl-gcc + '' + ); + binPath = lib.makeBinPath (lib.optionals useMusl [ musl-gcc ] ++ [ stdenv.cc ]); + + runtimeLibraryPath = lib.makeLibraryPath ( + [ cups ] + ++ lib.optionals gtkSupport [ + cairo + glib + gtk3 + ] + ); + + graalvm-ce = stdenv.mkDerivation ( + { + pname = "graalvm-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 + ''; + + dontStrip = true; + + nativeBuildInputs = [ + unzip + makeWrapper + ] ++ lib.optional stdenv.isLinux autoPatchelfHook; + + propagatedBuildInputs = [ + setJavaClassPath + zlib + ] ++ lib.optional stdenv.isDarwin darwin.apple_sdk_11_0.frameworks.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 + ]; + + 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 + + wrapProgram $out/bin/native-image \ + --prefix PATH : ${binPath} \ + ${toString (map (l: "--add-flags '-H:CLibraryPath=${l}/lib'") cLibs)} + ''; + + preFixup = lib.optionalString (stdenv.isLinux) '' + for bin in $(find "$out/bin" -executable -type f); do + wrapProgram "$bin" --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}" + done + ''; + + doInstallCheck = true; + installCheckPhase = '' + runHook preInstallCheck + + ${ + # broken in darwin + lib.optionalString stdenv.isLinux '' + echo "Testing Jshell" + echo '1 + 1' | $out/bin/jshell + '' + } + + 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' + + extraNativeImageArgs="$(export -p | sed -n 's/^declare -x \([^=]\+\)=.*$/ -E\1/p' | tr -d \\n)" + + echo "Ahead-Of-Time compilation" + $out/bin/native-image -H:+UnlockExperimentalVMOptions -H:-CheckToolchain -H:+ReportExceptionStackTraces -march=compatibility $extraNativeImageArgs HelloWorld + ./helloworld | fgrep 'Hello World' + + ${ + # -H:+StaticExecutableWithDynamicLibC is only available in Linux + lib.optionalString (stdenv.isLinux && !useMusl) '' + echo "Ahead-Of-Time compilation with -H:+StaticExecutableWithDynamicLibC" + $out/bin/native-image -H:+UnlockExperimentalVMOptions -H:+StaticExecutableWithDynamicLibC -march=compatibility $extraNativeImageArgs HelloWorld + ./helloworld | fgrep 'Hello World' + '' + } + + ${ + # --static is only available in Linux + lib.optionalString (stdenv.isLinux && useMusl) '' + echo "Ahead-Of-Time compilation with --static and --libc=musl" + $out/bin/native-image $extraNativeImageArgs -march=compatibility --libc=musl --static HelloWorld + ./helloworld | fgrep 'Hello World' + '' + } + + runHook postInstallCheck + ''; + + passthru = { + home = graalvm-ce; + updateScript = [ + ./update.sh + "graalvm-ce" + ]; + } // (args.passhtru or { }); + + meta = + with lib; + ( + { + 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 ++ [ ]; + } + // (args.meta or { }) + ); + } + // extraArgs + ); +in +graalvm-ce diff --git a/pkgs/development/compilers/graalvm/community-edition/graaljs/default.nix b/pkgs/development/compilers/graalvm/community-edition/graaljs/default.nix index ec662e156721c..a3b47516b0df4 100644 --- a/pkgs/development/compilers/graalvm/community-edition/graaljs/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/graaljs/default.nix @@ -1,9 +1,9 @@ { stdenv , fetchurl -, graalvmCEPackages +, graalvmPackages }: -graalvmCEPackages.buildGraalvmProduct { +graalvmPackages.buildGraalvmProduct { src = fetchurl (import ./hashes.nix).hashes.${stdenv.system}; version = (import ./hashes.nix).version; diff --git a/pkgs/development/compilers/graalvm/community-edition/graalnodejs/default.nix b/pkgs/development/compilers/graalvm/community-edition/graalnodejs/default.nix index d98f4b0e380f4..8df0ab5a38e15 100644 --- a/pkgs/development/compilers/graalvm/community-edition/graalnodejs/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/graalnodejs/default.nix @@ -1,9 +1,9 @@ { stdenv , fetchurl -, graalvmCEPackages +, graalvmPackages }: -graalvmCEPackages.buildGraalvmProduct { +graalvmPackages.buildGraalvmProduct { src = fetchurl (import ./hashes.nix).hashes.${stdenv.system}; version = (import ./hashes.nix).version; diff --git a/pkgs/development/compilers/graalvm/community-edition/graalpy/default.nix b/pkgs/development/compilers/graalvm/community-edition/graalpy/default.nix index e2b28500f7fe4..ff73a7dde8c60 100644 --- a/pkgs/development/compilers/graalvm/community-edition/graalpy/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/graalpy/default.nix @@ -1,9 +1,9 @@ { stdenv , fetchurl -, graalvmCEPackages +, graalvmPackages }: -graalvmCEPackages.buildGraalvmProduct { +graalvmPackages.buildGraalvmProduct { src = fetchurl (import ./hashes.nix).hashes.${stdenv.system}; version = (import ./hashes.nix).version; diff --git a/pkgs/development/compilers/graalvm/community-edition/graalvm-ce/default.nix b/pkgs/development/compilers/graalvm/community-edition/graalvm-ce/default.nix index b7f7db61097f2..da5b59417e20b 100644 --- a/pkgs/development/compilers/graalvm/community-edition/graalvm-ce/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/graalvm-ce/default.nix @@ -1,10 +1,10 @@ { stdenv , fetchurl -, graalvmCEPackages +, graalvmPackages , useMusl ? false }: -graalvmCEPackages.buildGraalvm { +graalvmPackages.buildGraalvm { inherit useMusl; src = fetchurl (import ./hashes.nix).hashes.${stdenv.system}; version = (import ./hashes.nix).version; diff --git a/pkgs/development/compilers/graalvm/community-edition/truffleruby/default.nix b/pkgs/development/compilers/graalvm/community-edition/truffleruby/default.nix index da971347652e1..de9e93c180fd6 100644 --- a/pkgs/development/compilers/graalvm/community-edition/truffleruby/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/truffleruby/default.nix @@ -1,12 +1,12 @@ { lib , stdenv , fetchurl -, graalvmCEPackages +, graalvmPackages , libyaml , openssl }: -graalvmCEPackages.buildGraalvmProduct { +graalvmPackages.buildGraalvmProduct { src = fetchurl (import ./hashes.nix).hashes.${stdenv.system}; version = (import ./hashes.nix).version; diff --git a/pkgs/development/compilers/graalvm/default.nix b/pkgs/development/compilers/graalvm/default.nix new file mode 100644 index 0000000000000..6dc0715a7bd8d --- /dev/null +++ b/pkgs/development/compilers/graalvm/default.nix @@ -0,0 +1,13 @@ +{ callPackage }: + +let + cePackages = callPackage ./community-edition { }; +in +cePackages +// rec { + buildGraalvm = callPackage ./buildGraalvm.nix; + + graalvm-oracle_22 = callPackage ./graalvm-oracle { version = "22"; }; + graalvm-oracle_17 = callPackage ./graalvm-oracle { version = "17"; }; + graalvm-oracle = graalvm-oracle_22; +} diff --git a/pkgs/development/compilers/graalvm/graalvm-oracle/default.nix b/pkgs/development/compilers/graalvm/graalvm-oracle/default.nix new file mode 100644 index 0000000000000..d8a9f14e70e3f --- /dev/null +++ b/pkgs/development/compilers/graalvm/graalvm-oracle/default.nix @@ -0,0 +1,16 @@ +{ + lib, + stdenv, + fetchurl, + graalvmPackages, + useMusl ? false, + version ? "22", +}: + +graalvmPackages.buildGraalvm { + inherit useMusl version; + src = fetchurl (import ./hashes.nix).${version}.${stdenv.system}; + meta.platforms = builtins.attrNames (import ./hashes.nix).${version}; + meta.license = lib.licenses.unfree; + pname = "graalvm-oracle"; +} diff --git a/pkgs/development/compilers/graalvm/graalvm-oracle/hashes.nix b/pkgs/development/compilers/graalvm/graalvm-oracle/hashes.nix new file mode 100644 index 0000000000000..1df3f67dc3e4f --- /dev/null +++ b/pkgs/development/compilers/graalvm/graalvm-oracle/hashes.nix @@ -0,0 +1,38 @@ +{ + "22" = { + "aarch64-linux" = { + hash = "sha256-E0Fm6mFB7o39pu7JVWOoXT9BdPWiSXBx2hPvlruD5ls="; + url = "https://download.oracle.com/graalvm/22/archive/graalvm-jdk-22.0.1_linux-aarch64_bin.tar.gz"; + }; + "x86_64-linux" = { + hash = "sha256-1YPNsBygI6N+7UXZ0YS2i3qNf1C1jd4TaQQfKUw09KM="; + url = "https://download.oracle.com/graalvm/22/archive/graalvm-jdk-22.0.1_linux-x64_bin.tar.gz"; + }; + "x86_64-darwin" = { + hash = "sha256-waR39L44Ew8wznRc67tYD3HGFZ2UUD4+ELerWnxNpms="; + url = "https://download.oracle.com/graalvm/22/archive/graalvm-jdk-22.0.1_macos-x64_bin.tar.gz"; + }; + "aarch64-darwin" = { + hash = "sha256-dzUVPih81jopuxAx8sAYdwonNOXHyyirUUOhvStK1F8="; + url = "https://download.oracle.com/graalvm/22/archive/graalvm-jdk-22.0.1_macos-aarch64_bin.tar.gz"; + }; + }; + "17" = { + "aarch64-linux" = { + hash = "sha256-0J/XaXGzNyBgxrW1HgUvtBCPPRfAvzwOx67p/QcY4u0="; + url = "https://download.oracle.com/graalvm/17/archive/graalvm-jdk-17.0.11_linux-aarch64_bin.tar.gz"; + }; + "x86_64-linux" = { + hash = "sha256-t0GHR7MGSZDSAGeX7bsI1ziugaP4euRcJq+covDBUYw="; + url = "https://download.oracle.com/graalvm/17/archive/graalvm-jdk-17.0.11_linux-x64_bin.tar.gz"; + }; + "x86_64-darwin" = { + hash = "sha256-q9b6I5hSVt67gkYzUtsJDSi4bPEkzpkoeC5ZyxfqJRc="; + url = "https://download.oracle.com/graalvm/17/archive/graalvm-jdk-17.0.11_macos-x64_bin.tar.gz"; + }; + "aarch64-darwin" = { + hash = "sha256-o4BGCfnD25AVYwG1Ol+2eDVCgiB+mk4I1JBIjyETK6s="; + url = "https://download.oracle.com/graalvm/17/archive/graalvm-jdk-17.0.11_macos-aarch64_bin.tar.gz"; + }; + }; +} diff --git a/pkgs/development/interpreters/babashka/default.nix b/pkgs/development/interpreters/babashka/default.nix index f4b51b37c480f..7b82513a15c70 100644 --- a/pkgs/development/interpreters/babashka/default.nix +++ b/pkgs/development/interpreters/babashka/default.nix @@ -1,6 +1,6 @@ { lib , buildGraalvmNativeImage -, graalvmCEPackages +, graalvmPackages , fetchurl , writeScript , installShellFiles @@ -16,7 +16,7 @@ let sha256 = "sha256-uVRk1/lfOXMSp3qOdeMoAFpwJaEBxF1MYtFOv364H7Y="; }; - graalvmDrv = graalvmCEPackages.graalvm-ce; + graalvmDrv = graalvmPackages.graalvm-ce; executable = "bb"; diff --git a/pkgs/development/tools/clj-kondo/default.nix b/pkgs/development/tools/clj-kondo/default.nix index e764f34c91253..5a68182352e47 100644 --- a/pkgs/development/tools/clj-kondo/default.nix +++ b/pkgs/development/tools/clj-kondo/default.nix @@ -1,4 +1,4 @@ -{ lib, buildGraalvmNativeImage, graalvmCEPackages, fetchurl +{ lib, buildGraalvmNativeImage, graalvmPackages, removeReferencesTo, fetchurl }: buildGraalvmNativeImage rec { @@ -11,7 +11,7 @@ buildGraalvmNativeImage rec { sha256 = "sha256-DrSfL1WazlNd5H0jG6m0S5aED4BLVufr1rGIAyifn6E="; }; - graalvmDrv = graalvmCEPackages.graalvm-ce; + graalvmDrv = graalvmPackages.graalvm-ce; extraNativeImageBuildArgs = [ "-H:+ReportExceptionStackTraces" "--no-fallback" ]; diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 91596ddfd6ed5..7cb01b21b2349 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -646,6 +646,8 @@ mapAliases { graalvm11-ce = throw "graalvm11-ce has been removed because upstream dropped support to different JDK versions for each GraalVM release. Please use graalvm-ce instead"; # Added 2023-09-26 graalvm17-ce = throw "graalvm17-ce has been removed because upstream dropped support to different JDK versions for each GraalVM release. Please use graalvm-ce instead"; # Added 2023-09-26 graalvm19-ce = throw "graalvm19-ce has been removed because upstream dropped support to different JDK versions for each GraalVM release. Please use graalvm-ce instead"; # Added 2023-09-26 + graalvmCEPackages = graalvmPackages; # Added 2024-08-10 + graalvm-ce = graalvmPackages.graalvm-ce; # Added 2024-08-10 grab-site = throw "grab-site has been removed because it's unmaintained and broken"; # Added 2023-11-12 gradle_4 = throw "gradle_4 has been removed because it's no longer being updated"; # Added 2023-01-17 gradle_5 = throw "gradle_5 has been removed because it's no longer being updated"; # Added 2023-01-17 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 271c5ee0343db..1ab15851e8683 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8003,7 +8003,7 @@ with pkgs; }; dapl-native = callPackage ../development/interpreters/dzaima-apl { buildNativeImage = true; - jdk = graalvm-ce; + jdk = graalvmPackages.graalvm-ce; }; gnucap-full = gnucap.withPlugins(p: [ p.verilog ]); @@ -15217,10 +15217,9 @@ with pkgs; openjdk = jdk; openjdk_headless = jdk_headless; - graalvmCEPackages = callPackage ../development/compilers/graalvm/community-edition { }; - graalvm-ce = graalvmCEPackages.graalvm-ce; + graalvmPackages = recurseIntoAttrs (callPackage ../development/compilers/graalvm { }); buildGraalvmNativeImage = (callPackage ../build-support/build-graalvm-native-image { - graalvmDrv = graalvm-ce; + graalvmDrv = graalvmPackages.graalvm-ce; }).override; openshot-qt = libsForQt5.callPackage ../applications/video/openshot-qt { @@ -16179,7 +16178,7 @@ with pkgs; dbqn-native = dbqn.override { buildNativeImage = true; - jdk = graalvm-ce; + jdk = graalvmPackages.graalvm-ce; }; chibi = callPackage ../development/interpreters/chibi { };