diff --git a/pkgs/development/compilers/openjdk/jre.nix b/pkgs/development/compilers/openjdk/jre.nix index 817cdf9c26a97..436bd0468c52d 100644 --- a/pkgs/development/compilers/openjdk/jre.nix +++ b/pkgs/development/compilers/openjdk/jre.nix @@ -1,19 +1,34 @@ -{ jdk -, runCommand -, patchelf +{ stdenv +, jdk , lib , modules ? [ "java.base" ] }: let - jre = runCommand "${jdk.name}-jre" { - nativeBuildInputs = [ patchelf ]; + jre = stdenv.mkDerivation { + name = "${jdk.name}-minimal-jre"; + version = jdk.version; + buildInputs = [ jdk ]; + + dontUnpack = true; + + # Strip more heavily than the default '-S', since if you're + # using this derivation you probably care about this. + stripDebugFlags = [ "--strip-unneeded" ]; + + buildPhase = '' + runHook preBuild + + jlink --module-path ${jdk}/lib/openjdk/jmods --add-modules ${lib.concatStringsSep "," modules} --output $out + + runHook postBuild + ''; + + dontInstall = true; + passthru = { home = "${jre}"; }; - } '' - jlink --module-path ${jdk}/lib/openjdk/jmods --add-modules ${lib.concatStringsSep "," modules} --output $out - patchelf --shrink-rpath $out/bin/* $out/lib/jexec $out/lib/jspawnhelper $out/lib/*.so $out/lib/*/*.so - ''; + }; in jre