git.iko.soy/typeable/nixpkgs
on master help sign in
jre_minimal: strip libraries

runCommand doesn't invoke the automatic stripping from stdenv, expanding the derivation like this does. Fixes #115486

commitd3e904068665e9358afbd0757e87c941092620cf authorArnout Engelen <arnout@bzzt.net> dateTue 9 Mar 2021, 13:24 (6 years ago) parent102eb68
1 file changed+24−9
pkgs/development/compilers/openjdk/jre.nix+24−9
pkgs/development/compilers/openjdk/jre.nix+24−9
@@ -1,19 +1,34 @@
1−{ jdk
2−, runCommand
3−, patchelf
1+{ stdenv
2+, jdk
43, lib
54, modules ? [ "java.base" ]
65}:
76
87let
9− jre = runCommand "${jdk.name}-jre" {
10− nativeBuildInputs = [ patchelf ];
8+ jre = stdenv.mkDerivation {
9+ name = "${jdk.name}-minimal-jre";
10+ version = jdk.version;
11+
1112 buildInputs = [ jdk ];
13+
14+ dontUnpack = true;
15+
16+ # Strip more heavily than the default '-S', since if you're
17+ # using this derivation you probably care about this.
18+ stripDebugFlags = [ "--strip-unneeded" ];
19+
20+ buildPhase = ''
21+ runHook preBuild
22+
23+ jlink --module-path ${jdk}/lib/openjdk/jmods --add-modules ${lib.concatStringsSep "," modules} --output $out
24+
25+ runHook postBuild
26+ '';
27+
28+ dontInstall = true;
29+
1230 passthru = {
1331 home = "${jre}";
1432 };
15− } ''
16− jlink --module-path ${jdk}/lib/openjdk/jmods --add-modules ${lib.concatStringsSep "," modules} --output $out
17− patchelf --shrink-rpath $out/bin/* $out/lib/jexec $out/lib/jspawnhelper $out/lib/*.so $out/lib/*/*.so
18− '';
33+ };
1934in jre