about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/adoptopenjdk-bin')
-rwxr-xr-xnixpkgs/pkgs/development/compilers/adoptopenjdk-bin/generate-sources.py63
-rw-r--r--nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix59
-rw-r--r--nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix118
-rw-r--r--nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-darwin.nix9
-rw-r--r--nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-linux.nix9
-rw-r--r--nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/sources.json108
6 files changed, 366 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/generate-sources.py b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/generate-sources.py
new file mode 100755
index 000000000000..40b690048eba
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/generate-sources.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env nix-shell
+#!nix-shell --pure -i python3 -p "python3.withPackages (ps: with ps; [ requests ])"
+
+import json
+import re
+import requests
+import sys
+
+releases = ["openjdk11"]
+oses = ["mac", "linux"]
+types = ["jre", "jdk"]
+impls = ["hotspot", "openj9"]
+
+arch_to_nixos = {
+    "x64": "x86_64",
+    "aarch64": "aarch64",
+}
+
+def get_sha256(url):
+    resp = requests.get(url)
+    if resp.status_code != 200:
+        print("error: could not fetch checksum from url {}: code {}".format(url, resp.code), file=sys.stderr)
+        sys.exit(1)
+    return resp.text.strip().split(" ")[0]
+
+RE_RELEASE_NAME = re.compile(r'[^-]+-([0-9.]+)\+([0-9]+)') # example release name: jdk-11.0.1+13
+def generate_sources(release, assets):
+    out = {}
+    for asset in assets:
+        if asset["os"] not in oses: continue
+        if asset["binary_type"] not in types: continue
+        if asset["openjdk_impl"] not in impls: continue
+        if asset["heap_size"] != "normal": continue
+        if asset["architecture"] not in arch_to_nixos: continue
+
+        version, build = RE_RELEASE_NAME.match(asset["release_name"]).groups()
+
+        type_map = out.setdefault(asset["os"], {})
+        impl_map = type_map.setdefault(asset["binary_type"], {})
+        arch_map = impl_map.setdefault(asset["openjdk_impl"], {
+            "packageType": asset["binary_type"],
+            "vmType": asset["openjdk_impl"],
+        })
+
+        arch_map[arch_to_nixos[asset["architecture"]]] = {
+            "url": asset["binary_link"],
+            "sha256": get_sha256(asset["checksum_link"]),
+            "version": version,
+            "build": build,
+        }
+
+    return out
+
+out = {}
+for release in releases:
+    resp = requests.get("https://api.adoptopenjdk.net/v2/latestAssets/releases/" + release)
+    if resp.status_code != 200:
+        print("error: could not fetch data for release {} (code {})".format(release, resp.code), file=sys.stderr)
+        sys.exit(1)
+    out[release] = generate_sources(release, resp.json())
+
+with open("sources.json", "w") as f:
+    json.dump(out, f, indent=2, sort_keys=True)
diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix
new file mode 100644
index 000000000000..7b16d6ad9dbc
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-darwin-base.nix
@@ -0,0 +1,59 @@
+sourcePerArch:
+
+{ swingSupport ? true # not used for now
+, stdenv
+, fetchurl
+}:
+
+let cpuName = stdenv.hostPlatform.parsed.cpu.name;
+    result = stdenv.mkDerivation rec {
+  name = if sourcePerArch.packageType == "jdk"
+    then "adoptopenjdk-${sourcePerArch.vmType}-bin-${sourcePerArch.${cpuName}.version}"
+    else "adoptopenjdk-${sourcePerArch.packageType}-${sourcePerArch.vmType}-bin-${sourcePerArch.${cpuName}.version}";
+
+  src = fetchurl {
+    inherit (sourcePerArch.${cpuName}) url sha256;
+  };
+
+  # See: https://github.com/NixOS/patchelf/issues/10
+  dontStrip = 1;
+
+  installPhase = ''
+    cd ..
+
+    mv $sourceRoot $out
+
+    rm -rf $out/Home/demo
+
+    # Remove some broken manpages.
+    rm -rf $out/Home/man/ja*
+
+    # for backward compatibility
+    ln -s $out/Contents/Home $out/jre
+
+    ln -s $out/Contents/Home/* $out/
+
+    mkdir -p $out/nix-support
+
+    # Set JAVA_HOME automatically.
+    cat <<EOF >> $out/nix-support/setup-hook
+    if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi
+    EOF
+  '';
+
+  # FIXME: use multiple outputs or return actual JRE package
+  passthru.jre = result;
+
+  passthru.home = result;
+
+  # for backward compatibility
+  passthru.architecture = "";
+
+  meta = with stdenv.lib; {
+    license = licenses.gpl2Classpath;
+    description = "AdoptOpenJDK, prebuilt OpenJDK binary";
+    platforms = [ "x86_64-darwin" ]; # some inherit jre.meta.platforms
+    maintainers = with stdenv.lib.maintainers; [ taku0 ];
+  };
+
+}; in result
diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix
new file mode 100644
index 000000000000..8e8b157aa229
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix
@@ -0,0 +1,118 @@
+sourcePerArch:
+
+{ swingSupport ? true
+, stdenv
+, fetchurl
+, file
+, xorg ? null
+, glib
+, libxml2
+, ffmpeg_2
+, libxslt
+, libGL
+, freetype
+, fontconfig
+, gtk2
+, pango
+, cairo
+, alsaLib
+, atk
+, gdk_pixbuf
+, zlib
+, elfutils
+}:
+
+assert swingSupport -> xorg != null;
+
+let
+  rSubPaths = [
+    "lib/jli"
+    "lib/server"
+    "lib/compressedrefs" # OpenJ9
+    "lib/j9vm" # OpenJ9
+    "lib"
+  ];
+
+  libraries = [
+    stdenv.cc.libc glib libxml2 ffmpeg_2 libxslt libGL
+    xorg.libXxf86vm alsaLib fontconfig freetype pango gtk2 cairo gdk_pixbuf
+    atk zlib elfutils
+  ] ++ (stdenv.lib.optionals swingSupport [
+    xorg.libX11 xorg.libXext xorg.libXtst xorg.libXi xorg.libXp xorg.libXt
+    xorg.libXrender
+    stdenv.cc.cc
+  ]);
+
+  cpuName = stdenv.hostPlatform.parsed.cpu.name;
+in
+
+let result = stdenv.mkDerivation rec {
+  name = if sourcePerArch.packageType == "jdk"
+    then "adoptopenjdk-${sourcePerArch.vmType}-bin-${version}"
+    else "adoptopenjdk-${sourcePerArch.packageType}-${sourcePerArch.vmType}-bin-${version}";
+
+  version = sourcePerArch.${cpuName}.version or (throw "unsupported CPU ${cpuName}");
+
+  src = fetchurl {
+    inherit (sourcePerArch.${cpuName}) url sha256;
+  };
+
+  nativeBuildInputs = [ file ];
+
+  # See: https://github.com/NixOS/patchelf/issues/10
+  dontStrip = 1;
+
+  installPhase = ''
+    cd ..
+
+    mv $sourceRoot $out
+
+    rm -rf $out/demo
+
+    # Remove some broken manpages.
+    rm -rf $out/man/ja*
+
+    # Remove embedded freetype to avoid problems like
+    # https://github.com/NixOS/nixpkgs/issues/57733
+    rm $out/lib/libfreetype.so
+
+    # for backward compatibility
+    ln -s $out $out/jre
+
+    mkdir -p $out/nix-support
+
+    # Set JAVA_HOME automatically.
+    cat <<EOF >> $out/nix-support/setup-hook
+    if [ -z "\$JAVA_HOME" ]; then export JAVA_HOME=$out; fi
+    EOF
+  '';
+
+  postFixup = ''
+    rpath+="''${rpath:+:}${stdenv.lib.concatStringsSep ":" (map (a: "$out/${a}") rSubPaths)}"
+
+    # set all the dynamic linkers
+    find $out -type f -perm -0100 \
+        -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+        --set-rpath "$rpath" {} \;
+
+    find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \;
+  '';
+
+  rpath = stdenv.lib.strings.makeLibraryPath libraries;
+
+  # FIXME: use multiple outputs or return actual JRE package
+  passthru.jre = result;
+
+  passthru.home = result;
+
+  # for backward compatibility
+  passthru.architecture = "";
+
+  meta = with stdenv.lib; {
+    license = licenses.gpl2Classpath;
+    description = "AdoptOpenJDK, prebuilt OpenJDK binary";
+    platforms = stdenv.lib.mapAttrsToList (arch: _: arch + "-linux") sourcePerArch; # some inherit jre.meta.platforms
+    maintainers = with stdenv.lib.maintainers; [ taku0 ];
+  };
+
+}; in result
diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-darwin.nix b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-darwin.nix
new file mode 100644
index 000000000000..d1db77215d16
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-darwin.nix
@@ -0,0 +1,9 @@
+let
+  sources = builtins.fromJSON (builtins.readFile ./sources.json);
+in
+{
+  jdk-hotspot = import ./jdk-darwin-base.nix sources.openjdk11.mac.jdk.hotspot;
+  jre-hotspot = import ./jdk-darwin-base.nix sources.openjdk11.mac.jre.hotspot;
+  jdk-openj9 = import ./jdk-darwin-base.nix sources.openjdk11.mac.jdk.openj9;
+  jre-openj9 = import ./jdk-darwin-base.nix sources.openjdk11.mac.jre.openj9;
+}
diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-linux.nix b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-linux.nix
new file mode 100644
index 000000000000..755ffaab271e
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/jdk11-linux.nix
@@ -0,0 +1,9 @@
+let
+  sources = builtins.fromJSON (builtins.readFile ./sources.json);
+in
+{
+  jdk-hotspot = import ./jdk-linux-base.nix sources.openjdk11.linux.jdk.hotspot;
+  jre-hotspot = import ./jdk-linux-base.nix sources.openjdk11.linux.jre.hotspot;
+  jdk-openj9 = import ./jdk-linux-base.nix sources.openjdk11.linux.jdk.openj9;
+  jre-openj9 = import ./jdk-linux-base.nix sources.openjdk11.linux.jre.openj9;
+}
diff --git a/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/sources.json b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/sources.json
new file mode 100644
index 000000000000..03febb6aa355
--- /dev/null
+++ b/nixpkgs/pkgs/development/compilers/adoptopenjdk-bin/sources.json
@@ -0,0 +1,108 @@
+{
+  "openjdk11": {
+    "linux": {
+      "jdk": {
+        "hotspot": {
+          "aarch64": {
+            "build": "7",
+            "sha256": "894a846600ddb0df474350037a2fb43e3343dc3606809a20c65e750580d8f2b9",
+            "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_aarch64_linux_hotspot_11.0.3_7.tar.gz",
+            "version": "11.0.3"
+          },
+          "packageType": "jdk",
+          "vmType": "hotspot",
+          "x86_64": {
+            "build": "7",
+            "sha256": "23cded2b43261016f0f246c85c8948d4a9b7f2d44988f75dad69723a7a526094",
+            "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz",
+            "version": "11.0.3"
+          }
+        },
+        "openj9": {
+          "packageType": "jdk",
+          "vmType": "openj9",
+          "x86_64": {
+            "build": "7",
+            "sha256": "7012edd56fc958070bc4747073de14ea08eb43081eb6ea19bdbf4763186e2d17",
+            "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7_openj9-0.14.0/OpenJDK11U-jdk_x64_linux_openj9_11.0.3_7_openj9-0.14.0.tar.gz",
+            "version": "11.0.3"
+          }
+        }
+      },
+      "jre": {
+        "hotspot": {
+          "aarch64": {
+            "build": "7",
+            "sha256": "de31fab70640c6d5099de5fc8fa8b4d6b484a7352fa48a9fafbdc088ca708564",
+            "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jre_aarch64_linux_hotspot_11.0.3_7.tar.gz",
+            "version": "11.0.3"
+          },
+          "packageType": "jre",
+          "vmType": "hotspot",
+          "x86_64": {
+            "build": "7",
+            "sha256": "d2df8bc799b09c8375f79bf646747afac3d933bb1f65de71d6c78e7466ff8fe4",
+            "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jre_x64_linux_hotspot_11.0.3_7.tar.gz",
+            "version": "11.0.3"
+          }
+        },
+        "openj9": {
+          "packageType": "jre",
+          "vmType": "openj9",
+          "x86_64": {
+            "build": "7",
+            "sha256": "14c660294832c7b2deb2845d96dce83df677e204b4f0f1fee0052764c4a56720",
+            "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7_openj9-0.14.0/OpenJDK11U-jre_x64_linux_openj9_11.0.3_7_openj9-0.14.0.tar.gz",
+            "version": "11.0.3"
+          }
+        }
+      }
+    },
+    "mac": {
+      "jdk": {
+        "hotspot": {
+          "packageType": "jdk",
+          "vmType": "hotspot",
+          "x86_64": {
+            "build": "7",
+            "sha256": "5ca2a24f1827bd7c110db99854693bf418f51ee3093c31332db5cd605278faad",
+            "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_x64_mac_hotspot_11.0.3_7.tar.gz",
+            "version": "11.0.3"
+          }
+        },
+        "openj9": {
+          "packageType": "jdk",
+          "vmType": "openj9",
+          "x86_64": {
+            "build": "7",
+            "sha256": "01045a99ff23bda354f82c0fd3fa6e8222e4a5acce7494e82495f47b30bc5e18",
+            "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7_openj9-0.14.0/OpenJDK11U-jdk_x64_mac_openj9_11.0.3_7_openj9-0.14.0.tar.gz",
+            "version": "11.0.3"
+          }
+        }
+      },
+      "jre": {
+        "hotspot": {
+          "packageType": "jre",
+          "vmType": "hotspot",
+          "x86_64": {
+            "build": "7",
+            "sha256": "9523b97288ff5d50e404565d346ed8ea8f19dd155092951af88d4be6b8414776",
+            "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jre_x64_mac_hotspot_11.0.3_7.tar.gz",
+            "version": "11.0.3"
+          }
+        },
+        "openj9": {
+          "packageType": "jre",
+          "vmType": "openj9",
+          "x86_64": {
+            "build": "7",
+            "sha256": "150c4065a57ec368b692276e8e3320b183ee17b402b7db07e676dff5837f0c52",
+            "url": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7_openj9-0.14.0/OpenJDK11U-jre_x64_mac_openj9_11.0.3_7_openj9-0.14.0.tar.gz",
+            "version": "11.0.3"
+          }
+        }
+      }
+    }
+  }
+}
\ No newline at end of file