From e7b71481e463dec5ce3177df6831008a9ee15d0f Mon Sep 17 00:00:00 2001 From: Emily Date: Wed, 23 Oct 2024 16:41:30 +0100 Subject: [PATCH 01/17] =?UTF-8?q?{open,}jdk{19,20,22}{,=5Fheadless}:=20don?= =?UTF-8?q?=E2=80=99t=20alias=20the=20`throw`s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This causes issues with the automated removal script. --- pkgs/top-level/aliases.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 8dc79a6e83af..95cb4561d82c 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -842,17 +842,17 @@ mapAliases { openimageio2 = openimageio; # Added 2023-01-05 openisns = throw "'openisns' has been renamed to/replaced by 'open-isns'"; # Converted to throw 2024-10-17 openjdk19 = throw "OpenJDK 19 was removed as it has reached its end of life"; # Added 2024-08-01 - openjdk19_headless = openjdk19; # Added 2024-08-01 - jdk19 = openjdk19; # Added 2024-08-01 - jdk19_headless = openjdk19; # Added 2024-08-01 + openjdk19_headless = throw "OpenJDK 19 was removed as it has reached its end of life"; # Added 2024-08-01 + jdk19 = throw "OpenJDK 19 was removed as it has reached its end of life"; # Added 2024-08-01 + jdk19_headless = throw "OpenJDK 19 was removed as it has reached its end of life"; # Added 2024-08-01 openjdk20 = throw "OpenJDK 20 was removed as it has reached its end of life"; # Added 2024-08-01 - openjdk20_headless = openjdk20; # Added 2024-08-01 - jdk20 = openjdk20; # Added 2024-08-01 - jdk20_headless = openjdk20; # Added 2024-08-01 + openjdk20_headless = throw "OpenJDK 20 was removed as it has reached its end of life"; # Added 2024-08-01 + jdk20 = throw "OpenJDK 20 was removed as it has reached its end of life"; # Added 2024-08-01 + jdk20_headless = throw "OpenJDK 20 was removed as it has reached its end of life"; # Added 2024-08-01 openjdk22 = throw "OpenJDK 22 was removed as it has reached its end of life"; # Added 2024-09-24 - openjdk22_headless = openjdk22; # Added 2024-09-24 - jdk22 = openjdk22; # Added 2024-09-24 - jdk22_headless = openjdk22; # Added 2024-09-24 + openjdk22_headless = throw "OpenJDK 22 was removed as it has reached its end of life"; # Added 2024-09-24 + jdk22 = throw "OpenJDK 22 was removed as it has reached its end of life"; # Added 2024-09-24 + jdk22_headless = throw "OpenJDK 22 was removed as it has reached its end of life"; # Added 2024-09-24 openjfx11 = throw "OpenJFX 11 was removed as it has reached its end of life"; # Added 2024-10-07 openjfx19 = throw "OpenJFX 19 was removed as it has reached its end of life"; # Added 2024-08-01 openjfx20 = throw "OpenJFX 20 was removed as it has reached its end of life"; # Added 2024-08-01 From 82fc758e95d7ea2810b8fa1dc374b8c8142b59ff Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 6 Oct 2024 03:44:39 +0100 Subject: [PATCH 02/17] =?UTF-8?q?zulu:=20don=E2=80=99t=20depend=20on=20Ope?= =?UTF-8?q?nJDK=E2=80=99s=20`meta.nix`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is about to go away. --- pkgs/development/compilers/zulu/common.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/zulu/common.nix b/pkgs/development/compilers/zulu/common.nix index f1d0f43325f4..f8127b2b7450 100644 --- a/pkgs/development/compilers/zulu/common.nix +++ b/pkgs/development/compilers/zulu/common.nix @@ -155,13 +155,14 @@ let home = jdk; }; - meta = (import ../openjdk/meta.nix lib version) // { + meta = { description = "Certified builds of OpenJDK"; longDescription = '' Certified builds of OpenJDK that can be deployed across multiple operating systems, containers, hypervisors and Cloud platforms. ''; homepage = "https://www.azul.com/products/zulu/"; + license = lib.licenses.gpl2Only; mainProgram = "java"; maintainers = [ ]; platforms = builtins.attrNames dists; From 09f30d20bc378114e4436c69554badd589f9dfcd Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 18 Oct 2024 05:49:15 +0100 Subject: [PATCH 03/17] openjdk: remove unused patch --- .../compilers/openjdk/fix-glibc-2.34.patch | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 pkgs/development/compilers/openjdk/fix-glibc-2.34.patch diff --git a/pkgs/development/compilers/openjdk/fix-glibc-2.34.patch b/pkgs/development/compilers/openjdk/fix-glibc-2.34.patch deleted file mode 100644 index 7bf8b2b16744..000000000000 --- a/pkgs/development/compilers/openjdk/fix-glibc-2.34.patch +++ /dev/null @@ -1,24 +0,0 @@ -Taken from https://build.opensuse.org/package/view_file/Java:Factory/java-15-openjdk/openjdk-glibc234.patch - ---- openjdk/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c 2021-04-09 11:36:58.000000000 +0200 -+++ openjdk/test/hotspot/jtreg/runtime/StackGuardPages/exeinvoke.c 2021-08-26 15:42:52.326232581 +0200 -@@ -67,8 +67,17 @@ - longjmp(context, 1); - } - -+static char* altstack = NULL; -+ - void set_signal_handler() { -- static char altstack[SIGSTKSZ]; -+ if (altstack == NULL) { -+ // Dynamically allocated in case SIGSTKSZ is not constant -+ altstack = malloc(SIGSTKSZ); -+ if (altstack == NULL) { -+ fprintf(stderr, "Test ERROR. Unable to malloc altstack space\n"); -+ exit(7); -+ } -+ } - - stack_t ss = { - .ss_size = SIGSTKSZ, - From cd2eaf83ecde3d0d2fb59893120a266cbd8018c4 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 18 Oct 2024 05:47:19 +0100 Subject: [PATCH 04/17] openjdk: remove existing update script --- pkgs/development/compilers/openjdk/23.nix | 14 -- .../compilers/openjdk/JavaUpdater.java | 181 ------------------ 2 files changed, 195 deletions(-) delete mode 100644 pkgs/development/compilers/openjdk/JavaUpdater.java diff --git a/pkgs/development/compilers/openjdk/23.nix b/pkgs/development/compilers/openjdk/23.nix index 25b49356664a..420335b55bf6 100644 --- a/pkgs/development/compilers/openjdk/23.nix +++ b/pkgs/development/compilers/openjdk/23.nix @@ -253,20 +253,6 @@ stdenv.mkDerivation (finalAttrs: { doInstallCheck = true; passthru = { - updateScript = - let - java-json = fetchurl { - url = "https://search.maven.org/remotecontent?filepath=org/json/json/20240303/json-20240303.jar"; - hash = "sha256-PPbNaJLjLitMHDng9S9SSKL1s3ZG/fu3mma0a2GEFO0="; - }; - in - writeShellScript "update-java" '' - ${finalAttrs.finalPackage}/bin/java \ - -cp ${java-json} \ - ${./JavaUpdater.java} \ - ${featureVersion} pkgs/development/compilers/openjdk/info.json - ''; - home = "${finalAttrs.finalPackage}/lib/openjdk"; inherit gtk3; diff --git a/pkgs/development/compilers/openjdk/JavaUpdater.java b/pkgs/development/compilers/openjdk/JavaUpdater.java deleted file mode 100644 index 32dddf2fabc7..000000000000 --- a/pkgs/development/compilers/openjdk/JavaUpdater.java +++ /dev/null @@ -1,181 +0,0 @@ -import org.json.JSONArray; -import org.json.JSONObject; - -import java.io.IOException; -import java.io.PrintWriter; -import java.net.URI; -import java.net.http.*; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; - -public class JavaUpdater { - - record GitHubResult(Optional latestVersion, Optional next) { - } - - record JsonInfo(String repo, String version, String hash) { - public JsonInfo(JSONObject json) { - this(json.getString("repo"), json.getString("version"), json.getString("hash")); - } - - public String toJsonString(String featureVersion) { - return """ - \s "%s": { - \s "version": "%s", - \s "repo": "%s", - \s "hash": "%s" - \s }\ - """.formatted(featureVersion, version, repo, hash); - } - } - - // Parses the GitHub Link header - public static Optional getNextLink(HttpHeaders headers) { - var linkHeader = headers.map().get("Link"); - if (linkHeader == null || linkHeader.isEmpty()) return null; - - var links = linkHeader.getFirst(); - var linksRegex = Pattern.compile("<(.+)>;\\s*rel=\"next\""); - return Pattern.compile(",") - .splitAsStream(links) - .map(x -> linksRegex.matcher(x).results() - .map(g -> g.group(1)) - .findFirst() - ) - .filter(Optional::isPresent) - .map(Optional::orElseThrow) - .findFirst(); - } - - // HTTP request helper, sets GITHUB_TOKEN if present - private static HttpRequest NewGithubRequest(String url) { - var token = System.getenv().get("GITHUB_TOKEN"); - var builder = HttpRequest.newBuilder() - .uri(URI.create(url)); - if (token != null) - builder.setHeader("Authorization", "Bearer " + token); - return builder.build(); - } - - private static GitHubResult getLatestTag(String url) { - var request = NewGithubRequest(url); - - var response = - HttpClient.newHttpClient().sendAsync(request, HttpResponse.BodyHandlers.ofString()) - .join(); - - var json = new JSONArray(response.body()); - - Optional version = StreamSupport.stream(json.spliterator(), false) - .map(JSONObject.class::cast) - .map(x -> x.getString("name").replaceFirst("jdk-", "")) - .filter(x -> x.contains("-ga")) - .max(Comparator.comparing(Runtime.Version::parse)); - - return new GitHubResult(version, getNextLink(response.headers())); - } - - public String findNewerVersion() { - var url = Optional.of("https://api.github.com/repos/openjdk/" + getRepo() + "/tags?per_page=100"); - String version = getCurrentVersion(); - do { - GitHubResult response = getLatestTag(url.orElseThrow()); - if (response.latestVersion.isPresent() && response.latestVersion.orElseThrow().equals(version)) { - return null; - } - - String latestVersion = Stream.of(version, response.latestVersion.orElse(version)) - .max(Comparator.comparing(Runtime.Version::parse)).orElseThrow(); - - if (latestVersion != version) - return latestVersion; - - url = response.next; - } while (url.isPresent()); - return null; - } - - - private static String prettyPrint(JSONObject json) { - - Iterable iterable = () -> json.keys(); - - return StreamSupport - .stream(iterable.spliterator(), false) - .sorted(Comparator.reverseOrder()) - .map(majorVersion -> (new JsonInfo(json.getJSONObject(majorVersion))).toJsonString(majorVersion)) - .collect( - Collectors.joining(",\n", "{\n", "\n}") - ); - } - - public void updateJsonInfo(String newVersion) { - try { - JSONObject json = getJsonInfo(); - var info = json.getJSONObject(featureNumber); - info.put("version", newVersion); - info.put("hash", nixHash(newVersion)); - - try (PrintWriter out = new PrintWriter(infoJsonPath)) { - out.println(prettyPrint(json)); - } - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private String nixHash(String version) { - try { - var process = new ProcessBuilder("nix", "flake", "prefetch", - "--extra-experimental-features", "'nix-command flakes'", - "--json", "github:openjdk/" + getRepo() + "/jdk-" + version).start(); - - var json = new JSONObject(new String(process.getInputStream().readAllBytes())); - process.waitFor(); - return json.getString("hash"); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - private final String featureNumber; - private final String infoJsonPath; - private final JSONObject jsonInfo; - - public String getCurrentVersion() { - return this.jsonInfo.getJSONObject(this.featureNumber).getString("version"); - } - - public String getRepo() { - return this.jsonInfo.getJSONObject(this.featureNumber).getString("repo"); - } - - public JSONObject getJsonInfo() { - try { - String infoStr = Files.readString(Path.of(this.infoJsonPath)); - return new JSONObject(infoStr); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public JavaUpdater(String featureNumber, String infoJsonPath) { - this.featureNumber = featureNumber; - this.infoJsonPath = infoJsonPath; - this.jsonInfo = getJsonInfo(); - } - - public static void main(String[] args) { - var updater = new JavaUpdater(args[0], args[1]); - String newerVersion = updater.findNewerVersion(); - if (newerVersion != null) { - updater.updateJsonInfo(newerVersion); - } - } -} From a25242518c844db78cdf8064b40e885ab60ee060 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 6 Oct 2024 02:30:49 +0100 Subject: [PATCH 05/17] openjdk: copy latest version into `generic.nix` --- .../development/compilers/openjdk/generic.nix | 260 ++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 pkgs/development/compilers/openjdk/generic.nix diff --git a/pkgs/development/compilers/openjdk/generic.nix b/pkgs/development/compilers/openjdk/generic.nix new file mode 100644 index 000000000000..420335b55bf6 --- /dev/null +++ b/pkgs/development/compilers/openjdk/generic.nix @@ -0,0 +1,260 @@ +{ stdenv +, lib +, fetchurl +, fetchpatch +, fetchFromGitHub +, pkg-config +, autoconf +, cpio +, file +, which +, unzip +, zip +, perl +, cups +, freetype +, alsa-lib +, libjpeg +, giflib +, libpng +, zlib +, lcms2 +, libX11 +, libICE +, libXrender +, libXext +, libXt +, libXtst +, libXi +, libXinerama +, libXcursor +, libXrandr +, fontconfig +, openjdk23-bootstrap +, ensureNewerSourcesForZipFilesHook +, setJavaClassPath + # TODO(@sternenseemann): gtk3 fails to evaluate in pkgsCross.ghcjs.buildPackages + # which should be fixable, this is a no-rebuild workaround for GHC. +, headless ? stdenv.targetPlatform.isGhcjs +, enableJavaFX ? false +, openjfx +, enableGtk ? true +, gtk3 +, glib +, writeShellScript +, versionCheckHook +}: + +let + + # Java version format: + # $FEATURE.$INTERIM.$UPDATE.$PATCH + # See + # https://openjdk.org/jeps/223 + # https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/Runtime.Version.html + featureVersion = "23"; + info = builtins.getAttr featureVersion (lib.importJSON ./info.json); + version = info.version; + + # when building a headless jdk, also bootstrap it with a headless jdk + openjdk-bootstrap = openjdk23-bootstrap.override { gtkSupport = !headless; }; +in + +stdenv.mkDerivation (finalAttrs: { + pname = "openjdk" + lib.optionalString headless "-headless"; + inherit version; + + src = fetchFromGitHub { + owner = "openjdk"; + repo = info.repo; + rev = "jdk-${version}"; + hash = info.hash; + }; + + nativeBuildInputs = [ pkg-config autoconf unzip ensureNewerSourcesForZipFilesHook ]; + buildInputs = [ + cpio + file + which + zip + perl + zlib + cups + freetype + alsa-lib + libjpeg + giflib + libpng + zlib + lcms2 + libX11 + libICE + libXrender + libXext + libXtst + libXt + libXtst + libXi + libXinerama + libXcursor + libXrandr + fontconfig + openjdk-bootstrap + ] ++ lib.optionals (!headless && enableGtk) [ + gtk3 + glib + ]; + + patches = [ + ./fix-java-home-jdk21.patch + ./read-truststore-from-env-jdk10.patch + ./increase-javadoc-heap-jdk13.patch + ./ignore-LegalNoticeFilePlugin-jdk18.patch + + # Fix build for gnumake-4.4.1: + # https://github.com/openjdk/jdk/pull/12992 + (fetchpatch { + name = "gnumake-4.4.1"; + url = "https://github.com/openjdk/jdk/commit/9341d135b855cc208d48e47d30cd90aafa354c36.patch"; + hash = "sha256-Qcm3ZmGCOYLZcskNjj7DYR85R4v07vYvvavrVOYL8vg="; + }) + ] ++ lib.optionals (!headless && enableGtk) [ + ./swing-use-gtk-jdk13.patch + ]; + + postPatch = '' + chmod +x configure + patchShebangs --build configure + ''; + + # JDK's build system attempts to specifically detect + # and special-case WSL, and we don't want it to do that, + # so pass the correct platform names explicitly + configurePlatforms = [ "build" "host" ]; + + + # https://openjdk.org/groups/build/doc/building.html + configureFlags = [ + "--with-boot-jdk=${openjdk-bootstrap.home}" + "--with-version-string=${version}" + "--with-vendor-version-string=(nix)" + "--enable-unlimited-crypto" + "--with-native-debug-symbols=internal" + "--with-libjpeg=system" + "--with-giflib=system" + "--with-libpng=system" + "--with-zlib=system" + "--with-lcms=system" + "--with-stdc++lib=dynamic" + ] + ++ lib.optionals stdenv.cc.isClang [ + "--with-toolchain-type=clang" + # Explicitly tell Clang to compile C++ files as C++, see + # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 + "--with-extra-cxxflags=-xc++" + ] + ++ lib.optional headless "--enable-headless-only" + ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; + + separateDebugInfo = true; + + env.NIX_CFLAGS_COMPILE = "-Wno-error"; + + NIX_LDFLAGS = toString (lib.optionals (!headless) [ + "-lfontconfig" + "-lcups" + "-lXinerama" + "-lXrandr" + "-lmagic" + ] ++ lib.optionals (!headless && enableGtk) [ + "-lgtk-3" + "-lgio-2.0" + ]); + + # -j flag is explicitly rejected by the build system: + # Error: 'make -jN' is not supported, use 'make JOBS=N' + # Note: it does not make build sequential. Build system + # still runs in parallel. + enableParallelBuilding = false; + + buildFlags = [ "images" ]; + + installPhase = '' + mkdir -p $out/lib + + mv build/*/images/jdk $out/lib/openjdk + + # Remove some broken manpages. + rm -rf $out/lib/openjdk/man/ja* + + # Mirror some stuff in top-level. + mkdir -p $out/share + ln -s $out/lib/openjdk/include $out/include + ln -s $out/lib/openjdk/man $out/share/man + + # IDEs use the provided src.zip to navigate the Java codebase (https://github.com/NixOS/nixpkgs/pull/95081) + ln -s $out/lib/openjdk/lib/src.zip $out/lib/src.zip + + # jni.h expects jni_md.h to be in the header search path. + ln -s $out/include/linux/*_md.h $out/include/ + + # Remove crap from the installation. + rm -rf $out/lib/openjdk/demo + ${lib.optionalString headless '' + rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so + ''} + + ln -s $out/lib/openjdk/bin $out/bin + ''; + + preFixup = '' + # Propagate the setJavaClassPath setup hook so that any package + # that depends on the JDK has $CLASSPATH set up properly. + mkdir -p $out/nix-support + #TODO or printWords? cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040 + echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs + + # Set JAVA_HOME automatically. + mkdir -p $out/nix-support + cat < $out/nix-support/setup-hook + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi + EOF + ''; + + postFixup = '' + # Build the set of output library directories to rpath against + LIBDIRS="" + for output in $(getAllOutputNames); do + if [ "$output" = debug ]; then continue; fi + LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort -u | tr '\n' ':'):$LIBDIRS" + done + # Add the local library paths to remove dependencies on the bootstrap + for output in $(getAllOutputNames); do + if [ "$output" = debug ]; then continue; fi + OUTPUTDIR=$(eval echo \$$output) + BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) + echo "$BINLIBS" | while read i; do + patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true + patchelf --shrink-rpath "$i" || true + done + done + ''; + + disallowedReferences = [ openjdk-bootstrap ]; + + pos = __curPos; + meta = import ./meta.nix lib featureVersion; + + nativeInstallCheckInputs = [ + versionCheckHook + ]; + versionCheckProgram = "${placeholder "out"}/bin/java"; + + doInstallCheck = true; + + passthru = { + home = "${finalAttrs.finalPackage}/lib/openjdk"; + + inherit gtk3; + }; +}) From 77acd709f994edb175dee3fc97ffa3cf858281c1 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 6 Oct 2024 02:31:03 +0100 Subject: [PATCH 06/17] openjdk: format `generic.nix` with `nixfmt-rfc-style` --- .../development/compilers/openjdk/generic.nix | 262 ++++++++++-------- 1 file changed, 139 insertions(+), 123 deletions(-) diff --git a/pkgs/development/compilers/openjdk/generic.nix b/pkgs/development/compilers/openjdk/generic.nix index 420335b55bf6..9aba729061c6 100644 --- a/pkgs/development/compilers/openjdk/generic.nix +++ b/pkgs/development/compilers/openjdk/generic.nix @@ -1,48 +1,49 @@ -{ stdenv -, lib -, fetchurl -, fetchpatch -, fetchFromGitHub -, pkg-config -, autoconf -, cpio -, file -, which -, unzip -, zip -, perl -, cups -, freetype -, alsa-lib -, libjpeg -, giflib -, libpng -, zlib -, lcms2 -, libX11 -, libICE -, libXrender -, libXext -, libXt -, libXtst -, libXi -, libXinerama -, libXcursor -, libXrandr -, fontconfig -, openjdk23-bootstrap -, ensureNewerSourcesForZipFilesHook -, setJavaClassPath +{ + stdenv, + lib, + fetchurl, + fetchpatch, + fetchFromGitHub, + pkg-config, + autoconf, + cpio, + file, + which, + unzip, + zip, + perl, + cups, + freetype, + alsa-lib, + libjpeg, + giflib, + libpng, + zlib, + lcms2, + libX11, + libICE, + libXrender, + libXext, + libXt, + libXtst, + libXi, + libXinerama, + libXcursor, + libXrandr, + fontconfig, + openjdk23-bootstrap, + ensureNewerSourcesForZipFilesHook, + setJavaClassPath, # TODO(@sternenseemann): gtk3 fails to evaluate in pkgsCross.ghcjs.buildPackages # which should be fixable, this is a no-rebuild workaround for GHC. -, headless ? stdenv.targetPlatform.isGhcjs -, enableJavaFX ? false -, openjfx -, enableGtk ? true -, gtk3 -, glib -, writeShellScript -, versionCheckHook + headless ? stdenv.targetPlatform.isGhcjs, + enableJavaFX ? false, + openjfx, + enableGtk ? true, + gtk3, + glib, + writeShellScript, + versionCheckHook, }: let @@ -71,56 +72,65 @@ stdenv.mkDerivation (finalAttrs: { hash = info.hash; }; - nativeBuildInputs = [ pkg-config autoconf unzip ensureNewerSourcesForZipFilesHook ]; - buildInputs = [ - cpio - file - which - zip - perl - zlib - cups - freetype - alsa-lib - libjpeg - giflib - libpng - zlib - lcms2 - libX11 - libICE - libXrender - libXext - libXtst - libXt - libXtst - libXi - libXinerama - libXcursor - libXrandr - fontconfig - openjdk-bootstrap - ] ++ lib.optionals (!headless && enableGtk) [ - gtk3 - glib + nativeBuildInputs = [ + pkg-config + autoconf + unzip + ensureNewerSourcesForZipFilesHook ]; + buildInputs = + [ + cpio + file + which + zip + perl + zlib + cups + freetype + alsa-lib + libjpeg + giflib + libpng + zlib + lcms2 + libX11 + libICE + libXrender + libXext + libXtst + libXt + libXtst + libXi + libXinerama + libXcursor + libXrandr + fontconfig + openjdk-bootstrap + ] + ++ lib.optionals (!headless && enableGtk) [ + gtk3 + glib + ]; - patches = [ - ./fix-java-home-jdk21.patch - ./read-truststore-from-env-jdk10.patch - ./increase-javadoc-heap-jdk13.patch - ./ignore-LegalNoticeFilePlugin-jdk18.patch + patches = + [ + ./fix-java-home-jdk21.patch + ./read-truststore-from-env-jdk10.patch + ./increase-javadoc-heap-jdk13.patch + ./ignore-LegalNoticeFilePlugin-jdk18.patch - # Fix build for gnumake-4.4.1: - # https://github.com/openjdk/jdk/pull/12992 - (fetchpatch { - name = "gnumake-4.4.1"; - url = "https://github.com/openjdk/jdk/commit/9341d135b855cc208d48e47d30cd90aafa354c36.patch"; - hash = "sha256-Qcm3ZmGCOYLZcskNjj7DYR85R4v07vYvvavrVOYL8vg="; - }) - ] ++ lib.optionals (!headless && enableGtk) [ - ./swing-use-gtk-jdk13.patch - ]; + # Fix build for gnumake-4.4.1: + # https://github.com/openjdk/jdk/pull/12992 + (fetchpatch { + name = "gnumake-4.4.1"; + url = "https://github.com/openjdk/jdk/commit/9341d135b855cc208d48e47d30cd90aafa354c36.patch"; + hash = "sha256-Qcm3ZmGCOYLZcskNjj7DYR85R4v07vYvvavrVOYL8vg="; + }) + ] + ++ lib.optionals (!headless && enableGtk) [ + ./swing-use-gtk-jdk13.patch + ]; postPatch = '' chmod +x configure @@ -130,46 +140,52 @@ stdenv.mkDerivation (finalAttrs: { # JDK's build system attempts to specifically detect # and special-case WSL, and we don't want it to do that, # so pass the correct platform names explicitly - configurePlatforms = [ "build" "host" ]; - + configurePlatforms = [ + "build" + "host" + ]; # https://openjdk.org/groups/build/doc/building.html - configureFlags = [ - "--with-boot-jdk=${openjdk-bootstrap.home}" - "--with-version-string=${version}" - "--with-vendor-version-string=(nix)" - "--enable-unlimited-crypto" - "--with-native-debug-symbols=internal" - "--with-libjpeg=system" - "--with-giflib=system" - "--with-libpng=system" - "--with-zlib=system" - "--with-lcms=system" - "--with-stdc++lib=dynamic" - ] - ++ lib.optionals stdenv.cc.isClang [ - "--with-toolchain-type=clang" - # Explicitly tell Clang to compile C++ files as C++, see - # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 - "--with-extra-cxxflags=-xc++" - ] - ++ lib.optional headless "--enable-headless-only" - ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; + configureFlags = + [ + "--with-boot-jdk=${openjdk-bootstrap.home}" + "--with-version-string=${version}" + "--with-vendor-version-string=(nix)" + "--enable-unlimited-crypto" + "--with-native-debug-symbols=internal" + "--with-libjpeg=system" + "--with-giflib=system" + "--with-libpng=system" + "--with-zlib=system" + "--with-lcms=system" + "--with-stdc++lib=dynamic" + ] + ++ lib.optionals stdenv.cc.isClang [ + "--with-toolchain-type=clang" + # Explicitly tell Clang to compile C++ files as C++, see + # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 + "--with-extra-cxxflags=-xc++" + ] + ++ lib.optional headless "--enable-headless-only" + ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; separateDebugInfo = true; env.NIX_CFLAGS_COMPILE = "-Wno-error"; - NIX_LDFLAGS = toString (lib.optionals (!headless) [ - "-lfontconfig" - "-lcups" - "-lXinerama" - "-lXrandr" - "-lmagic" - ] ++ lib.optionals (!headless && enableGtk) [ - "-lgtk-3" - "-lgio-2.0" - ]); + NIX_LDFLAGS = toString ( + lib.optionals (!headless) [ + "-lfontconfig" + "-lcups" + "-lXinerama" + "-lXrandr" + "-lmagic" + ] + ++ lib.optionals (!headless && enableGtk) [ + "-lgtk-3" + "-lgio-2.0" + ] + ); # -j flag is explicitly rejected by the build system: # Error: 'make -jN' is not supported, use 'make JOBS=N' From 9f3e8a9f0b97939c5cc79f98842db3b7940954ed Mon Sep 17 00:00:00 2001 From: Reno Dakota <170618376+paparodeo@users.noreply.github.com> Date: Wed, 23 Oct 2024 20:16:59 +0000 Subject: [PATCH 07/17] python312Packages.pytest-mpl: fix darwin fix checkphase on darwin to not access the display by using a workaround for matplotlib: https://github.com/matplotlib/matplotlib/issues/26292#issuecomment-1632887774 --- pkgs/development/python-modules/pytest-mpl/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/python-modules/pytest-mpl/default.nix b/pkgs/development/python-modules/pytest-mpl/default.nix index 26cca96a3d42..d5bfa4402cbe 100644 --- a/pkgs/development/python-modules/pytest-mpl/default.nix +++ b/pkgs/development/python-modules/pytest-mpl/default.nix @@ -43,10 +43,13 @@ buildPythonPackage rec { "tests/subtests/test_subtest.py" ]; + # need to set MPLBACKEND=agg for headless matplotlib for darwin + # https://github.com/matplotlib/matplotlib/issues/26292 # The default tolerance is too strict in our build environment # https://github.com/matplotlib/pytest-mpl/pull/9 # https://github.com/matplotlib/pytest-mpl/issues/225 preCheck = '' + export MPLBACKEND=agg substituteInPlace pytest_mpl/plugin.py \ --replace-fail "DEFAULT_TOLERANCE = 2" "DEFAULT_TOLERANCE = 10" substituteInPlace tests/test_pytest_mpl.py \ From 9bad08529e30fd43b01a587f7103cef0ca1545a1 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 18 Oct 2024 05:49:15 +0100 Subject: [PATCH 08/17] openjdk{8,11,17,21,23}: deduplicate into `generic.nix` --- pkgs/by-name/an/anyk/package.nix | 2 +- pkgs/development/compilers/openjdk/11.nix | 181 ----- .../patches}/currency-date-range-jdk10.patch | 0 .../patches}/fix-java-home-jdk10.patch | 0 .../patches}/fix-library-path-jdk11.patch | 0 .../patches}/increase-javadoc-heap.patch | 0 .../read-truststore-from-env-jdk10.patch | 0 .../patches}/swing-use-gtk-jdk10.patch | 0 .../compilers/openjdk/11/source.json | 6 + pkgs/development/compilers/openjdk/17.nix | 209 ------ .../patches}/fix-library-path-jdk17.patch | 0 .../ignore-LegalNoticeFilePlugin-jdk17.patch | 0 .../increase-javadoc-heap-jdk13.patch | 0 .../patches}/swing-use-gtk-jdk13.patch | 0 .../compilers/openjdk/17/source.json | 6 + pkgs/development/compilers/openjdk/21.nix | 195 ----- .../patches}/fix-java-home-jdk21.patch | 0 .../ignore-LegalNoticeFilePlugin-jdk18.patch | 0 .../compilers/openjdk/21/source.json | 6 + pkgs/development/compilers/openjdk/23.nix | 260 ------- .../compilers/openjdk/23/source.json | 6 + pkgs/development/compilers/openjdk/8.nix | 230 ------ .../openjdk/{ => 8}/generate-cacerts.pl | 0 .../patches}/currency-date-range-jdk8.patch | 0 .../{ => 8/patches}/fix-java-home-jdk8.patch | 0 .../patches}/fix-library-path-jdk8.patch | 0 .../read-truststore-from-env-jdk8.patch | 0 .../{ => 8/patches}/swing-use-gtk-jdk8.patch | 0 .../compilers/openjdk/8/source.json | 6 + .../development/compilers/openjdk/generic.nix | 686 ++++++++++++++---- pkgs/development/compilers/openjdk/info.json | 7 - pkgs/development/compilers/openjdk/meta.nix | 11 - .../development/tools/scenic-view/default.nix | 2 +- pkgs/top-level/all-packages.nix | 6 +- pkgs/top-level/java-packages.nix | 55 +- 35 files changed, 582 insertions(+), 1292 deletions(-) delete mode 100644 pkgs/development/compilers/openjdk/11.nix rename pkgs/development/compilers/openjdk/{ => 11/patches}/currency-date-range-jdk10.patch (100%) rename pkgs/development/compilers/openjdk/{ => 11/patches}/fix-java-home-jdk10.patch (100%) rename pkgs/development/compilers/openjdk/{ => 11/patches}/fix-library-path-jdk11.patch (100%) rename pkgs/development/compilers/openjdk/{ => 11/patches}/increase-javadoc-heap.patch (100%) rename pkgs/development/compilers/openjdk/{ => 11/patches}/read-truststore-from-env-jdk10.patch (100%) rename pkgs/development/compilers/openjdk/{ => 11/patches}/swing-use-gtk-jdk10.patch (100%) create mode 100644 pkgs/development/compilers/openjdk/11/source.json delete mode 100644 pkgs/development/compilers/openjdk/17.nix rename pkgs/development/compilers/openjdk/{ => 17/patches}/fix-library-path-jdk17.patch (100%) rename pkgs/development/compilers/openjdk/{ => 17/patches}/ignore-LegalNoticeFilePlugin-jdk17.patch (100%) rename pkgs/development/compilers/openjdk/{ => 17/patches}/increase-javadoc-heap-jdk13.patch (100%) rename pkgs/development/compilers/openjdk/{ => 17/patches}/swing-use-gtk-jdk13.patch (100%) create mode 100644 pkgs/development/compilers/openjdk/17/source.json delete mode 100644 pkgs/development/compilers/openjdk/21.nix rename pkgs/development/compilers/openjdk/{ => 21/patches}/fix-java-home-jdk21.patch (100%) rename pkgs/development/compilers/openjdk/{ => 21/patches}/ignore-LegalNoticeFilePlugin-jdk18.patch (100%) create mode 100644 pkgs/development/compilers/openjdk/21/source.json delete mode 100644 pkgs/development/compilers/openjdk/23.nix create mode 100644 pkgs/development/compilers/openjdk/23/source.json delete mode 100644 pkgs/development/compilers/openjdk/8.nix rename pkgs/development/compilers/openjdk/{ => 8}/generate-cacerts.pl (100%) rename pkgs/development/compilers/openjdk/{ => 8/patches}/currency-date-range-jdk8.patch (100%) rename pkgs/development/compilers/openjdk/{ => 8/patches}/fix-java-home-jdk8.patch (100%) rename pkgs/development/compilers/openjdk/{ => 8/patches}/fix-library-path-jdk8.patch (100%) rename pkgs/development/compilers/openjdk/{ => 8/patches}/read-truststore-from-env-jdk8.patch (100%) rename pkgs/development/compilers/openjdk/{ => 8/patches}/swing-use-gtk-jdk8.patch (100%) create mode 100644 pkgs/development/compilers/openjdk/8/source.json delete mode 100644 pkgs/development/compilers/openjdk/info.json delete mode 100644 pkgs/development/compilers/openjdk/meta.nix diff --git a/pkgs/by-name/an/anyk/package.nix b/pkgs/by-name/an/anyk/package.nix index 0bb63de00028..445b461759cf 100644 --- a/pkgs/by-name/an/anyk/package.nix +++ b/pkgs/by-name/an/anyk/package.nix @@ -28,7 +28,7 @@ let # ÁNYK needs JavaFX for the Ügyfélkapu login webview. jdkWithFX = openjdk.override { enableJavaFX = true; - openjfx = openjfx.override { withWebKit = true; }; + openjfx_jdk = openjfx.override { withWebKit = true; }; }; extraClasspath = [ diff --git a/pkgs/development/compilers/openjdk/11.nix b/pkgs/development/compilers/openjdk/11.nix deleted file mode 100644 index dfa1a0ab25ae..000000000000 --- a/pkgs/development/compilers/openjdk/11.nix +++ /dev/null @@ -1,181 +0,0 @@ -{ stdenv, lib, fetchpatch, fetchFromGitHub, bash, pkg-config, autoconf, cpio, file, which, unzip -, zip, perl, cups, freetype, harfbuzz, alsa-lib, libjpeg, giflib, libpng, zlib, lcms2 -, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama -, libXcursor, libXrandr, fontconfig, openjdk11-bootstrap -, setJavaClassPath -, headless ? false -, enableJavaFX ? false, openjfx -, enableGtk ? true, gtk3, glib -}: - -let - major = "11"; - minor = "0"; - update = "24"; - build = "8"; - - # when building a headless jdk, also bootstrap it with a headless jdk - openjdk-bootstrap = openjdk11-bootstrap.override { gtkSupport = !headless; }; - - openjdk = stdenv.mkDerivation rec { - pname = "openjdk" + lib.optionalString headless "-headless"; - version = "${major}.${minor}.${update}+${build}"; - - src = fetchFromGitHub { - owner = "openjdk"; - repo = "jdk${major}u"; - rev = "jdk-${version}"; - hash = "sha256-H/VmT6NYbbZBba7Js8xk+epVZ2kLfvlwTNgg5SQ4ljA="; - }; - - nativeBuildInputs = [ pkg-config autoconf unzip ]; - buildInputs = [ - cpio file which zip perl zlib cups freetype harfbuzz alsa-lib libjpeg giflib - libpng zlib lcms2 libX11 libICE libXrender libXext libXtst libXt libXtst - libXi libXinerama libXcursor libXrandr fontconfig openjdk-bootstrap - ] ++ lib.optionals (!headless && enableGtk) [ - gtk3 glib - ]; - - patches = [ - ./fix-java-home-jdk10.patch - ./read-truststore-from-env-jdk10.patch - ./currency-date-range-jdk10.patch - ./increase-javadoc-heap.patch - ./fix-library-path-jdk11.patch - - # Fix build for gnumake-4.4.1: - # https://github.com/openjdk/jdk/pull/12992 - (fetchpatch { - name = "gnumake-4.4.1"; - url = "https://github.com/openjdk/jdk/commit/9341d135b855cc208d48e47d30cd90aafa354c36.patch"; - hash = "sha256-Qcm3ZmGCOYLZcskNjj7DYR85R4v07vYvvavrVOYL8vg="; - }) - ] ++ lib.optionals (!headless && enableGtk) [ - ./swing-use-gtk-jdk10.patch - ]; - - preConfigure = '' - chmod +x configure - substituteInPlace configure --replace /bin/bash "${bash}/bin/bash" - ''; - - configureFlags = [ - "--with-boot-jdk=${openjdk-bootstrap.home}" - "--with-version-pre=" - "--enable-unlimited-crypto" - "--with-native-debug-symbols=internal" - "--with-freetype=system" - "--with-harfbuzz=system" - "--with-libjpeg=system" - "--with-giflib=system" - "--with-libpng=system" - "--with-zlib=system" - "--with-lcms=system" - "--with-stdc++lib=dynamic" - "--disable-warnings-as-errors" - ] - # Cannot be built by recent versions of Clang, as far as I can tell (see - # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260319). Known to - # compile with LLVM 12. - ++ lib.optionals stdenv.cc.isClang [ - "--with-toolchain-type=clang" - # Explicitly tell Clang to compile C++ files as C++, see - # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 - "--with-extra-cxxflags=-xc++" - ] - ++ lib.optional stdenv.hostPlatform.isx86_64 "--with-jvm-features=zgc" - ++ lib.optional headless "--enable-headless-only" - ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; - - separateDebugInfo = true; - - # Workaround for - # `cc1plus: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]` - # when building jtreg - env.NIX_CFLAGS_COMPILE = "-Wformat"; - - NIX_LDFLAGS = toString (lib.optionals (!headless) [ - "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic" - ] ++ lib.optionals (!headless && enableGtk) [ - "-lgtk-3" "-lgio-2.0" - ]); - - # -j flag is explicitly rejected by the build system: - # Error: 'make -jN' is not supported, use 'make JOBS=N' - # Note: it does not make build sequential. Build system - # still runs in parallel. - enableParallelBuilding = false; - - buildFlags = [ "all" ]; - - installPhase = '' - mkdir -p $out/lib - - mv build/*/images/jdk $out/lib/openjdk - - # Remove some broken manpages. - rm -rf $out/lib/openjdk/man/ja* - - # Mirror some stuff in top-level. - mkdir -p $out/share - ln -s $out/lib/openjdk/include $out/include - ln -s $out/lib/openjdk/man $out/share/man - ln -s $out/lib/openjdk/lib/src.zip $out/lib/src.zip - - # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/linux/*_md.h $out/include/ - - # Remove crap from the installation. - rm -rf $out/lib/openjdk/demo - ${lib.optionalString headless '' - rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so - ''} - - ln -s $out/lib/openjdk/bin $out/bin - ''; - - preFixup = '' - # Propagate the setJavaClassPath setup hook so that any package - # that depends on the JDK has $CLASSPATH set up properly. - mkdir -p $out/nix-support - #TODO or printWords? cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040 - echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs - - # Set JAVA_HOME automatically. - mkdir -p $out/nix-support - cat < $out/nix-support/setup-hook - if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi - EOF - ''; - - postFixup = '' - # Build the set of output library directories to rpath against - LIBDIRS="" - for output in $(getAllOutputNames); do - if [ "$output" = debug ]; then continue; fi - LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS" - done - # Add the local library paths to remove dependencies on the bootstrap - for output in $(getAllOutputNames); do - if [ "$output" = debug ]; then continue; fi - OUTPUTDIR=$(eval echo \$$output) - BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) - echo "$BINLIBS" | while read i; do - patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true - patchelf --shrink-rpath "$i" || true - done - done - ''; - - disallowedReferences = [ openjdk-bootstrap ]; - - meta = import ./meta.nix lib version; - - passthru = { - architecture = ""; - home = "${openjdk}/lib/openjdk"; - inherit gtk3; - }; - }; -in openjdk diff --git a/pkgs/development/compilers/openjdk/currency-date-range-jdk10.patch b/pkgs/development/compilers/openjdk/11/patches/currency-date-range-jdk10.patch similarity index 100% rename from pkgs/development/compilers/openjdk/currency-date-range-jdk10.patch rename to pkgs/development/compilers/openjdk/11/patches/currency-date-range-jdk10.patch diff --git a/pkgs/development/compilers/openjdk/fix-java-home-jdk10.patch b/pkgs/development/compilers/openjdk/11/patches/fix-java-home-jdk10.patch similarity index 100% rename from pkgs/development/compilers/openjdk/fix-java-home-jdk10.patch rename to pkgs/development/compilers/openjdk/11/patches/fix-java-home-jdk10.patch diff --git a/pkgs/development/compilers/openjdk/fix-library-path-jdk11.patch b/pkgs/development/compilers/openjdk/11/patches/fix-library-path-jdk11.patch similarity index 100% rename from pkgs/development/compilers/openjdk/fix-library-path-jdk11.patch rename to pkgs/development/compilers/openjdk/11/patches/fix-library-path-jdk11.patch diff --git a/pkgs/development/compilers/openjdk/increase-javadoc-heap.patch b/pkgs/development/compilers/openjdk/11/patches/increase-javadoc-heap.patch similarity index 100% rename from pkgs/development/compilers/openjdk/increase-javadoc-heap.patch rename to pkgs/development/compilers/openjdk/11/patches/increase-javadoc-heap.patch diff --git a/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk10.patch b/pkgs/development/compilers/openjdk/11/patches/read-truststore-from-env-jdk10.patch similarity index 100% rename from pkgs/development/compilers/openjdk/read-truststore-from-env-jdk10.patch rename to pkgs/development/compilers/openjdk/11/patches/read-truststore-from-env-jdk10.patch diff --git a/pkgs/development/compilers/openjdk/swing-use-gtk-jdk10.patch b/pkgs/development/compilers/openjdk/11/patches/swing-use-gtk-jdk10.patch similarity index 100% rename from pkgs/development/compilers/openjdk/swing-use-gtk-jdk10.patch rename to pkgs/development/compilers/openjdk/11/patches/swing-use-gtk-jdk10.patch diff --git a/pkgs/development/compilers/openjdk/11/source.json b/pkgs/development/compilers/openjdk/11/source.json new file mode 100644 index 000000000000..8683cdecba3d --- /dev/null +++ b/pkgs/development/compilers/openjdk/11/source.json @@ -0,0 +1,6 @@ +{ + "hash": "sha256-H/VmT6NYbbZBba7Js8xk+epVZ2kLfvlwTNgg5SQ4ljA=", + "owner": "openjdk", + "repo": "jdk11u", + "rev": "jdk-11.0.24+8" +} diff --git a/pkgs/development/compilers/openjdk/17.nix b/pkgs/development/compilers/openjdk/17.nix deleted file mode 100644 index fc2f50fc1157..000000000000 --- a/pkgs/development/compilers/openjdk/17.nix +++ /dev/null @@ -1,209 +0,0 @@ -{ stdenv, lib, fetchurl, fetchpatch, fetchFromGitHub, bash, pkg-config, autoconf, cpio -, file, which, unzip, zip, perl, cups, freetype, harfbuzz, alsa-lib, libjpeg, giflib -, libpng, zlib, lcms2, libX11, libICE, libXrender, libXext, libXt, libXtst -, libXi, libXinerama, libXcursor, libXrandr, fontconfig, openjdk17-bootstrap -, setJavaClassPath -, headless ? false -, enableJavaFX ? false, openjfx -, enableGtk ? true, gtk3, glib -}: - -let - version = { - feature = "17"; - interim = ".0.12"; - build = "7"; - }; - - # when building a headless jdk, also bootstrap it with a headless jdk - openjdk-bootstrap = openjdk17-bootstrap.override { gtkSupport = !headless; }; - - openjdk = stdenv.mkDerivation { - pname = "openjdk" + lib.optionalString headless "-headless"; - version = "${version.feature}${version.interim}+${version.build}"; - - src = fetchFromGitHub { - owner = "openjdk"; - repo = "jdk${version.feature}u"; - rev = "jdk-${version.feature}${version.interim}+${version.build}"; - hash = "sha256-9UB1H3gd+b4wWxOMgsdDPgX/IGWNORKk1gMsSjYoZMw="; - }; - - nativeBuildInputs = [ pkg-config autoconf unzip ]; - buildInputs = [ - cpio file which zip perl zlib cups freetype harfbuzz alsa-lib libjpeg giflib - libpng zlib lcms2 libX11 libICE libXrender libXext libXtst libXt libXtst - libXi libXinerama libXcursor libXrandr fontconfig openjdk-bootstrap - ] ++ lib.optionals (!headless && enableGtk) [ - gtk3 glib - ]; - - patches = [ - ./fix-java-home-jdk10.patch - ./read-truststore-from-env-jdk10.patch - ./currency-date-range-jdk10.patch - ./increase-javadoc-heap-jdk13.patch - ./ignore-LegalNoticeFilePlugin-jdk17.patch - ./fix-library-path-jdk17.patch - - # -Wformat etc. are stricter in newer gccs, per - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79677 - # so grab the work-around from - # https://src.fedoraproject.org/rpms/java-openjdk/pull-request/24 - (fetchurl { - url = "https://src.fedoraproject.org/rpms/java-openjdk/raw/06c001c7d87f2e9fe4fedeef2d993bcd5d7afa2a/f/rh1673833-remove_removal_of_wformat_during_test_compilation.patch"; - sha256 = "082lmc30x64x583vqq00c8y0wqih3y4r0mp1c4bqq36l22qv6b6r"; - }) - - # Patch borrowed from Alpine to fix build errors with musl libc and recent gcc. - # This is applied anywhere to prevent patchrot. - (fetchurl { - url = "https://git.alpinelinux.org/aports/plain/community/openjdk17/FixNullPtrCast.patch?id=41e78a067953e0b13d062d632bae6c4f8028d91c"; - sha256 = "sha256-LzmSew51+DyqqGyyMw2fbXeBluCiCYsS1nCjt9hX6zo="; - }) - - # Fix build for gnumake-4.4.1: - # https://github.com/openjdk/jdk/pull/12992 - (fetchpatch { - name = "gnumake-4.4.1"; - url = "https://github.com/openjdk/jdk/commit/9341d135b855cc208d48e47d30cd90aafa354c36.patch"; - hash = "sha256-Qcm3ZmGCOYLZcskNjj7DYR85R4v07vYvvavrVOYL8vg="; - }) - - # Backport fixes for musl 1.2.4 which are already applied in jdk21+ - # Fetching patch from chimera because they already went through the effort of rebasing it onto jdk17 - (fetchurl { - name = "lfs64.patch"; - url = "https://raw.githubusercontent.com/chimera-linux/cports/4614075d19e9c9636f3f7e476687247f63330a35/contrib/openjdk17/patches/lfs64.patch"; - hash = "sha256-t2mRbdEiumBAbIAC0zsJNwCn59WYWHsnRtuOSL6bWB4="; - }) - ] ++ lib.optionals (!headless && enableGtk) [ - ./swing-use-gtk-jdk13.patch - ]; - - postPatch = '' - chmod +x configure - patchShebangs --build configure - ''; - - # JDK's build system attempts to specifically detect - # and special-case WSL, and we don't want it to do that, - # so pass the correct platform names explicitly - configurePlatforms = ["build" "host"]; - - configureFlags = [ - "--with-boot-jdk=${openjdk-bootstrap.home}" - "--with-version-build=${version.build}" - "--with-version-opt=nixos" - "--with-version-pre=" - "--enable-unlimited-crypto" - "--with-native-debug-symbols=internal" - "--with-freetype=system" - "--with-harfbuzz=system" - "--with-libjpeg=system" - "--with-giflib=system" - "--with-libpng=system" - "--with-zlib=system" - "--with-lcms=system" - "--with-stdc++lib=dynamic" - ] - ++ lib.optionals stdenv.cc.isClang [ - "--with-toolchain-type=clang" - # Explicitly tell Clang to compile C++ files as C++, see - # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 - "--with-extra-cxxflags=-xc++" - ] - ++ lib.optional headless "--enable-headless-only" - ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; - - separateDebugInfo = true; - - env.NIX_CFLAGS_COMPILE = "-Wno-error"; - - NIX_LDFLAGS = toString (lib.optionals (!headless) [ - "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic" - ] ++ lib.optionals (!headless && enableGtk) [ - "-lgtk-3" "-lgio-2.0" - ]); - - # -j flag is explicitly rejected by the build system: - # Error: 'make -jN' is not supported, use 'make JOBS=N' - # Note: it does not make build sequential. Build system - # still runs in parallel. - enableParallelBuilding = false; - - buildFlags = [ "images" ]; - - installPhase = '' - mkdir -p $out/lib - - mv build/*/images/jdk $out/lib/openjdk - - # Remove some broken manpages. - rm -rf $out/lib/openjdk/man/ja* - - # Mirror some stuff in top-level. - mkdir -p $out/share - ln -s $out/lib/openjdk/include $out/include - ln -s $out/lib/openjdk/man $out/share/man - - # IDEs use the provided src.zip to navigate the Java codebase (https://github.com/NixOS/nixpkgs/pull/95081) - ln -s $out/lib/openjdk/lib/src.zip $out/lib/src.zip - - # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/linux/*_md.h $out/include/ - - # Remove crap from the installation. - rm -rf $out/lib/openjdk/demo - ${lib.optionalString headless '' - rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so - ''} - - ln -s $out/lib/openjdk/bin $out/bin - ''; - - preFixup = '' - # Propagate the setJavaClassPath setup hook so that any package - # that depends on the JDK has $CLASSPATH set up properly. - mkdir -p $out/nix-support - #TODO or printWords? cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040 - echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs - - # Set JAVA_HOME automatically. - mkdir -p $out/nix-support - cat < $out/nix-support/setup-hook - if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi - EOF - ''; - - postFixup = '' - # Build the set of output library directories to rpath against - LIBDIRS="" - for output in $(getAllOutputNames); do - if [ "$output" = debug ]; then continue; fi - LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort -u | tr '\n' ':'):$LIBDIRS" - done - # Add the local library paths to remove dependencies on the bootstrap - for output in $(getAllOutputNames); do - if [ "$output" = debug ]; then continue; fi - OUTPUTDIR=$(eval echo \$$output) - BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) - echo "$BINLIBS" | while read i; do - patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true - patchelf --shrink-rpath "$i" || true - done - done - ''; - - disallowedReferences = [ openjdk-bootstrap ]; - - pos = builtins.unsafeGetAttrPos "feature" version; - meta = import ./meta.nix lib version.feature; - - passthru = { - architecture = ""; - home = "${openjdk}/lib/openjdk"; - inherit gtk3; - }; - }; -in openjdk diff --git a/pkgs/development/compilers/openjdk/fix-library-path-jdk17.patch b/pkgs/development/compilers/openjdk/17/patches/fix-library-path-jdk17.patch similarity index 100% rename from pkgs/development/compilers/openjdk/fix-library-path-jdk17.patch rename to pkgs/development/compilers/openjdk/17/patches/fix-library-path-jdk17.patch diff --git a/pkgs/development/compilers/openjdk/ignore-LegalNoticeFilePlugin-jdk17.patch b/pkgs/development/compilers/openjdk/17/patches/ignore-LegalNoticeFilePlugin-jdk17.patch similarity index 100% rename from pkgs/development/compilers/openjdk/ignore-LegalNoticeFilePlugin-jdk17.patch rename to pkgs/development/compilers/openjdk/17/patches/ignore-LegalNoticeFilePlugin-jdk17.patch diff --git a/pkgs/development/compilers/openjdk/increase-javadoc-heap-jdk13.patch b/pkgs/development/compilers/openjdk/17/patches/increase-javadoc-heap-jdk13.patch similarity index 100% rename from pkgs/development/compilers/openjdk/increase-javadoc-heap-jdk13.patch rename to pkgs/development/compilers/openjdk/17/patches/increase-javadoc-heap-jdk13.patch diff --git a/pkgs/development/compilers/openjdk/swing-use-gtk-jdk13.patch b/pkgs/development/compilers/openjdk/17/patches/swing-use-gtk-jdk13.patch similarity index 100% rename from pkgs/development/compilers/openjdk/swing-use-gtk-jdk13.patch rename to pkgs/development/compilers/openjdk/17/patches/swing-use-gtk-jdk13.patch diff --git a/pkgs/development/compilers/openjdk/17/source.json b/pkgs/development/compilers/openjdk/17/source.json new file mode 100644 index 000000000000..546e2fff8a19 --- /dev/null +++ b/pkgs/development/compilers/openjdk/17/source.json @@ -0,0 +1,6 @@ +{ + "hash": "sha256-9UB1H3gd+b4wWxOMgsdDPgX/IGWNORKk1gMsSjYoZMw=", + "owner": "openjdk", + "repo": "jdk17u", + "rev": "jdk-17.0.12+7" +} diff --git a/pkgs/development/compilers/openjdk/21.nix b/pkgs/development/compilers/openjdk/21.nix deleted file mode 100644 index 3576f5af8e4a..000000000000 --- a/pkgs/development/compilers/openjdk/21.nix +++ /dev/null @@ -1,195 +0,0 @@ -{ stdenv, lib, fetchurl, fetchpatch, fetchFromGitHub, bash, pkg-config, autoconf, cpio -, file, which, unzip, zip, perl, cups, freetype, alsa-lib, libjpeg, giflib -, libpng, zlib, lcms2, libX11, libICE, libXrender, libXext, libXt, libXtst -, libXi, libXinerama, libXcursor, libXrandr, fontconfig, openjdk21-bootstrap -, ensureNewerSourcesForZipFilesHook -, setJavaClassPath -# TODO(@sternenseemann): gtk3 fails to evaluate in pkgsCross.ghcjs.buildPackages -# which should be fixable, this is a no-rebuild workaround for GHC. -, headless ? stdenv.targetPlatform.isGhcjs -, enableJavaFX ? false, openjfx -, enableGtk ? true, gtk3, glib -}: - -let - version = { - feature = "21"; - interim = ".0.4"; - build = "7"; - }; - - # when building a headless jdk, also bootstrap it with a headless jdk - openjdk-bootstrap = openjdk21-bootstrap.override { gtkSupport = !headless; }; - - openjdk = stdenv.mkDerivation { - pname = "openjdk" + lib.optionalString headless "-headless"; - version = "${version.feature}${version.interim}+${version.build}"; - - src = fetchFromGitHub { - owner = "openjdk"; - repo = "jdk${version.feature}u"; - rev = "jdk-${version.feature}${version.interim}+${version.build}"; - hash = "sha256-+xpQtQ1IQ7btVWnENT9XS5A/2VP101/+XR3BMo8BqYI="; - }; - - nativeBuildInputs = [ pkg-config autoconf unzip ensureNewerSourcesForZipFilesHook ]; - buildInputs = [ - cpio file which zip perl zlib cups freetype alsa-lib libjpeg giflib - libpng zlib lcms2 libX11 libICE libXrender libXext libXtst libXt libXtst - libXi libXinerama libXcursor libXrandr fontconfig openjdk-bootstrap - ] ++ lib.optionals (!headless && enableGtk) [ - gtk3 glib - ]; - - patches = [ - ./fix-java-home-jdk21.patch - ./read-truststore-from-env-jdk10.patch - ./currency-date-range-jdk10.patch - ./increase-javadoc-heap-jdk13.patch - ./ignore-LegalNoticeFilePlugin-jdk18.patch - - # -Wformat etc. are stricter in newer gccs, per - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79677 - # so grab the work-around from - # https://src.fedoraproject.org/rpms/java-openjdk/pull-request/24 - (fetchurl { - url = "https://src.fedoraproject.org/rpms/java-openjdk/raw/06c001c7d87f2e9fe4fedeef2d993bcd5d7afa2a/f/rh1673833-remove_removal_of_wformat_during_test_compilation.patch"; - sha256 = "082lmc30x64x583vqq00c8y0wqih3y4r0mp1c4bqq36l22qv6b6r"; - }) - - # Fix build for gnumake-4.4.1: - # https://github.com/openjdk/jdk/pull/12992 - (fetchpatch { - name = "gnumake-4.4.1"; - url = "https://github.com/openjdk/jdk/commit/9341d135b855cc208d48e47d30cd90aafa354c36.patch"; - hash = "sha256-Qcm3ZmGCOYLZcskNjj7DYR85R4v07vYvvavrVOYL8vg="; - }) - ] ++ lib.optionals (!headless && enableGtk) [ - ./swing-use-gtk-jdk13.patch - ]; - - postPatch = '' - chmod +x configure - patchShebangs --build configure - ''; - - # JDK's build system attempts to specifically detect - # and special-case WSL, and we don't want it to do that, - # so pass the correct platform names explicitly - configurePlatforms = ["build" "host"]; - - configureFlags = [ - "--with-boot-jdk=${openjdk-bootstrap.home}" - "--with-version-build=${version.build}" - "--with-version-opt=nixos" - "--with-version-pre=" - "--enable-unlimited-crypto" - "--with-native-debug-symbols=internal" - "--with-libjpeg=system" - "--with-giflib=system" - "--with-libpng=system" - "--with-zlib=system" - "--with-lcms=system" - "--with-stdc++lib=dynamic" - ] - ++ lib.optionals stdenv.cc.isClang [ - "--with-toolchain-type=clang" - # Explicitly tell Clang to compile C++ files as C++, see - # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 - "--with-extra-cxxflags=-xc++" - ] - ++ lib.optional stdenv.hostPlatform.isx86_64 "--with-jvm-features=zgc" - ++ lib.optional headless "--enable-headless-only" - ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; - - separateDebugInfo = true; - - env.NIX_CFLAGS_COMPILE = "-Wno-error"; - - NIX_LDFLAGS = toString (lib.optionals (!headless) [ - "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic" - ] ++ lib.optionals (!headless && enableGtk) [ - "-lgtk-3" "-lgio-2.0" - ]); - - # -j flag is explicitly rejected by the build system: - # Error: 'make -jN' is not supported, use 'make JOBS=N' - # Note: it does not make build sequential. Build system - # still runs in parallel. - enableParallelBuilding = false; - - buildFlags = [ "images" ]; - - installPhase = '' - mkdir -p $out/lib - - mv build/*/images/jdk $out/lib/openjdk - - # Remove some broken manpages. - rm -rf $out/lib/openjdk/man/ja* - - # Mirror some stuff in top-level. - mkdir -p $out/share - ln -s $out/lib/openjdk/include $out/include - ln -s $out/lib/openjdk/man $out/share/man - - # IDEs use the provided src.zip to navigate the Java codebase (https://github.com/NixOS/nixpkgs/pull/95081) - ln -s $out/lib/openjdk/lib/src.zip $out/lib/src.zip - - # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/linux/*_md.h $out/include/ - - # Remove crap from the installation. - rm -rf $out/lib/openjdk/demo - ${lib.optionalString headless '' - rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so - ''} - - ln -s $out/lib/openjdk/bin $out/bin - ''; - - preFixup = '' - # Propagate the setJavaClassPath setup hook so that any package - # that depends on the JDK has $CLASSPATH set up properly. - mkdir -p $out/nix-support - #TODO or printWords? cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040 - echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs - - # Set JAVA_HOME automatically. - mkdir -p $out/nix-support - cat < $out/nix-support/setup-hook - if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi - EOF - ''; - - postFixup = '' - # Build the set of output library directories to rpath against - LIBDIRS="" - for output in $(getAllOutputNames); do - if [ "$output" = debug ]; then continue; fi - LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort -u | tr '\n' ':'):$LIBDIRS" - done - # Add the local library paths to remove dependencies on the bootstrap - for output in $(getAllOutputNames); do - if [ "$output" = debug ]; then continue; fi - OUTPUTDIR=$(eval echo \$$output) - BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) - echo "$BINLIBS" | while read i; do - patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true - patchelf --shrink-rpath "$i" || true - done - done - ''; - - disallowedReferences = [ openjdk-bootstrap ]; - - pos = builtins.unsafeGetAttrPos "feature" version; - meta = import ./meta.nix lib version.feature; - - passthru = { - architecture = ""; - home = "${openjdk}/lib/openjdk"; - inherit gtk3; - }; - }; -in openjdk diff --git a/pkgs/development/compilers/openjdk/fix-java-home-jdk21.patch b/pkgs/development/compilers/openjdk/21/patches/fix-java-home-jdk21.patch similarity index 100% rename from pkgs/development/compilers/openjdk/fix-java-home-jdk21.patch rename to pkgs/development/compilers/openjdk/21/patches/fix-java-home-jdk21.patch diff --git a/pkgs/development/compilers/openjdk/ignore-LegalNoticeFilePlugin-jdk18.patch b/pkgs/development/compilers/openjdk/21/patches/ignore-LegalNoticeFilePlugin-jdk18.patch similarity index 100% rename from pkgs/development/compilers/openjdk/ignore-LegalNoticeFilePlugin-jdk18.patch rename to pkgs/development/compilers/openjdk/21/patches/ignore-LegalNoticeFilePlugin-jdk18.patch diff --git a/pkgs/development/compilers/openjdk/21/source.json b/pkgs/development/compilers/openjdk/21/source.json new file mode 100644 index 000000000000..d0db28246a84 --- /dev/null +++ b/pkgs/development/compilers/openjdk/21/source.json @@ -0,0 +1,6 @@ +{ + "hash": "sha256-+xpQtQ1IQ7btVWnENT9XS5A/2VP101/+XR3BMo8BqYI=", + "owner": "openjdk", + "repo": "jdk21u", + "rev": "jdk-21.0.4+7" +} diff --git a/pkgs/development/compilers/openjdk/23.nix b/pkgs/development/compilers/openjdk/23.nix deleted file mode 100644 index 420335b55bf6..000000000000 --- a/pkgs/development/compilers/openjdk/23.nix +++ /dev/null @@ -1,260 +0,0 @@ -{ stdenv -, lib -, fetchurl -, fetchpatch -, fetchFromGitHub -, pkg-config -, autoconf -, cpio -, file -, which -, unzip -, zip -, perl -, cups -, freetype -, alsa-lib -, libjpeg -, giflib -, libpng -, zlib -, lcms2 -, libX11 -, libICE -, libXrender -, libXext -, libXt -, libXtst -, libXi -, libXinerama -, libXcursor -, libXrandr -, fontconfig -, openjdk23-bootstrap -, ensureNewerSourcesForZipFilesHook -, setJavaClassPath - # TODO(@sternenseemann): gtk3 fails to evaluate in pkgsCross.ghcjs.buildPackages - # which should be fixable, this is a no-rebuild workaround for GHC. -, headless ? stdenv.targetPlatform.isGhcjs -, enableJavaFX ? false -, openjfx -, enableGtk ? true -, gtk3 -, glib -, writeShellScript -, versionCheckHook -}: - -let - - # Java version format: - # $FEATURE.$INTERIM.$UPDATE.$PATCH - # See - # https://openjdk.org/jeps/223 - # https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/Runtime.Version.html - featureVersion = "23"; - info = builtins.getAttr featureVersion (lib.importJSON ./info.json); - version = info.version; - - # when building a headless jdk, also bootstrap it with a headless jdk - openjdk-bootstrap = openjdk23-bootstrap.override { gtkSupport = !headless; }; -in - -stdenv.mkDerivation (finalAttrs: { - pname = "openjdk" + lib.optionalString headless "-headless"; - inherit version; - - src = fetchFromGitHub { - owner = "openjdk"; - repo = info.repo; - rev = "jdk-${version}"; - hash = info.hash; - }; - - nativeBuildInputs = [ pkg-config autoconf unzip ensureNewerSourcesForZipFilesHook ]; - buildInputs = [ - cpio - file - which - zip - perl - zlib - cups - freetype - alsa-lib - libjpeg - giflib - libpng - zlib - lcms2 - libX11 - libICE - libXrender - libXext - libXtst - libXt - libXtst - libXi - libXinerama - libXcursor - libXrandr - fontconfig - openjdk-bootstrap - ] ++ lib.optionals (!headless && enableGtk) [ - gtk3 - glib - ]; - - patches = [ - ./fix-java-home-jdk21.patch - ./read-truststore-from-env-jdk10.patch - ./increase-javadoc-heap-jdk13.patch - ./ignore-LegalNoticeFilePlugin-jdk18.patch - - # Fix build for gnumake-4.4.1: - # https://github.com/openjdk/jdk/pull/12992 - (fetchpatch { - name = "gnumake-4.4.1"; - url = "https://github.com/openjdk/jdk/commit/9341d135b855cc208d48e47d30cd90aafa354c36.patch"; - hash = "sha256-Qcm3ZmGCOYLZcskNjj7DYR85R4v07vYvvavrVOYL8vg="; - }) - ] ++ lib.optionals (!headless && enableGtk) [ - ./swing-use-gtk-jdk13.patch - ]; - - postPatch = '' - chmod +x configure - patchShebangs --build configure - ''; - - # JDK's build system attempts to specifically detect - # and special-case WSL, and we don't want it to do that, - # so pass the correct platform names explicitly - configurePlatforms = [ "build" "host" ]; - - - # https://openjdk.org/groups/build/doc/building.html - configureFlags = [ - "--with-boot-jdk=${openjdk-bootstrap.home}" - "--with-version-string=${version}" - "--with-vendor-version-string=(nix)" - "--enable-unlimited-crypto" - "--with-native-debug-symbols=internal" - "--with-libjpeg=system" - "--with-giflib=system" - "--with-libpng=system" - "--with-zlib=system" - "--with-lcms=system" - "--with-stdc++lib=dynamic" - ] - ++ lib.optionals stdenv.cc.isClang [ - "--with-toolchain-type=clang" - # Explicitly tell Clang to compile C++ files as C++, see - # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 - "--with-extra-cxxflags=-xc++" - ] - ++ lib.optional headless "--enable-headless-only" - ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; - - separateDebugInfo = true; - - env.NIX_CFLAGS_COMPILE = "-Wno-error"; - - NIX_LDFLAGS = toString (lib.optionals (!headless) [ - "-lfontconfig" - "-lcups" - "-lXinerama" - "-lXrandr" - "-lmagic" - ] ++ lib.optionals (!headless && enableGtk) [ - "-lgtk-3" - "-lgio-2.0" - ]); - - # -j flag is explicitly rejected by the build system: - # Error: 'make -jN' is not supported, use 'make JOBS=N' - # Note: it does not make build sequential. Build system - # still runs in parallel. - enableParallelBuilding = false; - - buildFlags = [ "images" ]; - - installPhase = '' - mkdir -p $out/lib - - mv build/*/images/jdk $out/lib/openjdk - - # Remove some broken manpages. - rm -rf $out/lib/openjdk/man/ja* - - # Mirror some stuff in top-level. - mkdir -p $out/share - ln -s $out/lib/openjdk/include $out/include - ln -s $out/lib/openjdk/man $out/share/man - - # IDEs use the provided src.zip to navigate the Java codebase (https://github.com/NixOS/nixpkgs/pull/95081) - ln -s $out/lib/openjdk/lib/src.zip $out/lib/src.zip - - # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/linux/*_md.h $out/include/ - - # Remove crap from the installation. - rm -rf $out/lib/openjdk/demo - ${lib.optionalString headless '' - rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so - ''} - - ln -s $out/lib/openjdk/bin $out/bin - ''; - - preFixup = '' - # Propagate the setJavaClassPath setup hook so that any package - # that depends on the JDK has $CLASSPATH set up properly. - mkdir -p $out/nix-support - #TODO or printWords? cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040 - echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs - - # Set JAVA_HOME automatically. - mkdir -p $out/nix-support - cat < $out/nix-support/setup-hook - if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi - EOF - ''; - - postFixup = '' - # Build the set of output library directories to rpath against - LIBDIRS="" - for output in $(getAllOutputNames); do - if [ "$output" = debug ]; then continue; fi - LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort -u | tr '\n' ':'):$LIBDIRS" - done - # Add the local library paths to remove dependencies on the bootstrap - for output in $(getAllOutputNames); do - if [ "$output" = debug ]; then continue; fi - OUTPUTDIR=$(eval echo \$$output) - BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) - echo "$BINLIBS" | while read i; do - patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true - patchelf --shrink-rpath "$i" || true - done - done - ''; - - disallowedReferences = [ openjdk-bootstrap ]; - - pos = __curPos; - meta = import ./meta.nix lib featureVersion; - - nativeInstallCheckInputs = [ - versionCheckHook - ]; - versionCheckProgram = "${placeholder "out"}/bin/java"; - - doInstallCheck = true; - - passthru = { - home = "${finalAttrs.finalPackage}/lib/openjdk"; - - inherit gtk3; - }; -}) diff --git a/pkgs/development/compilers/openjdk/23/source.json b/pkgs/development/compilers/openjdk/23/source.json new file mode 100644 index 000000000000..b47426326ecd --- /dev/null +++ b/pkgs/development/compilers/openjdk/23/source.json @@ -0,0 +1,6 @@ +{ + "hash": "sha256-lcLnWAiskWindOqWmOWiIHiYKXGSJZK4d20k19QZfrE=", + "owner": "openjdk", + "repo": "jdk23u", + "rev": "jdk-23-ga" +} diff --git a/pkgs/development/compilers/openjdk/8.nix b/pkgs/development/compilers/openjdk/8.nix deleted file mode 100644 index 831d5e8d49c3..000000000000 --- a/pkgs/development/compilers/openjdk/8.nix +++ /dev/null @@ -1,230 +0,0 @@ -{ stdenv, lib, fetchFromGitHub, pkg-config, lndir, bash, cpio, file, which, unzip, zip -, cups, freetype, alsa-lib, cacert, perl, liberation_ttf, fontconfig, zlib -, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama, libXcursor, libXrandr -, libjpeg, giflib -, openjdk8-bootstrap -, setJavaClassPath -, headless ? false -, enableGtk ? true, gtk2, glib -}: - -let - - /** - * The JRE libraries are in directories that depend on the CPU. - */ - architecture = { - i686-linux = "i386"; - x86_64-linux = "amd64"; - aarch64-linux = "aarch64"; - powerpc64le-linux = "ppc64le"; - }.${stdenv.system} or (throw "Unsupported platform ${stdenv.system}"); - - update = "422"; - build = "ga"; - - # when building a headless jdk, also bootstrap it with a headless jdk - openjdk-bootstrap = openjdk8-bootstrap.override { gtkSupport = !headless; }; - - openjdk8 = stdenv.mkDerivation rec { - pname = "openjdk" + lib.optionalString headless "-headless"; - version = "8u${update}-${build}"; - - src = fetchFromGitHub { - owner = "openjdk"; - repo = "jdk8u"; - rev = "jdk${version}"; - hash = "sha256-uMo1DIkji+FPTbFRwURXybkLE5xv+teSClWP9RfAvfo="; - }; - outputs = [ "out" "jre" ]; - - nativeBuildInputs = [ pkg-config lndir unzip ]; - buildInputs = [ - cpio file which zip perl zlib cups freetype alsa-lib - libjpeg giflib libX11 libICE libXext libXrender libXtst libXt libXtst - libXi libXinerama libXcursor libXrandr fontconfig openjdk-bootstrap - ] ++ lib.optionals (!headless && enableGtk) [ - gtk2 glib - ]; - - patches = [ - ./fix-java-home-jdk8.patch - ./read-truststore-from-env-jdk8.patch - ./currency-date-range-jdk8.patch - ./fix-library-path-jdk8.patch - ] ++ lib.optionals (!headless && enableGtk) [ - ./swing-use-gtk-jdk8.patch - ]; - - # Hotspot cares about the host(!) version otherwise - DISABLE_HOTSPOT_OS_VERSION_CHECK = "ok"; - - preConfigure = '' - chmod +x configure - substituteInPlace configure --replace /bin/bash "${bash}/bin/bash" - substituteInPlace hotspot/make/linux/adlc_updater --replace /bin/sh "${stdenv.shell}" - substituteInPlace hotspot/make/linux/makefiles/dtrace.make --replace /usr/include/sys/sdt.h "/no-such-path" - ''; - - configureFlags = [ - "--with-boot-jdk=${openjdk-bootstrap.home}" - "--with-update-version=${update}" - "--with-build-number=${build}" - "--with-milestone=fcs" - "--enable-unlimited-crypto" - "--with-native-debug-symbols=internal" - "--disable-freetype-bundling" - "--with-zlib=system" - "--with-giflib=system" - "--with-stdc++lib=dynamic" - ] ++ lib.optional headless "--disable-headful"; - - separateDebugInfo = true; - - env.NIX_CFLAGS_COMPILE = toString ([ - # glibc 2.24 deprecated readdir_r so we need this - # See https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg49006.html - "-Wno-error=deprecated-declarations" - ] ++ lib.optionals stdenv.cc.isGNU [ - # https://bugzilla.redhat.com/show_bug.cgi?id=1306558 - # https://github.com/JetBrains/jdk8u/commit/eaa5e0711a43d64874111254d74893fa299d5716 - "-fno-lifetime-dse" - "-fno-delete-null-pointer-checks" - "-std=gnu++98" - "-Wno-error" - ]); - - NIX_LDFLAGS= toString (lib.optionals (!headless) [ - "-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic" - ] ++ lib.optionals (!headless && enableGtk) [ - "-lgtk-x11-2.0" "-lgio-2.0" - ]); - - # -j flag is explicitly rejected by the build system: - # Error: 'make -jN' is not supported, use 'make JOBS=N' - # Note: it does not make build sequential. Build system - # still runs in parallel. - enableParallelBuilding = false; - - buildFlags = [ "all" ]; - - doCheck = false; # fails with "No rule to make target 'y'." - - installPhase = '' - mkdir -p $out/lib - - mv build/*/images/j2sdk-image $out/lib/openjdk - - # Remove some broken manpages. - rm -rf $out/lib/openjdk/man/ja* - - # Mirror some stuff in top-level. - mkdir -p $out/share - ln -s $out/lib/openjdk/include $out/include - ln -s $out/lib/openjdk/man $out/share/man - - # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/linux/*_md.h $out/include/ - - # Remove crap from the installation. - rm -rf $out/lib/openjdk/demo $out/lib/openjdk/sample - ${lib.optionalString headless '' - rm $out/lib/openjdk/jre/lib/${architecture}/{libjsound,libjsoundalsa,libsplashscreen,libawt*,libfontmanager}.so - rm $out/lib/openjdk/jre/bin/policytool - rm $out/lib/openjdk/bin/{policytool,appletviewer} - ''} - - # Move the JRE to a separate output - mkdir -p $jre/lib/openjdk - mv $out/lib/openjdk/jre $jre/lib/openjdk/jre - mkdir $out/lib/openjdk/jre - lndir $jre/lib/openjdk/jre $out/lib/openjdk/jre - - # Make sure cmm/*.pf are not symlinks: - # https://youtrack.jetbrains.com/issue/IDEA-147272 - rm -rf $out/lib/openjdk/jre/lib/cmm - ln -s {$jre,$out}/lib/openjdk/jre/lib/cmm - - # Setup fallback fonts - ${lib.optionalString (!headless) '' - mkdir -p $jre/lib/openjdk/jre/lib/fonts - ln -s ${liberation_ttf}/share/fonts/truetype $jre/lib/openjdk/jre/lib/fonts/fallback - ''} - - # Remove duplicate binaries. - for i in $(cd $out/lib/openjdk/bin && echo *); do - if [ "$i" = java ]; then continue; fi - if cmp -s $out/lib/openjdk/bin/$i $jre/lib/openjdk/jre/bin/$i; then - ln -sfn $jre/lib/openjdk/jre/bin/$i $out/lib/openjdk/bin/$i - fi - done - - # Generate certificates. - ( - cd $jre/lib/openjdk/jre/lib/security - rm cacerts - perl ${./generate-cacerts.pl} $jre/lib/openjdk/jre/bin/keytool ${cacert}/etc/ssl/certs/ca-bundle.crt - ) - - ln -s $out/lib/openjdk/bin $out/bin - ln -s $jre/lib/openjdk/jre/bin $jre/bin - ln -s $jre/lib/openjdk/jre $out/jre - ''; - - propagatedBuildInputs = [ setJavaClassPath ]; - - preFixup = '' - # Propagate the setJavaClassPath setup hook from the JRE so that - # any package that depends on the JRE has $CLASSPATH set up - # properly. - mkdir -p $jre/nix-support - printWords ${setJavaClassPath} > $jre/nix-support/propagated-build-inputs - - # Set JAVA_HOME automatically. - mkdir -p $out/nix-support - cat < $out/nix-support/setup-hook - if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi - EOF - ''; - - postFixup = '' - # Build the set of output library directories to rpath against - LIBDIRS="" - for output in $(getAllOutputNames); do - if [ "$output" = debug ]; then continue; fi - LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS" - done - # Add the local library paths to remove dependencies on the bootstrap - for output in $(getAllOutputNames); do - if [ "$output" = debug ]; then continue; fi - OUTPUTDIR=$(eval echo \$$output) - BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) - echo "$BINLIBS" | while read i; do - patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true - patchelf --shrink-rpath "$i" || true - done - done - ''; - - disallowedReferences = [ openjdk8-bootstrap ]; - - meta = with lib; { - homepage = "http://openjdk.java.net/"; - license = licenses.gpl2; - description = "Open-source Java Development Kit"; - maintainers = with maintainers; [ edwtjo ]; - platforms = [ "i686-linux" "x86_64-linux" "aarch64-linux" ]; - mainProgram = "java"; - # Broken for musl at 2024-01-17. Tracking issue: - # https://github.com/NixOS/nixpkgs/issues/281618 - # error: ‘isnanf’ was not declared in this scope - broken = stdenv.hostPlatform.isMusl; - }; - - passthru = { - inherit architecture; - home = "${openjdk8}/lib/openjdk"; - inherit gtk2; - }; - }; -in openjdk8 diff --git a/pkgs/development/compilers/openjdk/generate-cacerts.pl b/pkgs/development/compilers/openjdk/8/generate-cacerts.pl similarity index 100% rename from pkgs/development/compilers/openjdk/generate-cacerts.pl rename to pkgs/development/compilers/openjdk/8/generate-cacerts.pl diff --git a/pkgs/development/compilers/openjdk/currency-date-range-jdk8.patch b/pkgs/development/compilers/openjdk/8/patches/currency-date-range-jdk8.patch similarity index 100% rename from pkgs/development/compilers/openjdk/currency-date-range-jdk8.patch rename to pkgs/development/compilers/openjdk/8/patches/currency-date-range-jdk8.patch diff --git a/pkgs/development/compilers/openjdk/fix-java-home-jdk8.patch b/pkgs/development/compilers/openjdk/8/patches/fix-java-home-jdk8.patch similarity index 100% rename from pkgs/development/compilers/openjdk/fix-java-home-jdk8.patch rename to pkgs/development/compilers/openjdk/8/patches/fix-java-home-jdk8.patch diff --git a/pkgs/development/compilers/openjdk/fix-library-path-jdk8.patch b/pkgs/development/compilers/openjdk/8/patches/fix-library-path-jdk8.patch similarity index 100% rename from pkgs/development/compilers/openjdk/fix-library-path-jdk8.patch rename to pkgs/development/compilers/openjdk/8/patches/fix-library-path-jdk8.patch diff --git a/pkgs/development/compilers/openjdk/read-truststore-from-env-jdk8.patch b/pkgs/development/compilers/openjdk/8/patches/read-truststore-from-env-jdk8.patch similarity index 100% rename from pkgs/development/compilers/openjdk/read-truststore-from-env-jdk8.patch rename to pkgs/development/compilers/openjdk/8/patches/read-truststore-from-env-jdk8.patch diff --git a/pkgs/development/compilers/openjdk/swing-use-gtk-jdk8.patch b/pkgs/development/compilers/openjdk/8/patches/swing-use-gtk-jdk8.patch similarity index 100% rename from pkgs/development/compilers/openjdk/swing-use-gtk-jdk8.patch rename to pkgs/development/compilers/openjdk/8/patches/swing-use-gtk-jdk8.patch diff --git a/pkgs/development/compilers/openjdk/8/source.json b/pkgs/development/compilers/openjdk/8/source.json new file mode 100644 index 000000000000..47ad1dc0596a --- /dev/null +++ b/pkgs/development/compilers/openjdk/8/source.json @@ -0,0 +1,6 @@ +{ + "hash": "sha256-uMo1DIkji+FPTbFRwURXybkLE5xv+teSClWP9RfAvfo=", + "owner": "openjdk", + "repo": "jdk8u", + "rev": "jdk8u422-ga" +} diff --git a/pkgs/development/compilers/openjdk/generic.nix b/pkgs/development/compilers/openjdk/generic.nix index 9aba729061c6..00a66512161e 100644 --- a/pkgs/development/compilers/openjdk/generic.nix +++ b/pkgs/development/compilers/openjdk/generic.nix @@ -1,125 +1,216 @@ { - stdenv, + featureVersion, + lib, + stdenv, + + fetchFromGitHub, fetchurl, fetchpatch, - fetchFromGitHub, + pkg-config, autoconf, + lndir, + unzip, + ensureNewerSourcesForZipFilesHook, + cpio, file, which, - unzip, zip, perl, + zlib, cups, freetype, + harfbuzz, alsa-lib, libjpeg, giflib, libpng, - zlib, lcms2, libX11, libICE, - libXrender, libXext, - libXt, + libXrender, libXtst, + libXt, libXi, libXinerama, libXcursor, libXrandr, fontconfig, - openjdk23-bootstrap, - ensureNewerSourcesForZipFilesHook, + setJavaClassPath, + + versionCheckHook, + + bash, + liberation_ttf, + cacert, + # TODO(@sternenseemann): gtk3 fails to evaluate in pkgsCross.ghcjs.buildPackages # which should be fixable, this is a no-rebuild workaround for GHC. - headless ? stdenv.targetPlatform.isGhcjs, + headless ? lib.versionAtLeast featureVersion "21" && stdenv.targetPlatform.isGhcjs, + enableJavaFX ? false, - openjfx, + openjfx17, + openjfx21, + openjfx23, + openjfx_jdk ? + { + "17" = openjfx17; + "21" = openjfx21; + "23" = openjfx23; + } + .${featureVersion} or (throw "JavaFX is not supported on OpenJDK ${featureVersion}"), + enableGtk ? true, gtk3, + gtk2, glib, - writeShellScript, - versionCheckHook, + + temurin-bin-8, + temurin-bin-11, + temurin-bin-17, + temurin-bin-21, + temurin-bin-23, + jdk-bootstrap ? + { + "8" = temurin-bin-8; + "11" = temurin-bin-11; + "17" = temurin-bin-17; + "21" = temurin-bin-21; + "23" = temurin-bin-23; + } + .${featureVersion}, }: let + sourceFile = ./. + "/${featureVersion}/source.json"; + sourceInfo = lib.importJSON sourceFile; - # Java version format: - # $FEATURE.$INTERIM.$UPDATE.$PATCH - # See - # https://openjdk.org/jeps/223 - # https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/Runtime.Version.html - featureVersion = "23"; - info = builtins.getAttr featureVersion (lib.importJSON ./info.json); - version = info.version; + atLeast11 = lib.versionAtLeast featureVersion "11"; + atLeast17 = lib.versionAtLeast featureVersion "17"; + atLeast21 = lib.versionAtLeast featureVersion "21"; + atLeast23 = lib.versionAtLeast featureVersion "23"; - # when building a headless jdk, also bootstrap it with a headless jdk - openjdk-bootstrap = openjdk23-bootstrap.override { gtkSupport = !headless; }; + tagPrefix = if atLeast11 then "jdk-" else "jdk"; + # TODO: Merge these `lib.removePrefix` calls once update scripts have + # been run. + version = lib.removePrefix tagPrefix (lib.removePrefix "refs/tags/" sourceInfo.rev); + versionSplit = + # TODO: Remove `-ga` logic once update scripts have been run. + builtins.match (if atLeast11 then "(.+)[-+](.+)" else "(.+)-b?(.+)") version; + versionBuild = lib.elemAt versionSplit 1; + + # The JRE 8 libraries are in directories that depend on the CPU. + architecture = + if atLeast11 then + "" + else + { + i686-linux = "i386"; + x86_64-linux = "amd64"; + aarch64-linux = "aarch64"; + powerpc64le-linux = "ppc64le"; + } + .${stdenv.system} or (throw "Unsupported platform ${stdenv.system}"); + + jdk-bootstrap' = jdk-bootstrap.override { + # when building a headless jdk, also bootstrap it with a headless jdk + gtkSupport = !headless; + }; in +assert lib.assertMsg (lib.pathExists sourceFile) + "OpenJDK ${featureVersion} is not a supported version"; + stdenv.mkDerivation (finalAttrs: { pname = "openjdk" + lib.optionalString headless "-headless"; inherit version; - src = fetchFromGitHub { - owner = "openjdk"; - repo = info.repo; - rev = "jdk-${version}"; - hash = info.hash; - }; - - nativeBuildInputs = [ - pkg-config - autoconf - unzip - ensureNewerSourcesForZipFilesHook - ]; - buildInputs = + outputs = [ - cpio - file - which - zip - perl - zlib - cups - freetype - alsa-lib - libjpeg - giflib - libpng - zlib - lcms2 - libX11 - libICE - libXrender - libXext - libXtst - libXt - libXtst - libXi - libXinerama - libXcursor - libXrandr - fontconfig - openjdk-bootstrap + "out" ] - ++ lib.optionals (!headless && enableGtk) [ - gtk3 - glib + ++ lib.optionals (!atLeast11) [ + "jre" ]; + src = fetchFromGitHub { + inherit (sourceInfo) owner repo rev hash; + }; + patches = [ - ./fix-java-home-jdk21.patch - ./read-truststore-from-env-jdk10.patch - ./increase-javadoc-heap-jdk13.patch - ./ignore-LegalNoticeFilePlugin-jdk18.patch - + ( + if atLeast21 then + ./21/patches/fix-java-home-jdk21.patch + else if atLeast11 then + ./11/patches/fix-java-home-jdk10.patch + else + ./8/patches/fix-java-home-jdk8.patch + ) + ( + if atLeast11 then + ./11/patches/read-truststore-from-env-jdk10.patch + else + ./8/patches/read-truststore-from-env-jdk8.patch + ) + ] + ++ lib.optionals (!atLeast23) [ + ( + if atLeast11 then + ./11/patches/currency-date-range-jdk10.patch + else + ./8/patches/currency-date-range-jdk8.patch + ) + ] + ++ lib.optionals atLeast11 [ + ( + if atLeast17 then + ./17/patches/increase-javadoc-heap-jdk13.patch + else + ./11/patches/increase-javadoc-heap.patch + ) + ] + ++ lib.optionals atLeast17 [ + ( + if atLeast21 then + ./21/patches/ignore-LegalNoticeFilePlugin-jdk18.patch + else + ./17/patches/ignore-LegalNoticeFilePlugin-jdk17.patch + ) + ] + ++ lib.optionals (!atLeast21) [ + ( + if atLeast17 then + ./17/patches/fix-library-path-jdk17.patch + else if atLeast11 then + ./11/patches/fix-library-path-jdk11.patch + else + ./8/patches/fix-library-path-jdk8.patch + ) + ] + ++ lib.optionals (atLeast17 && !atLeast23) [ + # -Wformat etc. are stricter in newer gccs, per + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79677 + # so grab the work-around from + # https://src.fedoraproject.org/rpms/java-openjdk/pull-request/24 + (fetchurl { + url = "https://src.fedoraproject.org/rpms/java-openjdk/raw/06c001c7d87f2e9fe4fedeef2d993bcd5d7afa2a/f/rh1673833-remove_removal_of_wformat_during_test_compilation.patch"; + sha256 = "082lmc30x64x583vqq00c8y0wqih3y4r0mp1c4bqq36l22qv6b6r"; + }) + ] + ++ lib.optionals (featureVersion == "17") [ + # Patch borrowed from Alpine to fix build errors with musl libc and recent gcc. + # This is applied anywhere to prevent patchrot. + (fetchurl { + url = "https://git.alpinelinux.org/aports/plain/community/openjdk17/FixNullPtrCast.patch?id=41e78a067953e0b13d062d632bae6c4f8028d91c"; + sha256 = "sha256-LzmSew51+DyqqGyyMw2fbXeBluCiCYsS1nCjt9hX6zo="; + }) + ] + ++ lib.optionals atLeast11 [ # Fix build for gnumake-4.4.1: # https://github.com/openjdk/jdk/pull/12992 (fetchpatch { @@ -128,19 +219,107 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-Qcm3ZmGCOYLZcskNjj7DYR85R4v07vYvvavrVOYL8vg="; }) ] + ++ lib.optionals (featureVersion == "17") [ + # Backport fixes for musl 1.2.4 which are already applied in jdk21+ + # Fetching patch from chimera because they already went through the effort of rebasing it onto jdk17 + (fetchurl { + name = "lfs64.patch"; + url = "https://raw.githubusercontent.com/chimera-linux/cports/4614075d19e9c9636f3f7e476687247f63330a35/contrib/openjdk17/patches/lfs64.patch"; + hash = "sha256-t2mRbdEiumBAbIAC0zsJNwCn59WYWHsnRtuOSL6bWB4="; + }) + ] ++ lib.optionals (!headless && enableGtk) [ - ./swing-use-gtk-jdk13.patch + ( + if atLeast17 then + ./17/patches/swing-use-gtk-jdk13.patch + else if atLeast11 then + ./11/patches/swing-use-gtk-jdk10.patch + else + ./8/patches/swing-use-gtk-jdk8.patch + ) ]; - postPatch = '' - chmod +x configure - patchShebangs --build configure - ''; + nativeBuildInputs = + [ + pkg-config + ] + ++ lib.optionals atLeast11 [ + autoconf + ] + ++ lib.optionals (!atLeast11) [ + lndir + ] + ++ [ + unzip + ] + ++ lib.optionals atLeast21 [ + ensureNewerSourcesForZipFilesHook + ]; + + buildInputs = + [ + # TODO: Many of these should likely be in `nativeBuildInputs`. + cpio + file + which + zip + perl + zlib + cups + freetype + ] + ++ lib.optionals (atLeast11 && !atLeast21) [ + harfbuzz + ] + ++ [ + alsa-lib + libjpeg + giflib + ] + ++ lib.optionals atLeast11 [ + libpng + zlib # duplicate + lcms2 + ] + ++ [ + libX11 + libICE + ] + ++ lib.optionals (!atLeast11) [ + libXext + ] + ++ [ + libXrender + ] + ++ lib.optionals atLeast11 [ + libXext + ] + ++ [ + libXtst + libXt + libXtst # duplicate + libXi + libXinerama + libXcursor + libXrandr + fontconfig + jdk-bootstrap' + ] + ++ lib.optionals (!headless && enableGtk) [ + (if atLeast11 then gtk3 else gtk2) + glib + ]; + + propagatedBuildInputs = lib.optionals (!atLeast11) [ setJavaClassPath ]; + + nativeInstallCheckInputs = lib.optionals atLeast23 [ + versionCheckHook + ]; # JDK's build system attempts to specifically detect # and special-case WSL, and we don't want it to do that, # so pass the correct platform names explicitly - configurePlatforms = [ + ${if atLeast17 then "configurePlatforms" else null} = [ "build" "host" ]; @@ -148,101 +327,280 @@ stdenv.mkDerivation (finalAttrs: { # https://openjdk.org/groups/build/doc/building.html configureFlags = [ - "--with-boot-jdk=${openjdk-bootstrap.home}" - "--with-version-string=${version}" - "--with-vendor-version-string=(nix)" + "--with-boot-jdk=${jdk-bootstrap'.home}" + ] + ++ ( + if atLeast23 then + [ + "--with-version-string=${version}" + "--with-vendor-version-string=(nix)" + ] + else if atLeast11 then + lib.optionals atLeast17 [ + "--with-version-build=${versionBuild}" + "--with-version-opt=nixos" + ] + ++ [ + "--with-version-pre=" + ] + else + [ + "--with-update-version=${lib.removePrefix "${featureVersion}u" (lib.elemAt versionSplit 0)}" + "--with-build-number=${versionBuild}" + "--with-milestone=fcs" + ] + ) + ++ [ "--enable-unlimited-crypto" "--with-native-debug-symbols=internal" - "--with-libjpeg=system" - "--with-giflib=system" - "--with-libpng=system" - "--with-zlib=system" - "--with-lcms=system" + ] + ++ lib.optionals (!atLeast21) ( + if atLeast11 then + [ + "--with-freetype=system" + "--with-harfbuzz=system" + ] + else + [ + "--disable-freetype-bundling" + ] + ) + ++ ( + if atLeast11 then + [ + "--with-libjpeg=system" + "--with-giflib=system" + "--with-libpng=system" + "--with-zlib=system" + "--with-lcms=system" + ] + else + [ + "--with-zlib=system" + "--with-giflib=system" + ] + ) + ++ [ "--with-stdc++lib=dynamic" ] - ++ lib.optionals stdenv.cc.isClang [ + ++ lib.optionals (featureVersion == "11") [ + "--disable-warnings-as-errors" + ] + # OpenJDK 11 cannot be built by recent versions of Clang, as far as I can tell (see + # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260319). Known to + # compile with LLVM 12. + ++ lib.optionals (atLeast11 && stdenv.cc.isClang) [ "--with-toolchain-type=clang" # Explicitly tell Clang to compile C++ files as C++, see # https://github.com/NixOS/nixpkgs/issues/150655#issuecomment-1935304859 "--with-extra-cxxflags=-xc++" ] - ++ lib.optional headless "--enable-headless-only" - ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}"; + # This probably shouldn’t apply to OpenJDK 21; see + # b7e68243306833845cbf92e2ea1e0cf782481a51 which removed it for + # versions 15 through 20. + ++ lib.optional ( + (featureVersion == "11" || featureVersion == "21") && stdenv.hostPlatform.isx86_64 + ) "--with-jvm-features=zgc" + ++ lib.optional headless (if atLeast11 then "--enable-headless-only" else "--disable-headful") + ++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx_jdk}"; + + buildFlags = if atLeast17 then [ "images" ] else [ "all" ]; separateDebugInfo = true; - env.NIX_CFLAGS_COMPILE = "-Wno-error"; - - NIX_LDFLAGS = toString ( - lib.optionals (!headless) [ - "-lfontconfig" - "-lcups" - "-lXinerama" - "-lXrandr" - "-lmagic" - ] - ++ lib.optionals (!headless && enableGtk) [ - "-lgtk-3" - "-lgio-2.0" - ] - ); - # -j flag is explicitly rejected by the build system: # Error: 'make -jN' is not supported, use 'make JOBS=N' # Note: it does not make build sequential. Build system # still runs in parallel. enableParallelBuilding = false; - buildFlags = [ "images" ]; + env = + { + NIX_CFLAGS_COMPILE = + if atLeast17 then + "-Wno-error" + else if atLeast11 then + # Workaround for + # `cc1plus: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]` + # when building jtreg + "-Wformat" + else + lib.concatStringsSep " " ( + [ + # glibc 2.24 deprecated readdir_r so we need this + # See https://www.mail-archive.com/openembedded-devel@lists.openembedded.org/msg49006.html + "-Wno-error=deprecated-declarations" + ] + ++ lib.optionals stdenv.cc.isGNU [ + # https://bugzilla.redhat.com/show_bug.cgi?id=1306558 + # https://github.com/JetBrains/jdk8u/commit/eaa5e0711a43d64874111254d74893fa299d5716 + "-fno-lifetime-dse" + "-fno-delete-null-pointer-checks" + "-std=gnu++98" + "-Wno-error" + ] + ); - installPhase = '' - mkdir -p $out/lib + NIX_LDFLAGS = lib.concatStringsSep " " ( + lib.optionals (!headless) [ + "-lfontconfig" + "-lcups" + "-lXinerama" + "-lXrandr" + "-lmagic" + ] + ++ lib.optionals (!headless && enableGtk) [ + (if atLeast11 then "-lgtk-3" else "-lgtk-x11-2.0") + "-lgio-2.0" + ] + ); + } + // lib.optionalAttrs (!atLeast11) { + # OpenJDK 8 Hotspot cares about the host(!) version otherwise + DISABLE_HOTSPOT_OS_VERSION_CHECK = "ok"; + }; - mv build/*/images/jdk $out/lib/openjdk + ${if atLeast23 then "versionCheckProgram" else null} = "${placeholder "out"}/bin/java"; - # Remove some broken manpages. - rm -rf $out/lib/openjdk/man/ja* + ${if !atLeast11 then "doCheck" else null} = false; # fails with "No rule to make target 'y'." - # Mirror some stuff in top-level. - mkdir -p $out/share - ln -s $out/lib/openjdk/include $out/include - ln -s $out/lib/openjdk/man $out/share/man + doInstallCheck = atLeast23; - # IDEs use the provided src.zip to navigate the Java codebase (https://github.com/NixOS/nixpkgs/pull/95081) - ln -s $out/lib/openjdk/lib/src.zip $out/lib/src.zip - - # jni.h expects jni_md.h to be in the header search path. - ln -s $out/include/linux/*_md.h $out/include/ - - # Remove crap from the installation. - rm -rf $out/lib/openjdk/demo - ${lib.optionalString headless '' - rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so - ''} - - ln -s $out/lib/openjdk/bin $out/bin + ${if atLeast17 then "postPatch" else null} = '' + chmod +x configure + patchShebangs --build configure ''; - preFixup = '' - # Propagate the setJavaClassPath setup hook so that any package - # that depends on the JDK has $CLASSPATH set up properly. - mkdir -p $out/nix-support - #TODO or printWords? cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040 - echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs + ${if !atLeast17 then "preConfigure" else null} = + '' + chmod +x configure + substituteInPlace configure --replace /bin/bash "${bash}/bin/bash" + '' + + lib.optionalString (!atLeast11) '' + substituteInPlace hotspot/make/linux/adlc_updater --replace /bin/sh "${stdenv.shell}" + substituteInPlace hotspot/make/linux/makefiles/dtrace.make --replace /usr/include/sys/sdt.h "/no-such-path" + ''; - # Set JAVA_HOME automatically. - mkdir -p $out/nix-support - cat < $out/nix-support/setup-hook - if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi - EOF - ''; + installPhase = + '' + mkdir -p $out/lib + + mv build/*/images/${if atLeast11 then "jdk" else "j2sdk-image"} $out/lib/openjdk + + # Remove some broken manpages. + rm -rf $out/lib/openjdk/man/ja* + + # Mirror some stuff in top-level. + mkdir -p $out/share + ln -s $out/lib/openjdk/include $out/include + ln -s $out/lib/openjdk/man $out/share/man + '' + + lib.optionalString atLeast17 '' + + # IDEs use the provided src.zip to navigate the Java codebase (https://github.com/NixOS/nixpkgs/pull/95081) + '' + + lib.optionalString atLeast11 '' + ln -s $out/lib/openjdk/lib/src.zip $out/lib/src.zip + '' + + '' + + # jni.h expects jni_md.h to be in the header search path. + ln -s $out/include/linux/*_md.h $out/include/ + + # Remove crap from the installation. + rm -rf $out/lib/openjdk/demo${lib.optionalString (!atLeast11) " $out/lib/openjdk/sample"} + ${lib.optionalString headless ( + if atLeast11 then + '' + rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so + '' + else + '' + rm $out/lib/openjdk/jre/lib/${architecture}/{libjsound,libjsoundalsa,libsplashscreen,libawt*,libfontmanager}.so + rm $out/lib/openjdk/jre/bin/policytool + rm $out/lib/openjdk/bin/{policytool,appletviewer} + '' + )} + '' + + lib.optionalString (!atLeast11) '' + + # Move the JRE to a separate output + mkdir -p $jre/lib/openjdk + mv $out/lib/openjdk/jre $jre/lib/openjdk/jre + mkdir $out/lib/openjdk/jre + lndir $jre/lib/openjdk/jre $out/lib/openjdk/jre + + # Make sure cmm/*.pf are not symlinks: + # https://youtrack.jetbrains.com/issue/IDEA-147272 + rm -rf $out/lib/openjdk/jre/lib/cmm + ln -s {$jre,$out}/lib/openjdk/jre/lib/cmm + + # Setup fallback fonts + ${lib.optionalString (!headless) '' + mkdir -p $jre/lib/openjdk/jre/lib/fonts + ln -s ${liberation_ttf}/share/fonts/truetype $jre/lib/openjdk/jre/lib/fonts/fallback + ''} + + # Remove duplicate binaries. + for i in $(cd $out/lib/openjdk/bin && echo *); do + if [ "$i" = java ]; then continue; fi + if cmp -s $out/lib/openjdk/bin/$i $jre/lib/openjdk/jre/bin/$i; then + ln -sfn $jre/lib/openjdk/jre/bin/$i $out/lib/openjdk/bin/$i + fi + done + + # Generate certificates. + ( + cd $jre/lib/openjdk/jre/lib/security + rm cacerts + perl ${./8/generate-cacerts.pl} $jre/lib/openjdk/jre/bin/keytool ${cacert}/etc/ssl/certs/ca-bundle.crt + ) + '' + + '' + + ln -s $out/lib/openjdk/bin $out/bin + '' + + lib.optionalString (!atLeast11) '' + ln -s $jre/lib/openjdk/jre/bin $jre/bin + ln -s $jre/lib/openjdk/jre $out/jre + ''; + + preFixup = + ( + if atLeast11 then + '' + # Propagate the setJavaClassPath setup hook so that any package + # that depends on the JDK has $CLASSPATH set up properly. + mkdir -p $out/nix-support + #TODO or printWords? cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040 + echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs + '' + else + '' + # Propagate the setJavaClassPath setup hook from the JRE so that + # any package that depends on the JRE has $CLASSPATH set up + # properly. + mkdir -p $jre/nix-support + printWords ${setJavaClassPath} > $jre/nix-support/propagated-build-inputs + '' + ) + + '' + + # Set JAVA_HOME automatically. + mkdir -p $out/nix-support + cat < $out/nix-support/setup-hook + if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi + EOF + ''; postFixup = '' # Build the set of output library directories to rpath against LIBDIRS="" for output in $(getAllOutputNames); do if [ "$output" = debug ]; then continue; fi - LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort -u | tr '\n' ':'):$LIBDIRS" + LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | ${ + if atLeast17 then "sort -u" else "sort | uniq" + } | tr '\n' ':'):$LIBDIRS" done # Add the local library paths to remove dependencies on the bootstrap for output in $(getAllOutputNames); do @@ -256,21 +614,45 @@ stdenv.mkDerivation (finalAttrs: { done ''; - disallowedReferences = [ openjdk-bootstrap ]; - - pos = __curPos; - meta = import ./meta.nix lib featureVersion; - - nativeInstallCheckInputs = [ - versionCheckHook + # TODO: The OpenJDK 8 derivation got this wrong. + disallowedReferences = [ + (if atLeast11 then jdk-bootstrap' else jdk-bootstrap) ]; - versionCheckProgram = "${placeholder "out"}/bin/java"; - doInstallCheck = true; + passthru = + { + home = "${finalAttrs.finalPackage}/lib/openjdk"; - passthru = { - home = "${finalAttrs.finalPackage}/lib/openjdk"; + inherit jdk-bootstrap; + } + // (if atLeast11 then { inherit gtk3; } else { inherit gtk2; }) + // lib.optionalAttrs (!atLeast23) { + inherit architecture; + }; - inherit gtk3; + meta = { + description = "Open-source Java Development Kit"; + homepage = "https://openjdk.java.net/"; + license = lib.licenses.gpl2Only; + maintainers = with lib.maintainers; [ + edwtjo + infinidoge + ]; + mainProgram = "java"; + platforms = + [ + "i686-linux" + "x86_64-linux" + "aarch64-linux" + ] + ++ lib.optionals atLeast11 [ + "armv7l-linux" + "armv6l-linux" + "powerpc64le-linux" + ]; + # OpenJDK 8 was broken for musl at 2024-01-17. Tracking issue: + # https://github.com/NixOS/nixpkgs/issues/281618 + # error: ‘isnanf’ was not declared in this scope + broken = !atLeast11 && stdenv.hostPlatform.isMusl; }; }) diff --git a/pkgs/development/compilers/openjdk/info.json b/pkgs/development/compilers/openjdk/info.json deleted file mode 100644 index 3bfa23fb0e49..000000000000 --- a/pkgs/development/compilers/openjdk/info.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "23": { - "version": "23-ga", - "repo": "jdk23u", - "hash": "sha256-lcLnWAiskWindOqWmOWiIHiYKXGSJZK4d20k19QZfrE=" - } -} diff --git a/pkgs/development/compilers/openjdk/meta.nix b/pkgs/development/compilers/openjdk/meta.nix deleted file mode 100644 index 04ed684eefab..000000000000 --- a/pkgs/development/compilers/openjdk/meta.nix +++ /dev/null @@ -1,11 +0,0 @@ -lib: version: with lib; { - homepage = "https://openjdk.java.net/"; - license = licenses.gpl2Only; - description = "Open-source Java Development Kit"; - maintainers = with maintainers; [ edwtjo infinidoge ]; - platforms = [ "i686-linux" "x86_64-linux" "aarch64-linux" "armv7l-linux" "armv6l-linux" "powerpc64le-linux" ]; - mainProgram = "java"; - knownVulnerabilities = optionals (builtins.elem (versions.major version) [ "12" "13" "14" "15" "16" "18" "19" "20" ]) [ - "This OpenJDK version has reached its end of life." - ]; -} diff --git a/pkgs/development/tools/scenic-view/default.nix b/pkgs/development/tools/scenic-view/default.nix index 925fc8d5b29d..e0c79ed08f77 100644 --- a/pkgs/development/tools/scenic-view/default.nix +++ b/pkgs/development/tools/scenic-view/default.nix @@ -2,7 +2,7 @@ let jdk = openjdk.override (lib.optionalAttrs stdenv.hostPlatform.isLinux { enableJavaFX = true; - openjfx = openjfx.override { withWebKit = true; }; + openjfx_jdk = openjfx.override { withWebKit = true; }; }); pname = "scenic-view"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f7005036ab68..534b09999bd6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -28352,7 +28352,7 @@ with pkgs; bluej = callPackage ../applications/editors/bluej { openjdk = openjdk17.override { enableJavaFX = true; - openjfx = openjfx17.override { withWebKit = true; }; + openjfx_jdk = openjfx17.override { withWebKit = true; }; }; }; @@ -28999,7 +28999,7 @@ with pkgs; greenfoot = callPackage ../applications/editors/greenfoot { openjdk = openjdk17.override { enableJavaFX = true; - openjfx = openjfx17.override { withWebKit = true; }; + openjfx_jdk = openjfx17.override { withWebKit = true; }; }; }; @@ -30274,7 +30274,7 @@ with pkgs; jabref = callPackage ../applications/office/jabref { jdk = jdk21.override { enableJavaFX = true; - openjfx = openjfx23.override { withWebKit = true; }; + openjfx_jdk = openjfx23.override { withWebKit = true; }; }; }; diff --git a/pkgs/top-level/java-packages.nix b/pkgs/top-level/java-packages.nix index eb549d0d21d1..7c270d134cfb 100644 --- a/pkgs/top-level/java-packages.nix +++ b/pkgs/top-level/java-packages.nix @@ -11,15 +11,15 @@ in { inherit openjfx17 openjfx21 openjfx23; compiler = let - mkOpenjdk = path-linux: path-darwin: args: + mkOpenjdk = featureVersion: path-darwin: if stdenv.hostPlatform.isLinux - then mkOpenjdkLinuxOnly path-linux args + then mkOpenjdkLinuxOnly featureVersion else let openjdk = callPackage path-darwin {}; in openjdk // { headless = openjdk; }; - mkOpenjdkLinuxOnly = path-linux: args: let - openjdk = callPackage path-linux (args); + mkOpenjdkLinuxOnly = featureVersion: let + openjdk = callPackage ../development/compilers/openjdk/generic.nix { inherit featureVersion; }; in assert stdenv.hostPlatform.isLinux; openjdk // { headless = openjdk.override { headless = true; }; }; @@ -29,45 +29,16 @@ in { corretto17 = callPackage ../development/compilers/corretto/17.nix { }; corretto21 = callPackage ../development/compilers/corretto/21.nix { }; - openjdk8-bootstrap = temurin-bin.jdk-8; + openjdk8 = mkOpenjdk "8" ../development/compilers/zulu/8.nix; + openjdk11 = mkOpenjdk "11" ../development/compilers/zulu/11.nix; + openjdk17 = mkOpenjdk "17" ../development/compilers/zulu/17.nix; + openjdk21 = mkOpenjdk "21" ../development/compilers/zulu/21.nix; + openjdk23 = mkOpenjdk "23" ../development/compilers/zulu/23.nix; - openjdk11-bootstrap = temurin-bin.jdk-11; - - openjdk17-bootstrap = temurin-bin.jdk-17; - - openjdk8 = mkOpenjdk - ../development/compilers/openjdk/8.nix - ../development/compilers/zulu/8.nix - { }; - - openjdk11 = mkOpenjdk - ../development/compilers/openjdk/11.nix - ../development/compilers/zulu/11.nix - { openjfx = throw "JavaFX is not supported on OpenJDK 11"; }; - - openjdk17 = mkOpenjdk - ../development/compilers/openjdk/17.nix - ../development/compilers/zulu/17.nix - { - inherit openjdk17-bootstrap; - openjfx = openjfx17; - }; - - openjdk21 = mkOpenjdk - ../development/compilers/openjdk/21.nix - ../development/compilers/zulu/21.nix - { - openjdk21-bootstrap = temurin-bin.jdk-21; - openjfx = openjfx21; - }; - - openjdk23 = mkOpenjdk - ../development/compilers/openjdk/23.nix - ../development/compilers/zulu/23.nix - { - openjdk23-bootstrap = temurin-bin.jdk-23; - openjfx = openjfx23; - }; + # Legacy aliases + openjdk8-bootstrap = openjdk8.jdk-bootstrap; + openjdk11-bootstrap = openjdk11.jdk-bootstrap; + openjdk17-bootstrap = openjdk17.jdk-bootstrap; temurin-bin = recurseIntoAttrs (callPackage ( if stdenv.hostPlatform.isLinux From 1801f90beeac37f03f51b166a971c24b8270d5b1 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 18 Oct 2024 05:38:24 +0100 Subject: [PATCH 09/17] openjfx: copy latest version into `generic.nix` --- .../compilers/openjdk/openjfx/generic.nix | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 pkgs/development/compilers/openjdk/openjfx/generic.nix diff --git a/pkgs/development/compilers/openjdk/openjfx/generic.nix b/pkgs/development/compilers/openjdk/openjfx/generic.nix new file mode 100644 index 000000000000..70677e247646 --- /dev/null +++ b/pkgs/development/compilers/openjdk/openjfx/generic.nix @@ -0,0 +1,111 @@ +{ stdenv +, lib +, pkgs +, fetchFromGitHub +, fetchpatch2 +, writeText +, openjdk23_headless +, gradle +, pkg-config +, perl +, cmake +, gperf +, gtk2 +, gtk3 +, libXtst +, libXxf86vm +, glib +, alsa-lib +, ffmpeg +, python3 +, ruby +, withMedia ? true +, withWebKit ? false +}: + +let + pname = "openjfx-modular-sdk"; + major = "23"; + update = ""; + build = "-ga"; + repover = "${major}${update}${build}"; + jdk = openjdk23_headless; + +in stdenv.mkDerivation { + inherit pname; + version = "${major}${update}${build}"; + + src = fetchFromGitHub { + owner = "openjdk"; + repo = "jfx23u"; + rev = repover; + hash = "sha256-a/ev91Rq7D3z9O56ZZQCgvvbfj5GBt5Lonow2NH3s/E="; + }; + + patches = [ + # 8338701: Provide media support for libavcodec version 61 + # + (fetchpatch2 { + url = "https://github.com/openjdk/jfx23u/commit/aba60fda1c82f00e8e685107592305c403a31287.patch?full_index=1"; + hash = "sha256-+aRhTwi4VQthAq1SH1jxPl0mTosNMKoTY52jm+jiKso="; + }) + ]; + + buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg ]; + nativeBuildInputs = [ gradle perl pkg-config cmake gperf python3 ruby ]; + + dontUseCmakeConfigure = true; + + config = writeText "gradle.properties" '' + CONF = Release + JDK_HOME = ${jdk.home} + COMPILE_MEDIA = ${lib.boolToString withMedia} + COMPILE_WEBKIT = ${lib.boolToString withWebKit} + ''; + + postPatch = '' + ln -s $config gradle.properties + ''; + + mitmCache = gradle.fetchDeps { + attrPath = "openjfx${major}"; + pkg = pkgs."openjfx${major}".override { withWebKit = true; }; + data = ./deps.json; + }; + + __darwinAllowLocalNetworking = true; + + preBuild = '' + export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES + export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE" + ''; + + enableParallelBuilding = false; + + gradleBuildTask = "sdk"; + + installPhase = '' + cp -r build/modular-sdk $out + ''; + + stripDebugList = [ "." ]; + + postFixup = '' + # Remove references to bootstrap. + export openjdkOutPath='${jdk.outPath}' + find "$out" -name \*.so | while read lib; do + new_refs="$(patchelf --print-rpath "$lib" | perl -pe 's,:?\Q$ENV{openjdkOutPath}\E[^:]*,,')" + patchelf --set-rpath "$new_refs" "$lib" + done + ''; + + disallowedReferences = [ jdk gradle.jdk ]; + + meta = with lib; { + homepage = "https://openjdk.org/projects/openjfx/"; + license = licenses.gpl2Classpath; + description = "Next-generation Java client toolkit"; + maintainers = with maintainers; [ abbradar ]; + platforms = platforms.unix; + }; +} From 058999318ff0d2113a15ae15b50f68a60613171f Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 18 Oct 2024 05:38:39 +0100 Subject: [PATCH 10/17] openjfx: format `generic.nix` with `nixfmt-rfc-style` --- .../compilers/openjdk/openjfx/generic.nix | 75 ++++++++++++------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/pkgs/development/compilers/openjdk/openjfx/generic.nix b/pkgs/development/compilers/openjdk/openjfx/generic.nix index 70677e247646..94de7c0e575c 100644 --- a/pkgs/development/compilers/openjdk/openjfx/generic.nix +++ b/pkgs/development/compilers/openjdk/openjfx/generic.nix @@ -1,26 +1,27 @@ -{ stdenv -, lib -, pkgs -, fetchFromGitHub -, fetchpatch2 -, writeText -, openjdk23_headless -, gradle -, pkg-config -, perl -, cmake -, gperf -, gtk2 -, gtk3 -, libXtst -, libXxf86vm -, glib -, alsa-lib -, ffmpeg -, python3 -, ruby -, withMedia ? true -, withWebKit ? false +{ + stdenv, + lib, + pkgs, + fetchFromGitHub, + fetchpatch2, + writeText, + openjdk23_headless, + gradle, + pkg-config, + perl, + cmake, + gperf, + gtk2, + gtk3, + libXtst, + libXxf86vm, + glib, + alsa-lib, + ffmpeg, + python3, + ruby, + withMedia ? true, + withWebKit ? false, }: let @@ -31,7 +32,8 @@ let repover = "${major}${update}${build}"; jdk = openjdk23_headless; -in stdenv.mkDerivation { +in +stdenv.mkDerivation { inherit pname; version = "${major}${update}${build}"; @@ -51,8 +53,24 @@ in stdenv.mkDerivation { }) ]; - buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg ]; - nativeBuildInputs = [ gradle perl pkg-config cmake gperf python3 ruby ]; + buildInputs = [ + gtk2 + gtk3 + libXtst + libXxf86vm + glib + alsa-lib + ffmpeg + ]; + nativeBuildInputs = [ + gradle + perl + pkg-config + cmake + gperf + python3 + ruby + ]; dontUseCmakeConfigure = true; @@ -99,7 +117,10 @@ in stdenv.mkDerivation { done ''; - disallowedReferences = [ jdk gradle.jdk ]; + disallowedReferences = [ + jdk + gradle.jdk + ]; meta = with lib; { homepage = "https://openjdk.org/projects/openjfx/"; From f05216c37302b8e12e0bc13856e19353a48972c0 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 18 Oct 2024 05:38:58 +0100 Subject: [PATCH 11/17] openjfx{17,21,23}: deduplicate into `generic.nix` --- .../compilers/openjdk/openjfx/17/default.nix | 98 ---------- .../backport-ffmpeg-6-support-jfx11.patch | 0 .../backport-ffmpeg-7-support-jfx11.patch | 0 .../compilers/openjdk/openjfx/17/source.json | 6 + .../compilers/openjdk/openjfx/21/default.nix | 94 ---------- .../backport-ffmpeg-7-support-jfx21.patch | 0 .../compilers/openjdk/openjfx/21/source.json | 6 + .../compilers/openjdk/openjfx/23/default.nix | 111 ------------ .../compilers/openjdk/openjfx/23/source.json | 6 + .../compilers/openjdk/openjfx/generic.nix | 170 +++++++++++------- pkgs/top-level/java-packages.nix | 6 +- 11 files changed, 128 insertions(+), 369 deletions(-) delete mode 100644 pkgs/development/compilers/openjdk/openjfx/17/default.nix rename pkgs/development/compilers/openjdk/openjfx/{ => 17/patches}/backport-ffmpeg-6-support-jfx11.patch (100%) rename pkgs/development/compilers/openjdk/openjfx/{ => 17/patches}/backport-ffmpeg-7-support-jfx11.patch (100%) create mode 100644 pkgs/development/compilers/openjdk/openjfx/17/source.json delete mode 100644 pkgs/development/compilers/openjdk/openjfx/21/default.nix rename pkgs/development/compilers/openjdk/openjfx/{ => 21/patches}/backport-ffmpeg-7-support-jfx21.patch (100%) create mode 100644 pkgs/development/compilers/openjdk/openjfx/21/source.json delete mode 100644 pkgs/development/compilers/openjdk/openjfx/23/default.nix create mode 100644 pkgs/development/compilers/openjdk/openjfx/23/source.json diff --git a/pkgs/development/compilers/openjdk/openjfx/17/default.nix b/pkgs/development/compilers/openjdk/openjfx/17/default.nix deleted file mode 100644 index d43ffc8b6862..000000000000 --- a/pkgs/development/compilers/openjdk/openjfx/17/default.nix +++ /dev/null @@ -1,98 +0,0 @@ -{ stdenv, lib, pkgs, fetchFromGitHub, writeText, openjdk17_headless, gradle_7 -, pkg-config, perl, cmake, gperf, gtk2, gtk3, libXtst, libXxf86vm, glib, alsa-lib -, ffmpeg-headless, python3, ruby -, withMedia ? true -, withWebKit ? false -}: - -let - pname = "openjfx-modular-sdk"; - major = "17"; - update = ".0.11"; - build = "-ga"; - repover = "${major}${update}${build}"; - jdk = openjdk17_headless; - gradle = gradle_7; - -in stdenv.mkDerivation { - inherit pname; - version = "${major}${update}${build}"; - - src = fetchFromGitHub { - owner = "openjdk"; - repo = "jfx${major}u"; - rev = repover; - sha256 = "sha256-9VfXk2EfMebMyVKPohPRP2QXRFf8XemUtfY0JtBCHyw="; - }; - - patches = [ - ../backport-ffmpeg-6-support-jfx11.patch - ../backport-ffmpeg-7-support-jfx11.patch - ]; - - buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg-headless ]; - nativeBuildInputs = [ gradle perl pkg-config cmake gperf python3 ruby ]; - - dontUseCmakeConfigure = true; - - config = writeText "gradle.properties" '' - CONF = Release - JDK_HOME = ${jdk.home} - COMPILE_MEDIA = ${lib.boolToString withMedia} - COMPILE_WEBKIT = ${lib.boolToString withWebKit} - ''; - - postPatch = '' - # Add missing includes for gcc-13 for webkit build: - sed -e '1i #include ' \ - -i modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/Heap.cpp \ - modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/IsoSharedPageInlines.h - - substituteInPlace modules/javafx.web/src/main/native/Source/JavaScriptCore/offlineasm/parser.rb \ - --replace-fail "File.exists?" "File.exist?" - - ln -s $config gradle.properties - ''; - - mitmCache = gradle.fetchDeps { - attrPath = "openjfx${major}"; - pkg = pkgs."openjfx${major}".override { withWebKit = true; }; - data = ./deps.json; - }; - - __darwinAllowLocalNetworking = true; - - preBuild = '' - export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES - export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE" - ''; - - enableParallelBuilding = false; - - gradleBuildTask = "sdk"; - - installPhase = '' - cp -r build/modular-sdk $out - ''; - - stripDebugList = [ "." ]; - - postFixup = '' - # Remove references to bootstrap. - export openjdkOutPath='${jdk.outPath}' - find "$out" -name \*.so | while read lib; do - new_refs="$(patchelf --print-rpath "$lib" | perl -pe 's,:?\Q$ENV{openjdkOutPath}\E[^:]*,,')" - patchelf --set-rpath "$new_refs" "$lib" - done - ''; - - disallowedReferences = [ jdk gradle.jdk ]; - - meta = with lib; { - homepage = "http://openjdk.java.net/projects/openjfx/"; - license = licenses.gpl2; - description = "Next-generation Java client toolkit"; - maintainers = with maintainers; [ abbradar ]; - platforms = platforms.unix; - }; -} diff --git a/pkgs/development/compilers/openjdk/openjfx/backport-ffmpeg-6-support-jfx11.patch b/pkgs/development/compilers/openjdk/openjfx/17/patches/backport-ffmpeg-6-support-jfx11.patch similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/backport-ffmpeg-6-support-jfx11.patch rename to pkgs/development/compilers/openjdk/openjfx/17/patches/backport-ffmpeg-6-support-jfx11.patch diff --git a/pkgs/development/compilers/openjdk/openjfx/backport-ffmpeg-7-support-jfx11.patch b/pkgs/development/compilers/openjdk/openjfx/17/patches/backport-ffmpeg-7-support-jfx11.patch similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/backport-ffmpeg-7-support-jfx11.patch rename to pkgs/development/compilers/openjdk/openjfx/17/patches/backport-ffmpeg-7-support-jfx11.patch diff --git a/pkgs/development/compilers/openjdk/openjfx/17/source.json b/pkgs/development/compilers/openjdk/openjfx/17/source.json new file mode 100644 index 000000000000..932875548f4b --- /dev/null +++ b/pkgs/development/compilers/openjdk/openjfx/17/source.json @@ -0,0 +1,6 @@ +{ + "owner": "openjdk", + "repo": "jfx17u", + "rev": "17.0.11-ga", + "sha256": "sha256-9VfXk2EfMebMyVKPohPRP2QXRFf8XemUtfY0JtBCHyw=" +} diff --git a/pkgs/development/compilers/openjdk/openjfx/21/default.nix b/pkgs/development/compilers/openjdk/openjfx/21/default.nix deleted file mode 100644 index 5266f5d8072f..000000000000 --- a/pkgs/development/compilers/openjdk/openjfx/21/default.nix +++ /dev/null @@ -1,94 +0,0 @@ -{ stdenv, lib, pkgs, fetchFromGitHub, writeText -, openjdk21_headless, gradle_7, pkg-config, perl, cmake, gperf, gtk2, gtk3, libXtst -, libXxf86vm, glib, alsa-lib, ffmpeg, python3, ruby -, withMedia ? true -, withWebKit ? false -}: - -let - pname = "openjfx-modular-sdk"; - major = "21"; - update = ".0.3"; - build = "-ga"; - repover = "${major}${update}${build}"; - jdk = openjdk21_headless; - gradle = gradle_7; - -in stdenv.mkDerivation { - inherit pname; - version = "${major}${update}${build}"; - - src = fetchFromGitHub { - owner = "openjdk"; - repo = "jfx21u"; - rev = repover; - hash = "sha256-7z0GIbkQwG9mXY9dssaicqaKpMo3FkNEpyAvkswoQQ4="; - }; - - patches = [ - ../backport-ffmpeg-7-support-jfx21.patch - ]; - - buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg ]; - nativeBuildInputs = [ gradle perl pkg-config cmake gperf python3 ruby ]; - - dontUseCmakeConfigure = true; - - config = writeText "gradle.properties" '' - CONF = Release - JDK_HOME = ${jdk.home} - COMPILE_MEDIA = ${lib.boolToString withMedia} - COMPILE_WEBKIT = ${lib.boolToString withWebKit} - ''; - - postPatch = '' - # Add missing includes for gcc-13 for webkit build: - sed -e '1i #include ' \ - -i modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/Heap.cpp \ - modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/IsoSharedPageInlines.h - - ln -s $config gradle.properties - ''; - - mitmCache = gradle.fetchDeps { - attrPath = "openjfx${major}"; - pkg = pkgs."openjfx${major}".override { withWebKit = true; }; - data = ./deps.json; - }; - - __darwinAllowLocalNetworking = true; - - preBuild = '' - export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES - export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE" - ''; - - enableParallelBuilding = false; - - gradleBuildTask = "sdk"; - - installPhase = '' - cp -r build/modular-sdk $out - ''; - - stripDebugList = [ "." ]; - - postFixup = '' - # Remove references to bootstrap. - export openjdkOutPath='${jdk.outPath}' - find "$out" -name \*.so | while read lib; do - new_refs="$(patchelf --print-rpath "$lib" | perl -pe 's,:?\Q$ENV{openjdkOutPath}\E[^:]*,,')" - patchelf --set-rpath "$new_refs" "$lib" - done - ''; - - disallowedReferences = [ jdk gradle.jdk ]; - - meta = with lib; { - homepage = "https://openjdk.org/projects/openjfx/"; - license = licenses.gpl2Classpath; - description = "Next-generation Java client toolkit"; - maintainers = with maintainers; [ abbradar ]; - platforms = platforms.unix; - }; -} diff --git a/pkgs/development/compilers/openjdk/openjfx/backport-ffmpeg-7-support-jfx21.patch b/pkgs/development/compilers/openjdk/openjfx/21/patches/backport-ffmpeg-7-support-jfx21.patch similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/backport-ffmpeg-7-support-jfx21.patch rename to pkgs/development/compilers/openjdk/openjfx/21/patches/backport-ffmpeg-7-support-jfx21.patch diff --git a/pkgs/development/compilers/openjdk/openjfx/21/source.json b/pkgs/development/compilers/openjdk/openjfx/21/source.json new file mode 100644 index 000000000000..adecaa605bcc --- /dev/null +++ b/pkgs/development/compilers/openjdk/openjfx/21/source.json @@ -0,0 +1,6 @@ +{ + "hash": "sha256-7z0GIbkQwG9mXY9dssaicqaKpMo3FkNEpyAvkswoQQ4=", + "owner": "openjdk", + "repo": "jfx21u", + "rev": "21.0.3-ga" +} diff --git a/pkgs/development/compilers/openjdk/openjfx/23/default.nix b/pkgs/development/compilers/openjdk/openjfx/23/default.nix deleted file mode 100644 index 70677e247646..000000000000 --- a/pkgs/development/compilers/openjdk/openjfx/23/default.nix +++ /dev/null @@ -1,111 +0,0 @@ -{ stdenv -, lib -, pkgs -, fetchFromGitHub -, fetchpatch2 -, writeText -, openjdk23_headless -, gradle -, pkg-config -, perl -, cmake -, gperf -, gtk2 -, gtk3 -, libXtst -, libXxf86vm -, glib -, alsa-lib -, ffmpeg -, python3 -, ruby -, withMedia ? true -, withWebKit ? false -}: - -let - pname = "openjfx-modular-sdk"; - major = "23"; - update = ""; - build = "-ga"; - repover = "${major}${update}${build}"; - jdk = openjdk23_headless; - -in stdenv.mkDerivation { - inherit pname; - version = "${major}${update}${build}"; - - src = fetchFromGitHub { - owner = "openjdk"; - repo = "jfx23u"; - rev = repover; - hash = "sha256-a/ev91Rq7D3z9O56ZZQCgvvbfj5GBt5Lonow2NH3s/E="; - }; - - patches = [ - # 8338701: Provide media support for libavcodec version 61 - # - (fetchpatch2 { - url = "https://github.com/openjdk/jfx23u/commit/aba60fda1c82f00e8e685107592305c403a31287.patch?full_index=1"; - hash = "sha256-+aRhTwi4VQthAq1SH1jxPl0mTosNMKoTY52jm+jiKso="; - }) - ]; - - buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg ]; - nativeBuildInputs = [ gradle perl pkg-config cmake gperf python3 ruby ]; - - dontUseCmakeConfigure = true; - - config = writeText "gradle.properties" '' - CONF = Release - JDK_HOME = ${jdk.home} - COMPILE_MEDIA = ${lib.boolToString withMedia} - COMPILE_WEBKIT = ${lib.boolToString withWebKit} - ''; - - postPatch = '' - ln -s $config gradle.properties - ''; - - mitmCache = gradle.fetchDeps { - attrPath = "openjfx${major}"; - pkg = pkgs."openjfx${major}".override { withWebKit = true; }; - data = ./deps.json; - }; - - __darwinAllowLocalNetworking = true; - - preBuild = '' - export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES - export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE" - ''; - - enableParallelBuilding = false; - - gradleBuildTask = "sdk"; - - installPhase = '' - cp -r build/modular-sdk $out - ''; - - stripDebugList = [ "." ]; - - postFixup = '' - # Remove references to bootstrap. - export openjdkOutPath='${jdk.outPath}' - find "$out" -name \*.so | while read lib; do - new_refs="$(patchelf --print-rpath "$lib" | perl -pe 's,:?\Q$ENV{openjdkOutPath}\E[^:]*,,')" - patchelf --set-rpath "$new_refs" "$lib" - done - ''; - - disallowedReferences = [ jdk gradle.jdk ]; - - meta = with lib; { - homepage = "https://openjdk.org/projects/openjfx/"; - license = licenses.gpl2Classpath; - description = "Next-generation Java client toolkit"; - maintainers = with maintainers; [ abbradar ]; - platforms = platforms.unix; - }; -} diff --git a/pkgs/development/compilers/openjdk/openjfx/23/source.json b/pkgs/development/compilers/openjdk/openjfx/23/source.json new file mode 100644 index 000000000000..a67cd0f370f1 --- /dev/null +++ b/pkgs/development/compilers/openjdk/openjfx/23/source.json @@ -0,0 +1,6 @@ +{ + "hash": "sha256-a/ev91Rq7D3z9O56ZZQCgvvbfj5GBt5Lonow2NH3s/E=", + "owner": "openjdk", + "repo": "jfx23u", + "rev": "23-ga" +} diff --git a/pkgs/development/compilers/openjdk/openjfx/generic.nix b/pkgs/development/compilers/openjdk/openjfx/generic.nix index 94de7c0e575c..e2cd6ced4f8c 100644 --- a/pkgs/development/compilers/openjdk/openjfx/generic.nix +++ b/pkgs/development/compilers/openjdk/openjfx/generic.nix @@ -1,16 +1,22 @@ { - stdenv, + featureVersion ? "17", + lib, + stdenv, pkgs, + fetchFromGitHub, fetchpatch2, - writeText, - openjdk23_headless, + gradle, - pkg-config, + gradle_7, perl, + pkg-config, cmake, gperf, + python3, + ruby, + gtk2, gtk3, libXtst, @@ -18,39 +24,73 @@ glib, alsa-lib, ffmpeg, - python3, - ruby, + ffmpeg-headless, + + writeText, + withMedia ? true, withWebKit ? false, + + jdk17_headless, + jdk21_headless, + jdk23_headless, + jdk-bootstrap ? + { + "17" = jdk17_headless; + "21" = jdk21_headless; + "23" = jdk23_headless; + } + .${featureVersion}, }: let - pname = "openjfx-modular-sdk"; - major = "23"; - update = ""; - build = "-ga"; - repover = "${major}${update}${build}"; - jdk = openjdk23_headless; + sourceFile = ./. + "/${featureVersion}/source.json"; + sourceInfo = lib.importJSON sourceFile; + atLeast21 = lib.versionAtLeast featureVersion "21"; + atLeast23 = lib.versionAtLeast featureVersion "23"; + + gradle_openjfx = if atLeast23 then gradle else gradle_7; in + +assert lib.assertMsg (lib.pathExists sourceFile) + "OpenJFX ${featureVersion} is not a supported version"; + stdenv.mkDerivation { - inherit pname; - version = "${major}${update}${build}"; + pname = "openjfx-modular-sdk"; + version = lib.removePrefix "refs/tags/" sourceInfo.rev; - src = fetchFromGitHub { - owner = "openjdk"; - repo = "jfx23u"; - rev = repover; - hash = "sha256-a/ev91Rq7D3z9O56ZZQCgvvbfj5GBt5Lonow2NH3s/E="; - }; + # TODO: Tighten up after update scripts are run. + src = fetchFromGitHub sourceInfo; - patches = [ - # 8338701: Provide media support for libavcodec version 61 - # - (fetchpatch2 { - url = "https://github.com/openjdk/jfx23u/commit/aba60fda1c82f00e8e685107592305c403a31287.patch?full_index=1"; - hash = "sha256-+aRhTwi4VQthAq1SH1jxPl0mTosNMKoTY52jm+jiKso="; - }) + patches = + if featureVersion == "23" then + [ + # 8338701: Provide media support for libavcodec version 61 + # + (fetchpatch2 { + url = "https://github.com/openjdk/jfx23u/commit/aba60fda1c82f00e8e685107592305c403a31287.patch?full_index=1"; + hash = "sha256-+aRhTwi4VQthAq1SH1jxPl0mTosNMKoTY52jm+jiKso="; + }) + ] + else if atLeast21 then + [ + ./21/patches/backport-ffmpeg-7-support-jfx21.patch + ] + else + [ + ./17/patches/backport-ffmpeg-6-support-jfx11.patch + ./17/patches/backport-ffmpeg-7-support-jfx11.patch + ]; + + nativeBuildInputs = [ + gradle_openjfx + perl + pkg-config + cmake + gperf + python3 + ruby ]; buildInputs = [ @@ -60,57 +100,61 @@ stdenv.mkDerivation { libXxf86vm glib alsa-lib - ffmpeg - ]; - nativeBuildInputs = [ - gradle - perl - pkg-config - cmake - gperf - python3 - ruby + (if atLeast21 then ffmpeg else ffmpeg-headless) ]; - dontUseCmakeConfigure = true; + mitmCache = gradle_openjfx.fetchDeps { + attrPath = "openjfx${featureVersion}"; + pkg = pkgs."openjfx${featureVersion}".override { withWebKit = true; }; + data = ./. + "/${featureVersion}/deps.json"; + }; - config = writeText "gradle.properties" '' + gradleBuildTask = "sdk"; + + stripDebugList = [ "." ]; + + enableParallelBuilding = false; + + __darwinAllowLocalNetworking = true; + + env.config = writeText "gradle.properties" '' CONF = Release - JDK_HOME = ${jdk.home} + JDK_HOME = ${jdk-bootstrap.home} COMPILE_MEDIA = ${lib.boolToString withMedia} COMPILE_WEBKIT = ${lib.boolToString withWebKit} ''; - postPatch = '' - ln -s $config gradle.properties - ''; + dontUseCmakeConfigure = true; - mitmCache = gradle.fetchDeps { - attrPath = "openjfx${major}"; - pkg = pkgs."openjfx${major}".override { withWebKit = true; }; - data = ./deps.json; - }; + postPatch = + lib.optionalString (!atLeast23) '' + # Add missing includes for gcc-13 for webkit build: + sed -e '1i #include ' \ + -i modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/Heap.cpp \ + modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/IsoSharedPageInlines.h - __darwinAllowLocalNetworking = true; + '' + + lib.optionalString (!atLeast21) '' + substituteInPlace modules/javafx.web/src/main/native/Source/JavaScriptCore/offlineasm/parser.rb \ + --replace-fail "File.exists?" "File.exist?" + + '' + + '' + ln -s $config gradle.properties + ''; preBuild = '' export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE" ''; - enableParallelBuilding = false; - - gradleBuildTask = "sdk"; - installPhase = '' cp -r build/modular-sdk $out ''; - stripDebugList = [ "." ]; - postFixup = '' # Remove references to bootstrap. - export openjdkOutPath='${jdk.outPath}' + export openjdkOutPath='${jdk-bootstrap.outPath}' find "$out" -name \*.so | while read lib; do new_refs="$(patchelf --print-rpath "$lib" | perl -pe 's,:?\Q$ENV{openjdkOutPath}\E[^:]*,,')" patchelf --set-rpath "$new_refs" "$lib" @@ -118,15 +162,15 @@ stdenv.mkDerivation { ''; disallowedReferences = [ - jdk - gradle.jdk + jdk-bootstrap + gradle_openjfx.jdk ]; - meta = with lib; { - homepage = "https://openjdk.org/projects/openjfx/"; - license = licenses.gpl2Classpath; + meta = { description = "Next-generation Java client toolkit"; - maintainers = with maintainers; [ abbradar ]; - platforms = platforms.unix; + homepage = "https://openjdk.org/projects/openjfx/"; + license = lib.licenses.gpl2Classpath; + maintainers = with lib.maintainers; [ abbradar ]; + platforms = lib.platforms.unix; }; } diff --git a/pkgs/top-level/java-packages.nix b/pkgs/top-level/java-packages.nix index 7c270d134cfb..edcd30c45970 100644 --- a/pkgs/top-level/java-packages.nix +++ b/pkgs/top-level/java-packages.nix @@ -3,9 +3,9 @@ with pkgs; let - openjfx17 = callPackage ../development/compilers/openjdk/openjfx/17 { }; - openjfx21 = callPackage ../development/compilers/openjdk/openjfx/21 { }; - openjfx23 = callPackage ../development/compilers/openjdk/openjfx/23 { }; + openjfx17 = callPackage ../development/compilers/openjdk/openjfx/generic.nix { featureVersion = "17"; }; + openjfx21 = callPackage ../development/compilers/openjdk/openjfx/generic.nix { featureVerison = "21"; }; + openjfx23 = callPackage ../development/compilers/openjdk/openjfx/generic.nix { featureVersion = "23"; }; in { inherit openjfx17 openjfx21 openjfx23; From f2569008ab1ab7dae2e2d28c58be6705805e89d6 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 6 Oct 2024 03:44:39 +0100 Subject: [PATCH 12/17] openjfx{17,21,23}: move to `pkgs/by-name` --- .../openjdk => by-name/op}/openjfx/17/deps.json | 0 .../17/patches/backport-ffmpeg-6-support-jfx11.patch | 0 .../17/patches/backport-ffmpeg-7-support-jfx11.patch | 0 .../openjdk => by-name/op}/openjfx/17/source.json | 0 .../openjdk => by-name/op}/openjfx/21/deps.json | 0 .../21/patches/backport-ffmpeg-7-support-jfx21.patch | 0 .../openjdk => by-name/op}/openjfx/21/source.json | 0 .../openjdk => by-name/op}/openjfx/23/deps.json | 0 .../openjdk => by-name/op}/openjfx/23/source.json | 0 .../generic.nix => by-name/op/openjfx/package.nix} | 0 pkgs/top-level/all-packages.nix | 5 +++-- pkgs/top-level/java-packages.nix | 9 ++------- 12 files changed, 5 insertions(+), 9 deletions(-) rename pkgs/{development/compilers/openjdk => by-name/op}/openjfx/17/deps.json (100%) rename pkgs/{development/compilers/openjdk => by-name/op}/openjfx/17/patches/backport-ffmpeg-6-support-jfx11.patch (100%) rename pkgs/{development/compilers/openjdk => by-name/op}/openjfx/17/patches/backport-ffmpeg-7-support-jfx11.patch (100%) rename pkgs/{development/compilers/openjdk => by-name/op}/openjfx/17/source.json (100%) rename pkgs/{development/compilers/openjdk => by-name/op}/openjfx/21/deps.json (100%) rename pkgs/{development/compilers/openjdk => by-name/op}/openjfx/21/patches/backport-ffmpeg-7-support-jfx21.patch (100%) rename pkgs/{development/compilers/openjdk => by-name/op}/openjfx/21/source.json (100%) rename pkgs/{development/compilers/openjdk => by-name/op}/openjfx/23/deps.json (100%) rename pkgs/{development/compilers/openjdk => by-name/op}/openjfx/23/source.json (100%) rename pkgs/{development/compilers/openjdk/openjfx/generic.nix => by-name/op/openjfx/package.nix} (100%) diff --git a/pkgs/development/compilers/openjdk/openjfx/17/deps.json b/pkgs/by-name/op/openjfx/17/deps.json similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/17/deps.json rename to pkgs/by-name/op/openjfx/17/deps.json diff --git a/pkgs/development/compilers/openjdk/openjfx/17/patches/backport-ffmpeg-6-support-jfx11.patch b/pkgs/by-name/op/openjfx/17/patches/backport-ffmpeg-6-support-jfx11.patch similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/17/patches/backport-ffmpeg-6-support-jfx11.patch rename to pkgs/by-name/op/openjfx/17/patches/backport-ffmpeg-6-support-jfx11.patch diff --git a/pkgs/development/compilers/openjdk/openjfx/17/patches/backport-ffmpeg-7-support-jfx11.patch b/pkgs/by-name/op/openjfx/17/patches/backport-ffmpeg-7-support-jfx11.patch similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/17/patches/backport-ffmpeg-7-support-jfx11.patch rename to pkgs/by-name/op/openjfx/17/patches/backport-ffmpeg-7-support-jfx11.patch diff --git a/pkgs/development/compilers/openjdk/openjfx/17/source.json b/pkgs/by-name/op/openjfx/17/source.json similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/17/source.json rename to pkgs/by-name/op/openjfx/17/source.json diff --git a/pkgs/development/compilers/openjdk/openjfx/21/deps.json b/pkgs/by-name/op/openjfx/21/deps.json similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/21/deps.json rename to pkgs/by-name/op/openjfx/21/deps.json diff --git a/pkgs/development/compilers/openjdk/openjfx/21/patches/backport-ffmpeg-7-support-jfx21.patch b/pkgs/by-name/op/openjfx/21/patches/backport-ffmpeg-7-support-jfx21.patch similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/21/patches/backport-ffmpeg-7-support-jfx21.patch rename to pkgs/by-name/op/openjfx/21/patches/backport-ffmpeg-7-support-jfx21.patch diff --git a/pkgs/development/compilers/openjdk/openjfx/21/source.json b/pkgs/by-name/op/openjfx/21/source.json similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/21/source.json rename to pkgs/by-name/op/openjfx/21/source.json diff --git a/pkgs/development/compilers/openjdk/openjfx/23/deps.json b/pkgs/by-name/op/openjfx/23/deps.json similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/23/deps.json rename to pkgs/by-name/op/openjfx/23/deps.json diff --git a/pkgs/development/compilers/openjdk/openjfx/23/source.json b/pkgs/by-name/op/openjfx/23/source.json similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/23/source.json rename to pkgs/by-name/op/openjfx/23/source.json diff --git a/pkgs/development/compilers/openjdk/openjfx/generic.nix b/pkgs/by-name/op/openjfx/package.nix similarity index 100% rename from pkgs/development/compilers/openjdk/openjfx/generic.nix rename to pkgs/by-name/op/openjfx/package.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 534b09999bd6..c046335cdac1 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15039,8 +15039,9 @@ with pkgs; hugs = callPackage ../development/interpreters/hugs { }; - inherit (javaPackages) openjfx17 openjfx21 openjfx23; - openjfx = openjfx17; + openjfx17 = openjfx; + openjfx21 = callPackage ../by-name/op/openjfx/package.nix { featureVersion = "21"; }; + openjfx23 = callPackage ../by-name/op/openjfx/package.nix { featureVersion = "23"; }; openjdk8-bootstrap = javaPackages.compiler.openjdk8-bootstrap; openjdk8 = javaPackages.compiler.openjdk8; diff --git a/pkgs/top-level/java-packages.nix b/pkgs/top-level/java-packages.nix index edcd30c45970..bef177372945 100644 --- a/pkgs/top-level/java-packages.nix +++ b/pkgs/top-level/java-packages.nix @@ -2,13 +2,8 @@ with pkgs; -let - openjfx17 = callPackage ../development/compilers/openjdk/openjfx/generic.nix { featureVersion = "17"; }; - openjfx21 = callPackage ../development/compilers/openjdk/openjfx/generic.nix { featureVerison = "21"; }; - openjfx23 = callPackage ../development/compilers/openjdk/openjfx/generic.nix { featureVersion = "23"; }; - -in { - inherit openjfx17 openjfx21 openjfx23; +{ + inherit (pkgs) openjfx17 openjfx21 openjfx23; compiler = let mkOpenjdk = featureVersion: path-darwin: From 49606d943aa634938c6b74f35125e6b7a2ba2bc7 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 18 Oct 2024 12:10:05 +0100 Subject: [PATCH 13/17] _experimental-update-script-combinators.sequence: handle silent scripts Co-authored-by: Jan Tojnar --- pkgs/common-updater/combinators.nix | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pkgs/common-updater/combinators.nix b/pkgs/common-updater/combinators.nix index dadbb1e81ca4..a774328380bb 100644 --- a/pkgs/common-updater/combinators.nix +++ b/pkgs/common-updater/combinators.nix @@ -120,21 +120,33 @@ rec { let scripts = scriptsNormalized; hasCommitSupport = lib.findSingle ({ supportedFeatures, ... }: supportedFeatures == [ "commit" ]) null null scripts != null; + hasSilentSupport = lib.findFirst ({ supportedFeatures, ... }: supportedFeatures == [ "silent" ]) null scripts != null; + # Supported features currently only describe the format of the standard output of the update script. + # Here we ensure that the standard output of the combined update script is well formed. validateFeatures = if hasCommitSupport then + # Exactly one update script declares only “commit” feature and all the rest declare only “silent” feature. ({ supportedFeatures, ... }: supportedFeatures == [ "commit" ] || supportedFeatures == [ "silent" ]) + else if hasSilentSupport then + # All update scripts declare only “silent” feature. + ({ supportedFeatures, ... }: supportedFeatures == [ "silent" ]) else + # No update script declares any supported feature to fail loudly on unknown features rather than silently discard them. ({ supportedFeatures, ... }: supportedFeatures == [ ]); in - assert lib.assertMsg (lib.all validateFeatures scripts) "Combining update scripts with features enabled (other than a single script with “commit” and all other with “silent”) is currently unsupported."; + assert lib.assertMsg (lib.all validateFeatures scripts) "Combining update scripts with features enabled (other than “silent” scripts and an optional single script with “commit”) is currently unsupported."; assert lib.assertMsg (builtins.length (lib.unique (builtins.map ({ attrPath ? null, ... }: attrPath) scripts)) == 1) "Combining update scripts with different attr paths is currently unsupported."; { command = commandsToShellInvocation (builtins.map ({ command, ... }: command) scripts); - supportedFeatures = lib.optionals hasCommitSupport [ - "commit" - ]; + supportedFeatures = + if hasCommitSupport then + [ "commit" ] + else if hasSilentSupport then + [ "silent" ] + else + [ ]; }; /* From cdddf15c81660d9d039b7779d51bb7f05bdf502f Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 6 Oct 2024 03:44:39 +0100 Subject: [PATCH 14/17] nixpkgs-openjdk-updater: init at 0.1.0 --- .../nixpkgs-openjdk-updater/.gitignore | 4 + .../nixpkgs-openjdk-updater/.python-version | 1 + .../nixpkgs-openjdk-updater/pyproject.toml | 41 +++++ .../src/nixpkgs_openjdk_updater/__init__.py | 173 ++++++++++++++++++ .../ni/nixpkgs-openjdk-updater/package.nix | 80 ++++++++ 5 files changed, 299 insertions(+) create mode 100644 pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/.gitignore create mode 100644 pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/.python-version create mode 100644 pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/pyproject.toml create mode 100644 pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/src/nixpkgs_openjdk_updater/__init__.py create mode 100644 pkgs/by-name/ni/nixpkgs-openjdk-updater/package.nix diff --git a/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/.gitignore b/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/.gitignore new file mode 100644 index 000000000000..897636e0d11c --- /dev/null +++ b/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/.gitignore @@ -0,0 +1,4 @@ +.pytest_cache +.ruff_cache +.venv +uv.lock diff --git a/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/.python-version b/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/.python-version new file mode 100644 index 000000000000..e4fba2183587 --- /dev/null +++ b/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/pyproject.toml b/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/pyproject.toml new file mode 100644 index 000000000000..1fa811700b05 --- /dev/null +++ b/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/pyproject.toml @@ -0,0 +1,41 @@ +[project] +name = "nixpkgs-openjdk-updater" +version = "0.1.0" +description = "Update tool for Nixpkgs OpenJDK packages" +requires-python = ">=3.12" +dependencies = [ + "pydantic>=2.8.2", + "pygithub>=2.4.0", +] + +[project.scripts] +nixpkgs-openjdk-updater = "nixpkgs_openjdk_updater:main" + +[build-system] +requires = ["hatchling>=1.25.0"] +build-backend = "hatchling.build" + +[tool.pyright] +include = ["src"] +strict = ["**/*"] +pythonVersion = "3.12" + +[tool.pytest.ini_options] +addopts = "--doctest-modules" + +[tool.ruff] +line-length = 80 + +[tool.ruff.lint] +select = ["ALL"] +ignore = ["COM812", "D203", "D213", "ISC001", "T201"] +allowed-confusables = ["’"] + +[tool.ruff.format] +docstring-code-format = true +docstring-code-line-length = "dynamic" + +[tool.uv] +dev-dependencies = [ + "pytest>=8.3.3", +] diff --git a/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/src/nixpkgs_openjdk_updater/__init__.py b/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/src/nixpkgs_openjdk_updater/__init__.py new file mode 100644 index 000000000000..9c18219770d2 --- /dev/null +++ b/pkgs/by-name/ni/nixpkgs-openjdk-updater/nixpkgs-openjdk-updater/src/nixpkgs_openjdk_updater/__init__.py @@ -0,0 +1,173 @@ +"""Update tool for Nixpkgs OpenJDK packages.""" + +import argparse +import json +import os +import re +import subprocess +from pathlib import Path +from typing import Literal + +import github +from pydantic import BaseModel + + +class SourceInfo(BaseModel): + """GitHub fetcher data for an OpenJDK release tag.""" + + owner: str + repo: str + rev: str + hash: str + + +type Update = tuple[int, ...] +type Build = int | Literal["ga"] + + +def parse_openjdk_ref_name( + feature_version_prefix: str, + ref_name: str, +) -> tuple[Update, Build]: + r"""Parse an OpenJDK Git ref name containing a JDK version. + + Takes the tag name prefix for a given feature version and parses + the rest of the version and build information. + + See |java.lang.Runtime.Version|_ for documentation of the modern + version string scheme initially introduced in `JEP 223`_ for JDK 9, + though this tool also supports JDK 8 for now. + + .. |java.lang.Runtime.Version| replace:: ``java.lang.Runtime.Version`` + .. _java.lang.Runtime.Version: https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/Runtime.Version.html + .. _JEP 223: https://openjdk.org/jeps/223 + + >>> parse_openjdk_ref_name("jdk-23", "refs/tags/jdk-23-ga") + ((), 'ga') + >>> parse_openjdk_ref_name("jdk-17", "refs/tags/jdk-17.0.2+7") + ((0, 2), 7) + >>> parse_openjdk_ref_name("jdk8", "refs/tags/jdk8u422-ga") + ((422,), 'ga') + >>> parse_openjdk_ref_name("jdk8", "refs/tags/jdk8-b01") + ((), 1) + >>> parse_openjdk_ref_name("22", "refs/tags/22.0.2-ga") + ((0, 2), 'ga') + >>> parse_openjdk_ref_name("jdk8", "refs/tags/jdk7-b147") + Traceback (most recent call last): + ... + ValueError: unexpected OpenJDK ref name: refs/tags/jdk7-b147 + >>> parse_openjdk_ref_name("jdk8", "refs/tags/jdk80-ga") + Traceback (most recent call last): + ... + ValueError: unexpected OpenJDK ref name: refs/tags/jdk80-ga + >>> parse_openjdk_ref_name("11", "refs/tags/jdk-11+14") + Traceback (most recent call last): + ... + ValueError: unexpected OpenJDK ref name: refs/tags/jdk-11+14 + """ + m = re.fullmatch( + rf""" + refs/tags/{re.escape(feature_version_prefix)} + (?P + (?:u[0-9]+)? # JDK 8 uses u + | (?:\.[0-9]+)* + ) + (?P + -ga + | (\+|-b) # JDK 8 uses -b + [0-9]+ + ) + """, + ref_name, + re.VERBOSE, + ) + if not m: + msg = f"unexpected OpenJDK ref name: {ref_name}" + raise ValueError(msg) + update = tuple( + int(element) for element in m["update"].replace("u", ".").split(".")[1:] + ) + build = ( + "ga" + if m["build"] == "-ga" + else int(m["build"].removeprefix("+").removeprefix("-b")) + ) + return update, build + + +def main() -> None: + """Update a Nixpkgs OpenJDK package.""" + parser = argparse.ArgumentParser(description=main.__doc__) + parser.add_argument("--source-file", type=Path, required=True) + parser.add_argument("--owner", required=True) + parser.add_argument("--repo", required=True) + parser.add_argument("--feature-version-prefix", required=True) + args = parser.parse_args() + + source_info: SourceInfo | None + try: + with args.source_file.open() as source_fp: + source_info = SourceInfo(**json.load(source_fp)) + except FileNotFoundError: + source_info = None + + token = os.environ.get("GITHUB_TOKEN") + gh = github.Github(auth=github.Auth.Token(token) if token else None) + + repo = gh.get_repo(f"{args.owner}/{args.repo}") + versions: dict[Update, dict[Build, str]] = {} + for ref in repo.get_git_matching_refs( + "tags/" + args.feature_version_prefix + ): + update, build = parse_openjdk_ref_name( + args.feature_version_prefix, + ref.ref, + ) + versions.setdefault(update, {})[build] = ref.ref + + # We want a finalized General Availability release version, but we + # want to pin a tag with the build number in it so that we can use + # it for version information. + # + # The OpenJDK `-ga` tags point to the same commits as the highest + # build number for a given version, so we find and pin that. + latest_release_builds = versions[ + max(update for update, builds in versions.items() if "ga" in builds) + ] + latest_release_ref_name = latest_release_builds[ + max(latest_release_builds.keys() - {"ga"}) + ] + + if source_info and source_info.rev == latest_release_ref_name: + return + + prefetch_result = subprocess.run( # noqa: S603 + ( + "nix", + "--extra-experimental-features", + "nix-command", + "store", + "prefetch-file", + "--json", + "--unpack", + "--name", + "source", + repo.get_archive_link("tarball", latest_release_ref_name), + ), + check=True, + stdout=subprocess.PIPE, + ) + source_info = SourceInfo( + owner=args.owner, + repo=args.repo, + rev=latest_release_ref_name, + hash=json.loads(prefetch_result.stdout)["hash"], + ) + with args.source_file.open("w") as source_fp: + json.dump( + source_info.model_dump(), + source_fp, + indent=" ", + sort_keys=True, + ) + print(file=source_fp) diff --git a/pkgs/by-name/ni/nixpkgs-openjdk-updater/package.nix b/pkgs/by-name/ni/nixpkgs-openjdk-updater/package.nix new file mode 100644 index 000000000000..124a1fced4c6 --- /dev/null +++ b/pkgs/by-name/ni/nixpkgs-openjdk-updater/package.nix @@ -0,0 +1,80 @@ +{ + lib, + python3Packages, + ruff, + pyright, + fetchFromGitHub, + nixpkgs-openjdk-updater, +}: + +python3Packages.buildPythonApplication { + pname = "nixpkgs-openjdk-updater"; + version = "0.1.0"; + format = "pyproject"; + + src = ./nixpkgs-openjdk-updater; + + build-system = [ python3Packages.hatchling ]; + + dependencies = [ + python3Packages.pydantic + python3Packages.pygithub + ]; + + nativeCheckInputs = [ + ruff + pyright + python3Packages.pytestCheckHook + ]; + + preCheck = '' + ruff format --check + ruff check + pyright + ''; + + postCheck = '' + $out/bin/nixpkgs-openjdk-updater --help >/dev/null + ''; + + passthru.openjdkSource = + { + sourceFile, + featureVersionPrefix, + }: + let + # TODO: Tighten up after update scripts are run. + src = fetchFromGitHub (lib.importJSON sourceFile); + in + { + inherit src; + + updateScript = { + command = [ + (lib.getExe nixpkgs-openjdk-updater) + + "--source-file" + sourceFile + + "--owner" + src.owner + + "--repo" + src.repo + + "--feature-version-prefix" + featureVersionPrefix + ]; + + supportedFeatures = [ "silent" ]; + }; + }; + + meta = { + description = "Updater for Nixpkgs OpenJDK packages"; + license = lib.licenses.mit; + sourceProvenance = [ lib.sourceTypes.fromSource ]; + maintainers = [ lib.maintainers.emily ]; + mainProgram = "nixpkgs-openjdk-updater"; + }; +} From bb161ee1388034171b7d840cc4ea3ecee16a8544 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 6 Oct 2024 03:44:39 +0100 Subject: [PATCH 15/17] openjdk{8,11,17,21,23}: add update script --- pkgs/development/compilers/openjdk/generic.nix | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkgs/development/compilers/openjdk/generic.nix b/pkgs/development/compilers/openjdk/generic.nix index 00a66512161e..49742ca8b989 100644 --- a/pkgs/development/compilers/openjdk/generic.nix +++ b/pkgs/development/compilers/openjdk/generic.nix @@ -4,7 +4,6 @@ lib, stdenv, - fetchFromGitHub, fetchurl, fetchpatch, @@ -48,6 +47,8 @@ liberation_ttf, cacert, + nixpkgs-openjdk-updater, + # TODO(@sternenseemann): gtk3 fails to evaluate in pkgsCross.ghcjs.buildPackages # which should be fixable, this is a no-rebuild workaround for GHC. headless ? lib.versionAtLeast featureVersion "21" && stdenv.targetPlatform.isGhcjs, @@ -87,7 +88,10 @@ let sourceFile = ./. + "/${featureVersion}/source.json"; - sourceInfo = lib.importJSON sourceFile; + source = nixpkgs-openjdk-updater.openjdkSource { + inherit sourceFile; + featureVersionPrefix = tagPrefix + featureVersion; + }; atLeast11 = lib.versionAtLeast featureVersion "11"; atLeast17 = lib.versionAtLeast featureVersion "17"; @@ -97,7 +101,7 @@ let tagPrefix = if atLeast11 then "jdk-" else "jdk"; # TODO: Merge these `lib.removePrefix` calls once update scripts have # been run. - version = lib.removePrefix tagPrefix (lib.removePrefix "refs/tags/" sourceInfo.rev); + version = lib.removePrefix tagPrefix (lib.removePrefix "refs/tags/" source.src.rev); versionSplit = # TODO: Remove `-ga` logic once update scripts have been run. builtins.match (if atLeast11 then "(.+)[-+](.+)" else "(.+)-b?(.+)") version; @@ -137,9 +141,7 @@ stdenv.mkDerivation (finalAttrs: { "jre" ]; - src = fetchFromGitHub { - inherit (sourceInfo) owner repo rev hash; - }; + inherit (source) src; patches = [ @@ -622,8 +624,8 @@ stdenv.mkDerivation (finalAttrs: { passthru = { home = "${finalAttrs.finalPackage}/lib/openjdk"; - inherit jdk-bootstrap; + inherit (source) updateScript; } // (if atLeast11 then { inherit gtk3; } else { inherit gtk2; }) // lib.optionalAttrs (!atLeast23) { From f3b30d484e5f4afc155554c00542ca07e38d51c9 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 18 Oct 2024 05:52:44 +0100 Subject: [PATCH 16/17] openjfx{17,21,23}: add update script --- pkgs/by-name/op/openjfx/package.nix | 42 +++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/op/openjfx/package.nix b/pkgs/by-name/op/openjfx/package.nix index e2cd6ced4f8c..96269280f7b6 100644 --- a/pkgs/by-name/op/openjfx/package.nix +++ b/pkgs/by-name/op/openjfx/package.nix @@ -5,7 +5,6 @@ stdenv, pkgs, - fetchFromGitHub, fetchpatch2, gradle, @@ -28,6 +27,11 @@ writeText, + _experimental-update-script-combinators, + nixpkgs-openjdk-updater, + writeShellScript, + path, + withMedia ? true, withWebKit ? false, @@ -45,7 +49,10 @@ let sourceFile = ./. + "/${featureVersion}/source.json"; - sourceInfo = lib.importJSON sourceFile; + source = nixpkgs-openjdk-updater.openjdkSource { + inherit sourceFile; + featureVersionPrefix = featureVersion; + }; atLeast21 = lib.versionAtLeast featureVersion "21"; atLeast23 = lib.versionAtLeast featureVersion "23"; @@ -58,10 +65,9 @@ assert lib.assertMsg (lib.pathExists sourceFile) stdenv.mkDerivation { pname = "openjfx-modular-sdk"; - version = lib.removePrefix "refs/tags/" sourceInfo.rev; + version = lib.removePrefix "refs/tags/" source.src.rev; - # TODO: Tighten up after update scripts are run. - src = fetchFromGitHub sourceInfo; + inherit (source) src; patches = if featureVersion == "23" then @@ -166,6 +172,32 @@ stdenv.mkDerivation { gradle_openjfx.jdk ]; + passthru.updateScript = _experimental-update-script-combinators.sequence [ + source.updateScript + + { + command = [ + # We need to do this separate script rather than simply using + # `finalAttrs.mitmCache.updateScript` because the Gradle update + # script captures the source at the time of evaluation, making + # it miss the update. + (writeShellScript "update-openjfx-deps.sh" '' + eval "$( + nix-build "$1" \ + -A openjfx${featureVersion}.mitmCache.updateScript + )" + '') + + # This has to be a separate argument so that + # `maintainers/scripts/update.py` can rewrite it to the + # appropriate Git work tree. + path + ]; + + supportedFeatures = [ "silent" ]; + } + ]; + meta = { description = "Next-generation Java client toolkit"; homepage = "https://openjdk.org/projects/openjfx/"; From cdeea95bc0b102aa6319af4890cd0821f811ef4f Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 24 Oct 2024 17:04:43 +0200 Subject: [PATCH 17/17] paperless-ngx: disable failing tests These are due to a test-only dependency, so no functionality should be impaired. --- pkgs/applications/office/paperless-ngx/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/applications/office/paperless-ngx/default.nix b/pkgs/applications/office/paperless-ngx/default.nix index b0e51f5a8e54..34549330a747 100644 --- a/pkgs/applications/office/paperless-ngx/default.nix +++ b/pkgs/applications/office/paperless-ngx/default.nix @@ -257,6 +257,10 @@ python.pkgs.buildPythonApplication rec { "testNormalOperation" # Something broken with new Tesseract and inline RTL/LTR overrides? "test_rtl_language_detection" + # Broke during the pytest-httpx 0.30.0 -> 0.32.0 upgrade + "test_request_pdf_a_format" + "test_generate_pdf_html_email" + "test_generate_pdf_html_email_merge_failure" ]; doCheck = !stdenv.hostPlatform.isDarwin;