From 5c9a8665511a7757aac91b020c8b7162d7cde479 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sat, 16 Apr 2022 12:37:37 +0100 Subject: [PATCH 1/2] graalvmXX-ce: add sourcesPath parameter In #168816, we removed support for Python/Ruby/WASM to reduce the support burden of GraalVM languages that, arguably, are not really being used. However, the way that `pkgs.graalvmCEPackages.mkGraal` function works right now doesn't allow passing a custom sources file, that would allow someone to compile GraalVM with the additional products (e.g.: Python). This PR adds this possibility. So if someone wants to create a custom graalvm11-ce derivation with Python support, for example, they can do something like this: ```nix let graalvm11-ce-custom = pkgs.graalvmCEPackages.mkGraal { config = { x86_64-linux = { products = [ "graalvm-ce" "python-installable-svm" ]; arch = "linux-amd64"; }; }; defaultVersion = "22.0.0.2"; javaVersion = "11"; platforms = "x86_64-linux"; sourcesPath = /home/someone/graalvm11-ce-sources.json; }; in { environment.systemPackages = [ graalvm11-ce-custom ]; } ``` --- .../graalvm/community-edition/default.nix | 4 ++-- .../graalvm11-ce-sources.json | 12 +++++------ .../graalvm/community-edition/mkGraal.nix | 18 +++++++++-------- .../graalvm/community-edition/update.nix | 20 +++++++++---------- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/pkgs/development/compilers/graalvm/community-edition/default.nix b/pkgs/development/compilers/graalvm/community-edition/default.nix index e45c89b3f1be..c50b9e49f55a 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-20220401_1942"; - graalvm17-ce-dev-version = "22.2.0-dev-20220401_1942"; + graalvm11-ce-dev-version = "22.2.0-dev-20220415_1945"; + graalvm17-ce-dev-version = "22.2.0-dev-20220415_1945"; products = [ "graalvm-ce" 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 e3d514d58b9d..732cefbdf738 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-20220414_2112": { - "sha256": "7d1d39a7cc2579112e745943fa5b557405b501f5c3c3fde441f9a31c7627d18d", - "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220414_2112/graalvm-ce-java11-darwin-aarch64-dev.tar.gz" + "graalvm-ce|java11|22.2.0-dev-20220415_1945": { + "sha256": "ab81b00177124d746a3871b6e48ce7611e93dd3b4f6dee45d77300ef214fbab8", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220415_1945/graalvm-ce-java11-darwin-aarch64-dev.tar.gz" }, - "native-image-installable-svm|java11|22.2.0-dev-20220414_2112": { - "sha256": "5ec82588bf493c38656ca7c31fff276342ce1cbadee41309ae7a3486f56f7ba7", - "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220414_2112/native-image-installable-svm-java11-darwin-aarch64-dev.jar" + "native-image-installable-svm|java11|22.2.0-dev-20220415_1945": { + "sha256": "9d3753736fe71f55f3fb3bcbdf43271dd96dda0c4b731d11f3f890d5bddf3bbb", + "url": "https://github.com/graalvm/graalvm-ce-dev-builds/releases/download/22.2.0-dev-20220415_1945/native-image-installable-svm-java11-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 8f4aaba44f08..768ad1fbaa17 100644 --- a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix +++ b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix @@ -1,7 +1,9 @@ -{ javaVersion +{ config , defaultVersion +, javaVersion , platforms -, config +, forceUpdate ? false +, sourcesPath ? ./. + "/graalvm${javaVersion}-ce-sources.json" , useMusl ? false }: @@ -32,10 +34,11 @@ , gtkSupport ? stdenv.isLinux , cairo , glib -, gtk3 -, writeShellScript -, jq + # updateScript deps , gnused +, gtk3 +, jq +, writeShellScript }: assert useMusl -> stdenv.isLinux; @@ -44,8 +47,7 @@ let platform = config.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); version = platform.version or defaultVersion; name = "graalvm${javaVersion}-ce"; - sourcesFilename = "${name}-sources.json"; - sources = builtins.fromJSON (builtins.readFile (./. + "/${sourcesFilename}")); + sources = builtins.fromJSON (builtins.readFile sourcesPath); runtimeLibraryPath = lib.makeLibraryPath ([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]); @@ -285,7 +287,7 @@ let inherit (platform) products; home = graalvmXXX-ce; updateScript = import ./update.nix { - inherit lib writeShellScript jq sourcesFilename name config gnused defaultVersion; + inherit config defaultVersion forceUpdate gnused jq lib name sourcesPath writeShellScript; 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 6201ab100177..77f9d0e095ba 100644 --- a/pkgs/development/compilers/graalvm/community-edition/update.nix +++ b/pkgs/development/compilers/graalvm/community-edition/update.nix @@ -1,14 +1,14 @@ -{ javaVersion -, graalVersion +{ config , defaultVersion -, config -, sourcesFilename -, name -, lib -, writeShellScript -, jq +, forceUpdate , gnused -, forceUpdate ? false +, graalVersion +, javaVersion +, jq +, lib +, name +, sourcesPath +, writeShellScript }: /* @@ -185,7 +185,7 @@ let newVersion = getLatestVersion graalVersion; sourcesJson = genSources javaVersion defaultVersion config; - sourcesJsonPath = lib.strings.escapeShellArg ./. + "/${sourcesFilename}"; + sourcesJsonPath = lib.strings.escapeShellArg sourcesPath; # versionKeyInDefaultNix String -> String versionKeyInDefaultNix = graalVersion: From 6b2691d7ce0ebfadf750a29a2733fbaffec03d5f Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sat, 16 Apr 2022 13:33:19 +0100 Subject: [PATCH 2/2] graalvmXX-ce: add documentation to mkGraal function --- .../graalvm/community-edition/default.nix | 2 -- .../graalvm/community-edition/mkGraal.nix | 31 +++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/graalvm/community-edition/default.nix b/pkgs/development/compilers/graalvm/community-edition/default.nix index c50b9e49f55a..167aaa95c5ff 100644 --- a/pkgs/development/compilers/graalvm/community-edition/default.nix +++ b/pkgs/development/compilers/graalvm/community-edition/default.nix @@ -49,7 +49,6 @@ in }; defaultVersion = graalvm11-ce-release-version; javaVersion = "11"; - platforms = builtins.attrNames config; }; graalvm17-ce = mkGraal rec { @@ -74,6 +73,5 @@ in }; defaultVersion = graalvm17-ce-release-version; javaVersion = "17"; - platforms = builtins.attrNames config; }; } diff --git a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix index 768ad1fbaa17..77f0fa9b7dc5 100644 --- a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix +++ b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix @@ -1,9 +1,36 @@ -{ config +{ + # 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 overriden by `config..version` , defaultVersion + # Java version used by GraalVM , javaVersion -, platforms + # 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" + # Use musl instead of glibc to allow true static builds in GraalVM's + # Native Image (i.e.: `--static --libc=musl`). This will cause glibc builds + # to fail, so it should be used with care , useMusl ? false }: