Skip to content

Commit

Permalink
jre_minimal: strip libraries
Browse files Browse the repository at this point in the history
runCommand doesn't invoke the automatic stripping from stdenv,
expanding the derivation like this does.

Fixes #115486
  • Loading branch information
raboof committed Mar 11, 2021
1 parent 102eb68 commit d3e9040
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions pkgs/development/compilers/openjdk/jre.nix
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d3e9040

Please sign in to comment.