git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #166537 from tricktron/f-graalvm-update-nix

graalvmXX-ce: new update script & init on aarch64-darwin

commit484bf4b741634c18e8b5fb68311782ba2d85f08b authorThiago Kenji Okada <thiagokokada@gmail.com> dateSat 2 Apr 2022, 17:48 (5 years ago) parent96674e9be1232e
7 files changed+478−225
pkgs/development/compilers/graalvm/community-edition/default.nix+66−5 pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.json+74 pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.json+56 pkgs/development/compilers/graalvm/community-edition/hashes.nix−57 pkgs/development/compilers/graalvm/community-edition/mkGraal.nix+59−82 pkgs/development/compilers/graalvm/community-edition/update.nix+223 pkgs/development/compilers/graalvm/community-edition/update.sh−81
pkgs/development/compilers/graalvm/community-edition/default.nix+66−5
@@ -1,17 +1,60 @@
1−{ lib, callPackage, Foundation }:
1+{ callPackage, Foundation }:
2+/*
3+ Add new graal versions and products here and then see update.nix on how to
4+ generate the sources.
5+*/
26
37let
48 mkGraal = opts: callPackage (import ./mkGraal.nix opts) {
59 inherit Foundation;
610 };
11+
12+ /*
13+ Looks a bit ugly but makes version update in the update script using sed
14+ much easier
15+ */
16+ graalvm11-ce-release-version = "22.0.0.2";
17+ graalvm17-ce-release-version = "22.0.0.2";
18+ graalvm11-ce-dev-version = "22.2.0-dev-20220401_1942";
19+ graalvm17-ce-dev-version = "22.2.0-dev-20220401_1942";
20+
21+ commonProducts = [
22+ "graalvm-ce"
23+ "native-image-installable-svm"
24+ "ruby-installable-svm"
25+ "wasm-installable-svm"
26+ ];
27+
728in
829{
930 inherit mkGraal;
1031
1132 graalvm11-ce = mkGraal rec {
12− version = "22.0.0.2";
33+ config = {
34+ x86_64-darwin = {
35+ arch = "darwin-amd64";
36+ products = commonProducts ++ [ "python-installable-svm" ];
37+ };
38+ x86_64-linux = {
39+ arch = "linux-amd64";
40+ products = commonProducts ++ [ "python-installable-svm" ];
41+ };
42+ aarch64-darwin = {
43+ arch = "darwin-aarch64";
44+ products = [
45+ "graalvm-ce"
46+ "native-image-installable-svm"
47+ ];
48+ version = graalvm11-ce-dev-version;
49+ };
50+ aarch64-linux = {
51+ arch = "linux-aarch64";
52+ products = commonProducts;
53+ };
54+ };
55+ defaultVersion = graalvm11-ce-release-version;
1356 javaVersion = "11";
14− platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
57+ platforms = builtins.attrNames config;
1558 };
1659
1760 # TODO: fix aarch64-linux, failing during Native Image compilation
@@ -20,8 +63,26 @@ in
2063 # directory"/tmp/SVM-4194439592488143713"): error=0, Failed to exec spawn
2164 # helper: pid: 19865, exit value: 1"
2265 graalvm17-ce = mkGraal rec {
23− version = "22.0.0.2";
66+ config = {
67+ x86_64-darwin = {
68+ arch = "darwin-amd64";
69+ products = commonProducts ++ [ "python-installable-svm" ];
70+ };
71+ x86_64-linux = {
72+ arch = "linux-amd64";
73+ products = commonProducts ++ [ "python-installable-svm" ];
74+ };
75+ aarch64-darwin = {
76+ arch = "darwin-aarch64";
77+ products = [
78+ "graalvm-ce"
79+ "native-image-installable-svm"
80+ ];
81+ version = graalvm17-ce-dev-version;
82+ };
83+ };
84+ defaultVersion = graalvm17-ce-release-version;
2485 javaVersion = "17";
25− platforms = [ "x86_64-linux" "x86_64-darwin" ];
86+ platforms = builtins.attrNames config;
2687 };
2788}
pkgs/development/compilers/graalvm/community-edition/graalvm11-ce-sources.jsonnew file+74
@@ -0,0 +1,74 @@
1+{
2+ "darwin-aarch64": {
3+ "graalvm-ce|java11|22.2.0-dev-20220401_1942": {
4+ "sha256": "c83dee740ae148486598759e44a717b09d8124e4ea50f9da1e7d49d016572b89",
5+ "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"
6+ },
7+ "native-image-installable-svm|java11|22.2.0-dev-20220401_1942": {
8+ "sha256": "661311ae26bfd6c46360b9e65aabe9361dc5cd05878a404343adf16925ae78fa",
9+ "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"
10+ }
11+ },
12+ "darwin-amd64": {
13+ "graalvm-ce|java11|22.0.0.2": {
14+ "sha256": "8280159b8a66c51a839c8079d885928a7f759d5da0632f3af7300df2b63a6323",
15+ "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"
16+ },
17+ "native-image-installable-svm|java11|22.0.0.2": {
18+ "sha256": "03c27de6cce61ee8073e89252212457f3fbac2c0bc9bfa4acbff12176476c176",
19+ "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"
20+ },
21+ "python-installable-svm|java11|22.0.0.2": {
22+ "sha256": "67ee2f1cc10b0189e359344c31b22f423e636ff4ec2dd7d9437c3eb0ef54e601",
23+ "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java11-darwin-amd64-22.0.0.2.jar"
24+ },
25+ "ruby-installable-svm|java11|22.0.0.2": {
26+ "sha256": "a25c0099a21ca1ca9904dd3acdeef509f67a13b96c6135b6de199e9805330df9",
27+ "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java11-darwin-amd64-22.0.0.2.jar"
28+ },
29+ "wasm-installable-svm|java11|22.0.0.2": {
30+ "sha256": "d74c210a8a87b8eb0c4d18a65fde6f2c03ebc94d9bf7ed87bbb9cacc460006d7",
31+ "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"
32+ }
33+ },
34+ "linux-aarch64": {
35+ "graalvm-ce|java11|22.0.0.2": {
36+ "sha256": "1cc0263d95f642dada4e290dca7f49c0456cefa7b690b67e3e5c159b537b2c58",
37+ "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"
38+ },
39+ "native-image-installable-svm|java11|22.0.0.2": {
40+ "sha256": "51d41e890a5aabf8e7b9d4f4e0f88206ee70a261f7dbb0315d51770ab8f3009e",
41+ "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"
42+ },
43+ "ruby-installable-svm|java11|22.0.0.2": {
44+ "sha256": "e0fb582a9c6b4167e7dc267c58ca1968bd1c471b3bc5c56061b436f175486d80",
45+ "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java11-linux-aarch64-22.0.0.2.jar"
46+ },
47+ "wasm-installable-svm|java11|22.0.0.2": {
48+ "sha256": "a48470ae391c75cb2805b7fe27cde2c925c0466fdbc0623dfbb67c54f19dbf8c",
49+ "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"
50+ }
51+ },
52+ "linux-amd64": {
53+ "graalvm-ce|java11|22.0.0.2": {
54+ "sha256": "bc86083bb7e2778c7e4fe4f55d74790e42255b96f7806a7fefa51d06f3bc7103",
55+ "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"
56+ },
57+ "native-image-installable-svm|java11|22.0.0.2": {
58+ "sha256": "8504a3441f5b28b8fd625f676674a9216f082ae63a4e30d43930c80f9672e71d",
59+ "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"
60+ },
61+ "python-installable-svm|java11|22.0.0.2": {
62+ "sha256": "2f01d1bbc2ed2c507952d8ceaab1cb2176fc67e2d8c4b3bf5864e8d930c60c55",
63+ "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java11-linux-amd64-22.0.0.2.jar"
64+ },
65+ "ruby-installable-svm|java11|22.0.0.2": {
66+ "sha256": "e90f7ebc13b6c1f8e3f98881bb4fe2336870744174b2b6d41dc672d15f0b9a40",
67+ "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java11-linux-amd64-22.0.0.2.jar"
68+ },
69+ "wasm-installable-svm|java11|22.0.0.2": {
70+ "sha256": "c0fdfc40374b70f6f1597dd21660535c813dc5c3948c8a6ea9559a20f4d3fb5e",
71+ "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"
72+ }
73+ }
74+}
pkgs/development/compilers/graalvm/community-edition/graalvm17-ce-sources.jsonnew file+56
@@ -0,0 +1,56 @@
1+{
2+ "darwin-aarch64": {
3+ "graalvm-ce|java17|22.2.0-dev-20220401_1942": {
4+ "sha256": "f0409c59adbce62da7be46ab7d0e01abe5c080ef97d0b555e6c773f94dbfdecf",
5+ "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"
6+ },
7+ "native-image-installable-svm|java17|22.2.0-dev-20220401_1942": {
8+ "sha256": "3770dc4810d7ebae8f9ca2212e91112629096a964d3caea1667b0aaf5f70c1e0",
9+ "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"
10+ }
11+ },
12+ "darwin-amd64": {
13+ "graalvm-ce|java17|22.0.0.2": {
14+ "sha256": "d54af9d1f4d0d351827395a714ed84d2489b023b74a9c13a431cc9d31d1e8f9a",
15+ "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"
16+ },
17+ "native-image-installable-svm|java17|22.0.0.2": {
18+ "sha256": "007fa742cd139d447f83d776b6d78e717c9df11d56a61061a5937547c20028b7",
19+ "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"
20+ },
21+ "python-installable-svm|java17|22.0.0.2": {
22+ "sha256": "af887b0304d5ec98fab1be2cd1fca2aa3b10e84e823142a7f274560b1e0ea7c1",
23+ "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java17-darwin-amd64-22.0.0.2.jar"
24+ },
25+ "ruby-installable-svm|java17|22.0.0.2": {
26+ "sha256": "fc5eb6f833136ae3fda61f46fe0af66a8454ca2f803ca35eaff7336521cb468d",
27+ "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java17-darwin-amd64-22.0.0.2.jar"
28+ },
29+ "wasm-installable-svm|java17|22.0.0.2": {
30+ "sha256": "b76e6d872ce07ca9facd5b997dbb6e557ba72aa369ddd5f1664431bd11b98796",
31+ "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"
32+ }
33+ },
34+ "linux-amd64": {
35+ "graalvm-ce|java17|22.0.0.2": {
36+ "sha256": "4f743e0ed3d974b7d619ca2ed6014554e8c12e5ebbb38b9bc9e820b182169bd4",
37+ "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"
38+ },
39+ "native-image-installable-svm|java17|22.0.0.2": {
40+ "sha256": "8c25f650d58c2649c97061cb806dfaec9e685d5d2b80afc7cf72fe61d6891831",
41+ "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"
42+ },
43+ "python-installable-svm|java17|22.0.0.2": {
44+ "sha256": "b3b78a15bd29b4eaaf0f2607e21181ca2a5b41b38ba43a3ff2656c2f6effda8a",
45+ "url": "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java17-linux-amd64-22.0.0.2.jar"
46+ },
47+ "ruby-installable-svm|java17|22.0.0.2": {
48+ "sha256": "d86c9ad50cbed980fa69d69b2eccd47d31880d8c55553483f59ce9eda15628bd",
49+ "url": "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java17-linux-amd64-22.0.0.2.jar"
50+ },
51+ "wasm-installable-svm|java17|22.0.0.2": {
52+ "sha256": "7f7e51e4a24384b3dd960c12ab9b05b1fea58a0457d6b80e3797228fab93c0bd",
53+ "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"
54+ }
55+ }
56+}
pkgs/development/compilers/graalvm/community-edition/hashes.nixdeleted−57
@@ -1,57 +0,0 @@
1−# Generated by ./update.sh script
2−{ javaVersionPlatform, ... }:
3−[
4− {
5− sha256 = {
6− "11-linux-aarch64" = "0n1cgd9rn5aw7rzbd45nlzpnqif095zwl3999vddlhpnjlyjdh0w";
7− "17-linux-aarch64" = "1iw27igiyzzl43yfgid1h6h7hd0xnv0rfdkp4r7r8i51sa3q7my7";
8− "11-linux-amd64" = "00vipkrhc7d5xxznm07pjrdjahhfg5s5vxg49xz8qxz2nwxhi1mw";
9− "17-linux-amd64" = "1m4v2s1b2878r6dqpcxvbqpc3s2l8l0xcbna37bbfx6rsc73wx2g";
10− "11-darwin-amd64" = "08v37avg439hywx2yqx0bnfpazwaja2xhyc0kj1imib6iadib042";
11− "17-darwin-amd64" = "16lg3qfx7j8w8cxc3abl7c19nj6jhkni99wmff153lyhyk8zjjnm";
12− }.${javaVersionPlatform} or null;
13− 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";
14− }
15− {
16− sha256 = {
17− "11-linux-aarch64" = "17h0yfw0lxsiblqv1nzpc6i71vh6hbwf1x6lp7kziass1a4ixm2i";
18− "17-linux-aarch64" = "1nvm04smzbis1jy9znac2a4yf9ajqvvmadcf5ffr521rm784g2br";
19− "11-linux-amd64" = "07g7fab0zj1h77a30kiswqm0hvr1m5s6crszcbyvha2v3x2a6145";
20− "17-linux-amd64" = "0c8qi7b63zkjrz3sz01bbmfni7pcz9nq1jv1f34lj9lcsm8gc9cc";
21− "11-darwin-amd64" = "0xn1frj1f4pzrd5gm6xwq31blgvz8l9249c97q3yh7p6rkk7vhh3";
22− "17-darwin-amd64" = "1dr80314fxcklmhi19jn3pqrsz3iivbvcxnphdzl978krm1afzq0";
23− }.${javaVersionPlatform} or null;
24− 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";
25− }
26− {
27− sha256 = {
28− "11-linux-aarch64" = "103d91sz2dmlc5hcbi9v3d3irgb83755hz16vkknfhbbkhm5iyz0";
29− "17-linux-aarch64" = "0vas98knpvpajmv8bkgcf0fh7n5fy361nd47002cpppg6hrp7k9q";
30− "11-linux-amd64" = "0h4s1dgx2wn63pabdckl85s70s1kw97vp0c8z7izihdn2fy7w3z9";
31− "17-linux-amd64" = "1g98ashyvscwyn1k8mamih6qhcbxsk62x6ynd7x81ndy1karlv6q";
32− "11-darwin-amd64" = "1y8d6c2ri7hrvsv3aqbcp49pmxh9yppcsfnx0jcwm88wlach0p52";
33− "17-darwin-amd64" = "13a6rchnaczpmxga6g405z55913ayq5gwihzlvyy6shk6gwbcppw";
34− }.${javaVersionPlatform} or null;
35− url = "https://github.com/oracle/truffleruby/releases/download/vm-22.0.0.2/ruby-installable-svm-java${javaVersionPlatform}-22.0.0.2.jar";
36− }
37− {
38− sha256 = {
39− "11-linux-aarch64" = "135zkpqm8z5nzcyn5h6vdx3c09f9wb6jgzmp0llcnx8w76p71154";
40− "17-linux-aarch64" = "0pij3kh70lxrzmbzx8zw97f9nb0rr492l7x3n13wcr859cr8akas";
41− "11-linux-amd64" = "0ppvsgs216jmm5p8m34lqg2kv0awadh1dlkxb7qzcw2b6x0grzf0";
42− "17-linux-amd64" = "1gf0jfmqy8lp6w7bimjp0j5abzmi0ndsn4hcjvfv7123lbj52zkz";
43− "11-darwin-amd64" = "1mq6013crjmrpf3yvxwv9p4yn0rcdzg5z9hq9l6fpf47i8522k6p";
44− "17-darwin-amd64" = "15l7p48vsca4cvqxbpb9lcmafysmdsxpv6avrpxajz705j3nsvmp";
45− }.${javaVersionPlatform} or null;
46− 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";
47− }
48− {
49− sha256 = {
50− "11-linux-amd64" = "0m8cqqqdks34b2zv7i6qw9kzqxi1rfqsmknqa9wm0b7dqaxx209g";
51− "17-linux-amd64" = "12nszxp2yv35y8zkm94bnd0mnanah48y41r61ypymd19plaqmdxk";
52− "11-darwin-amd64" = "00g6akpv0gkw8gcxfbgcyipn6gj25yr32k1lb7iqj08bq4f2zvk7";
53− "17-darwin-amd64" = "1hd71qg0nmklyakl4cc29vl10fxalbyd2b5yn7x9iv6m0h1pp25g";
54− }.${javaVersionPlatform} or null;
55− url = "https://github.com/graalvm/graalpython/releases/download/vm-22.0.0.2/python-installable-svm-java${javaVersionPlatform}-22.0.0.2.jar";
56− }
57−]
pkgs/development/compilers/graalvm/community-edition/mkGraal.nix+59−82
@@ -1,7 +1,7 @@
1−{ version
2−, javaVersion
1+{ javaVersion
2+, defaultVersion
33, platforms
4−, hashes ? import ./hashes.nix
4+, config
55, useMusl ? false
66}:
77
@@ -33,16 +33,19 @@
3333, cairo
3434, glib
3535, gtk3
36+, writeShellScript
37+, jq
38+, gnused
3639}:
3740
3841assert useMusl -> stdenv.isLinux;
3942
4043let
41− platform = {
42− aarch64-linux = "linux-aarch64";
43− x86_64-linux = "linux-amd64";
44− x86_64-darwin = "darwin-amd64";
45− }.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}");
44+ platform = config.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
45+ version = platform.version or defaultVersion;
46+ name = "graalvm${javaVersion}-ce";
47+ sourcesFilename = "${name}-sources.json";
48+ sources = builtins.fromJSON (builtins.readFile (./. + "/${sourcesFilename}"));
4649
4750 runtimeLibraryPath = lib.makeLibraryPath
4851 ([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]);
@@ -56,21 +59,11 @@ let
5659 (writeShellScriptBin "${stdenv.system}-musl-gcc" ''${lib.getDev musl}/bin/musl-gcc "$@"'')
5760 ]);
5861
59− javaVersionPlatform = "${javaVersion}-${platform}";
60−
6162 graalvmXXX-ce = stdenv.mkDerivation rec {
6263 inherit version;
63− name = "graalvm${javaVersion}-ce";
64− srcs =
65− let
66− # Some platforms doesn't have all GraalVM features
67− # e.g.: GraalPython on aarch64-linux
68− # When the platform doesn't have a feature, sha256 is null on hashes.nix
69− # To update hashes.nix file, run `./update.sh <graalvm-ce-version>`
70− maybeFetchUrl = url: if url.sha256 != null then (fetchurl url) else null;
71− in
72− (lib.remove null
73− (map maybeFetchUrl (hashes { inherit javaVersionPlatform; })));
64+ pname = name;
65+
66+ srcs = map fetchurl (builtins.attrValues sources.${platform.arch});
7467
7568 buildInputs = lib.optionals stdenv.isLinux [
7669 alsa-lib # libasound.so wanted by lib/libjsound.so
@@ -86,7 +79,8 @@ let
8679 zlib
8780 ];
8881
89− nativeBuildInputs = [ unzip perl autoPatchelfHook makeWrapper ];
82+ nativeBuildInputs = [ unzip perl makeWrapper ]
83+ ++ lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook;
9084
9185 unpackPhase = ''
9286 unpack_jar() {
@@ -139,65 +133,40 @@ let
139133
140134 outputs = [ "out" "lib" ];
141135
142− installPhase =
143− let
144− copyClibrariesToOut = basepath: ''
145− # provide libraries needed for static compilation
146− ${
147− if useMusl then
148− "for f in ${musl.stdenv.cc.cc}/lib/* ${musl}/lib/* ${zlib.static}/lib/*; do"
149− else
150− "for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do"
151− }
152− ln -s $f ${basepath}/${platform}/$(basename $f)
153− done
154− '';
155− copyClibrariesToLib = ''
156− # add those libraries to $lib output too, so we can use them with
157− # `native-image -H:CLibraryPath=''${lib.getLib graalvm11-ce}/lib ...` and reduce
158− # closure size by not depending on GraalVM $out (that is much bigger)
159− mkdir -p $lib/lib
160− for f in ${glibc}/lib/*; do
161− ln -s $f $lib/lib/$(basename $f)
162− done
163− '';
164− in
165− {
166− "11-linux-amd64" = ''
167− ${copyClibrariesToOut "$out/lib/svm/clibraries"}
168−
169− ${copyClibrariesToLib}
170− '';
171− "17-linux-amd64" = ''
172− ${copyClibrariesToOut "$out/lib/svm/clibraries"}
173−
174− ${copyClibrariesToLib}
175− '';
176− "11-linux-aarch64" = ''
177− ${copyClibrariesToOut "$out/lib/svm/clibraries"}
178−
179− ${copyClibrariesToLib}
180− '';
181− "17-linux-aarch64" = ''
182− ${copyClibrariesToOut "$out/lib/svm/clibraries"}
183−
184− ${copyClibrariesToLib}
185− '';
186− "11-darwin-amd64" = "";
187− "17-darwin-amd64" = "";
188− }.${javaVersionPlatform} + ''
189− # ensure that $lib/lib exists to avoid breaking builds
136+ installPhase = ''
137+ # ensure that $lib/lib exists to avoid breaking builds
138+ mkdir -p $lib/lib
139+ # jni.h expects jni_md.h to be in the header search path.
140+ ln -s $out/include/linux/*_md.h $out/include/
141+
142+ # copy-paste openjdk's preFixup
143+ # Set JAVA_HOME automatically.
144+ mkdir -p $out/nix-support
145+ cat > $out/nix-support/setup-hook << EOF
146+ if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
147+ EOF
148+ ${
149+ lib.optionalString (stdenv.isLinux) ''
150+ # provide libraries needed for static compilation
151+ ${
152+ if useMusl then
153+ "for f in ${musl.stdenv.cc.cc}/lib/* ${musl}/lib/* ${zlib.static}/lib/*; do"
154+ else
155+ "for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do"
156+ }
157+ ln -s $f $out/lib/svm/clibraries/${platform.arch}/$(basename $f)
158+ done
159+
160+ # add those libraries to $lib output too, so we can use them with
161+ # `native-image -H:CLibraryPath=''${lib.getLib graalvmXX-ce}/lib ...` and reduce
162+ # closure size by not depending on GraalVM $out (that is much bigger)
190163 mkdir -p $lib/lib
191− # jni.h expects jni_md.h to be in the header search path.
192− ln -s $out/include/linux/*_md.h $out/include/
193−
194− # copy-paste openjdk's preFixup
195− # Set JAVA_HOME automatically.
196− mkdir -p $out/nix-support
197− cat <<EOF > $out/nix-support/setup-hook
198− if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
199− EOF
200− '';
164+ for f in ${glibc}/lib/*; do
165+ ln -s $f $lib/lib/$(basename $f)
166+ done
167+ ''
168+ }
169+ '';
201170
202171 dontStrip = true;
203172
@@ -281,7 +250,7 @@ let
281250 }
282251
283252 ${
284− lib.optionalString (platform != "linux-aarch64") ''
253+ lib.optionalString (builtins.any (a: a == "python-installable-svm") platform.products) ''
285254 echo "Testing GraalPython"
286255 $out/bin/graalpython -c 'print(1 + 1)'
287256 echo '1 + 1' | $out/bin/graalpython
@@ -289,10 +258,14 @@ let
289258 }
290259
291260 echo "Testing TruffleRuby"
261+ ${
262+ lib.optionalString (builtins.any (a: a == "ruby-installable-svm") platform.products) ''
292263 # Hide warnings about wrong locale
293264 export LANG=C
294265 export LC_ALL=C
295266 $out/bin/ruby -e 'puts(1 + 1)'
267+ ''
268+ }
296269 ${# FIXME: irb is broken in all platforms
297270 # TODO: `irb` on MacOS gives an error saying "Could not find OpenSSL
298271 # headers, install via Homebrew or MacPorts or set OPENSSL_PREFIX", even
@@ -311,7 +284,11 @@ let
311284
312285 passthru = {
313286 home = graalvmXXX-ce;
314− updateScript = ./update.sh;
287+ updateScript = import ./update.nix {
288+ inherit lib writeShellScript jq sourcesFilename name config gnused defaultVersion;
289+ graalVersion = version;
290+ javaVersion = "java${javaVersion}";
291+ };
315292 };
316293
317294 meta = with lib; {
pkgs/development/compilers/graalvm/community-edition/update.nixnew file+223
@@ -0,0 +1,223 @@
1+{ javaVersion
2+, graalVersion
3+, defaultVersion
4+, config
5+, sourcesFilename
6+, name
7+, lib
8+, writeShellScript
9+, jq
10+, gnused
11+}:
12+
13+/*
14+ How to use:
15+ run `nix-shell maintainers/scripts/update.nix --argstr package graalvmXX-ce`
16+ to update the graalvmXX-ce-sources.json file.
17+ E.g: nix-shell maintainers/scripts/update.nix --argstr package graalvm17-ce
18+
19+ Basic idea:
20+ If we know the platform, product, javaVersion and graalVersion
21+ we can create the url. This leads to the following json structure:
22+ {
23+ "platform/arch1": {
24+ "product1|javaVersion|graalVersion": { "sha256": "...", "url": "..."},
25+ "product2|javaVersion|graalVersion": { "sha256": "...", "url": "..."},
26+ ...
27+ },
28+ "platform/arch2": {
29+ ...
30+ }
31+ }
32+*/
33+
34+let
35+ separator = "|";
36+
37+ # isDev :: String -> Boolean
38+ isDev = version:
39+ lib.hasInfix "dev" version;
40+
41+ # getLatestVersion :: String -> String
42+ getLatestVersion = currentVersion:
43+ let
44+ dev = if isDev currentVersion then "dev-" else "";
45+ url = "https://api.github.com/repos/graalvm/graalvm-ce-${dev}builds/releases/latest";
46+ file = builtins.fetchurl url;
47+ json = builtins.fromJSON (builtins.readFile file);
48+ in
49+ lib.removePrefix "vm-" json.tag_name;
50+
51+ # getArchString :: String -> String
52+ getArchString = nixArchString:
53+ {
54+ "aarch64-linux" = "linux-aarch64";
55+ "x86_64-linux" = "linux-amd64";
56+ "x86_64-darwin" = "darwin-amd64";
57+ }.${nixArchString};
58+
59+
60+ # getProductSuffix :: String -> String
61+ getProductSuffix = productName:
62+ {
63+ "graalvm-ce" = ".tar.gz";
64+ "native-image-installable-svm" = ".jar";
65+ "ruby-installable-svm" = ".jar";
66+ "wasm-installable-svm" = ".jar";
67+ "python-installable-svm" = ".jar";
68+ }.${productName};
69+
70+ # getProductSuffix :: String -> String
71+ getProductBaseUrl = productName:
72+ {
73+ "graalvm-ce" = "https://github.com/graalvm/graalvm-ce-builds/releases/download";
74+ "native-image-installable-svm" = "https://github.com/graalvm/graalvm-ce-builds/releases/download";
75+ "ruby-installable-svm" = "https://github.com/oracle/truffleruby/releases/download";
76+ "wasm-installable-svm" = "https://github.com/graalvm/graalvm-ce-builds/releases/download";
77+ "python-installable-svm" = "https://github.com/graalvm/graalpython/releases/download";
78+ }.${productName};
79+
80+ # getDevUrl :: String
81+ getDevUrl = { arch, graalVersion, product, javaVersion }:
82+ let
83+ baseUrl = https://github.com/graalvm/graalvm-ce-dev-builds/releases/download;
84+ in
85+ "${baseUrl}/${graalVersion}/${product}-${javaVersion}-${arch}-dev${getProductSuffix product}";
86+
87+ # getReleaseUrl :: AttrSet -> String
88+ getReleaseUrl = { arch, graalVersion, product, javaVersion }:
89+ let baseUrl = getProductBaseUrl product;
90+ in
91+ "${baseUrl}/vm-${graalVersion}/${product}-${javaVersion}-${arch}-${graalVersion}${getProductSuffix product}";
92+
93+ # getUrl :: AttrSet -> String
94+ getUrl = args@{ arch, graalVersion, product, javaVersion }:
95+ if isDev graalVersion
96+ then getDevUrl args
97+ else getReleaseUrl args;
98+
99+ # computeSha256 :: String -> String
100+ computeSha256 = url:
101+ builtins.hashFile "sha256" (builtins.fetchurl url);
102+
103+ # downloadSha256 :: String -> String
104+ downloadSha256 = url:
105+ let sha256Url = url + ".sha256";
106+ in
107+ builtins.readFile (builtins.fetchurl sha256Url);
108+
109+ # getSha256 :: String -> String -> String
110+ getSha256 = graalVersion: url:
111+ if isDev graalVersion
112+ then computeSha256 url
113+ else downloadSha256 url;
114+
115+ # cartesianZipListsWith :: (a -> b -> c) -> [a] -> [b] -> [c]
116+ cartesianZipListsWith = f: fst: snd:
117+ let
118+ cartesianProduct = lib.cartesianProductOfSets { a = fst; b = snd; };
119+ fst' = builtins.catAttrs "a" cartesianProduct;
120+ snd' = builtins.catAttrs "b" cartesianProduct;
121+ in
122+ lib.zipListsWith f fst' snd';
123+
124+ # zipListsToAttrs :: [a] -> [b] -> AttrSet
125+ zipListsToAttrs = names: values:
126+ lib.listToAttrs (
127+ lib.zipListsWith (name: value: { inherit name value; }) names values
128+ );
129+
130+ # genProductJavaVersionGraalVersionAttrSet :: String -> AttrSet
131+ genProductJavaVersionGraalVersionAttrSet = product_javaVersion_graalVersion:
132+ let
133+ attrNames = [ "product" "javaVersion" "graalVersion" ];
134+ attrValues = lib.splitString separator product_javaVersion_graalVersion;
135+ in
136+ zipListsToAttrs attrNames attrValues;
137+
138+ # genUrlAndSha256 :: String -> String -> AttrSet
139+ genUrlAndSha256 = arch: product_javaVersion_graalVersion:
140+ let
141+ productJavaVersionGraalVersion =
142+ (genProductJavaVersionGraalVersionAttrSet product_javaVersion_graalVersion)
143+ // { inherit arch; };
144+ url = getUrl productJavaVersionGraalVersion;
145+ sha256 = getSha256 productJavaVersionGraalVersion.graalVersion url;
146+ in
147+ {
148+ ${arch} = {
149+ ${product_javaVersion_graalVersion} = {
150+ inherit sha256 url;
151+ };
152+ };
153+ };
154+
155+ # genArchProductVersionPairs :: String -> -> String -> AttrSet -> [AttrSet]
156+ genArchProductVersionList = javaVersion: graalVersion: archProducts:
157+ let
158+ arch = archProducts.arch;
159+ products = archProducts.products;
160+ javaGraalVersion = javaVersion + separator + (getLatestVersion (archProducts.version or graalVersion));
161+ productJavaGraalVersionList =
162+ cartesianZipListsWith (a: b: a + separator + b)
163+ products [ javaGraalVersion ];
164+ in
165+ cartesianZipListsWith (genUrlAndSha256) [ arch ] productJavaGraalVersionList;
166+
167+
168+ # genSources :: String -> String -> AttrSet -> Path String
169+ genSources = javaVersion: defaultVersion: config:
170+ let
171+ archProducts = builtins.attrValues config;
172+ sourcesList = builtins.concatMap (genArchProductVersionList javaVersion defaultVersion) archProducts;
173+ sourcesAttr = builtins.foldl' (lib.recursiveUpdate) { } sourcesList;
174+ in
175+ builtins.toFile "sources.json" (builtins.toJSON sourcesAttr);
176+
177+ # isNew :: String -> String -> Boolean
178+ isNew = newVersion: currentVersion:
179+ {
180+ "-1" = false;
181+ "0" = false;
182+ "1" = true;
183+ }.${builtins.toString (builtins.compareVersions newVersion currentVersion)};
184+
185+ newVersion = getLatestVersion graalVersion;
186+ sourcesJson = genSources javaVersion defaultVersion config;
187+ sourcesJsonPath = lib.strings.escapeShellArg ./. + "/${sourcesFilename}";
188+
189+ # versionKeyInDefaultNix String -> String
190+ versionKeyInDefaultNix = graalVersion:
191+ if isDev graalVersion
192+ then "${name}-dev-version"
193+ else "${name}-release-version";
194+
195+ /*
196+ updateScriptText :: String -> String -> String
197+ Writes the json file and updates the version in default.nix using sed
198+ because update-source-version does not work srcs.
199+ */
200+ updateScriptText = newVersion: currentVersion:
201+
202+ if isNew newVersion currentVersion
203+ then
204+ let
205+ versionKey = versionKeyInDefaultNix currentVersion;
206+ in
207+ ''
208+ echo "New version found. Updating ${currentVersion} -> ${newVersion}".
209+ export PATH="${lib.makeBinPath [ jq gnused ]}:$PATH"
210+ jq . ${sourcesJson} > ${sourcesJsonPath}
211+ sed -i 's|${versionKey} = "${currentVersion}";|${versionKey} = "${newVersion}";|' \
212+ ${lib.strings.escapeShellArg ./default.nix}
213+ ''
214+ else ''echo "No new version found. Skip updating."'';
215+
216+in
217+writeShellScript "update-graal.sh" ''
218+ set -o errexit
219+ set -o nounset
220+ set -o pipefail
221+
222+ ${updateScriptText newVersion graalVersion}
223+''
pkgs/development/compilers/graalvm/community-edition/update.shdeleted−81
@@ -1,81 +0,0 @@
1−#!/usr/bin/env nix-shell
2−#!nix-shell -p coreutils curl nix jq gnused -i bash
3−
4−set -eou pipefail
5−
6−cd "$(dirname "${BASH_SOURCE[0]}")"
7−
8−info() { echo "[INFO] $*"; }
9−
10−echo_file() { echo "$@" >> hashes.nix; }
11−
12−verlte() {
13− [ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
14−}
15−
16−readonly nixpkgs=../../../../..
17−
18−readonly old_version="$(nix-instantiate "$nixpkgs" --eval --strict -A graalvm11-ce.version)"
19−
20−if [[ -z "${1:-}" ]]; then
21− readonly gh_version="$(curl \
22− ${GITHUB_TOKEN:+"-u \":$GITHUB_TOKEN\""} \
23− -s https://api.github.com/repos/graalvm/graalvm-ce-builds/releases/latest | \
24− jq --raw-output .tag_name)"
25− readonly new_version="${gh_version//vm-/}"
26−else
27− readonly new_version="$1"
28−fi
29−
30−if verlte "$old_version" "$new_version"; then
31− info "graalvm-ce $old_version is up-to-date."
32− [[ -z "${FORCE:-}" ]] && exit 0
33−else
34− info "graalvm-ce $old_version is out-of-date. Updating..."
35−fi
36−
37−readonly urls=(
38− "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/graalvm-ce-java@platform@-${new_version}.tar.gz"
39− "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/native-image-installable-svm-java@platform@-${new_version}.jar"
40− "https://github.com/oracle/truffleruby/releases/download/vm-${new_version}/ruby-installable-svm-java@platform@-${new_version}.jar"
41− "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${new_version}/wasm-installable-svm-java@platform@-${new_version}.jar"
42− "https://github.com/graalvm/graalpython/releases/download/vm-${new_version}/python-installable-svm-java@platform@-${new_version}.jar"
43−)
44−
45−readonly platforms=(
46− "11-linux-aarch64"
47− "17-linux-aarch64"
48− "11-linux-amd64"
49− "17-linux-amd64"
50− "11-darwin-amd64"
51− "17-darwin-amd64"
52−)
53−
54−info "Deleting old hashes.nix file..."
55−rm -f hashes.nix
56−info "Generating hashes.nix file for 'graalvm-ce' $new_version. This will take a while..."
57−
58−echo_file "# Generated by $0 script"
59−echo_file "{ javaVersionPlatform, ... }:"
60−echo_file "["
61−
62−for url in "${urls[@]}"; do
63− echo_file " {"
64− echo_file " sha256 = {"
65− for platform in "${platforms[@]}"; do
66− if hash="$(nix-prefetch-url "${url//@platform@/$platform}")"; then
67− echo_file " \"$platform\" = \"$hash\";"
68− fi
69− done
70− echo_file ' }.${javaVersionPlatform} or null;'
71− echo_file " url = \"${url//@platform@/\$\{javaVersionPlatform\}}\";"
72− echo_file " }"
73−done
74−
75−echo_file "]"
76−
77−info "Updating graalvm-ce version..."
78−# update-source-version does not work here since it expects src attribute
79−sed "s|$old_version|\"$new_version\"|" -i default.nix
80−
81−info "Done!"