about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2021-04-22 21:34:25 +0200
committerGitHub <noreply@github.com>2021-04-22 21:34:25 +0200
commitfb45a00d6353d89d67521acd38d266845e2d13c2 (patch)
tree830256b774276917deac6a2a3b3b144ed79a4093
parent14c8ae6efbf38dd4fd5fedaeeea2641c9c0e1e97 (diff)
parentd3e904068665e9358afbd0757e87c941092620cf (diff)
downloadnixlib-fb45a00d6353d89d67521acd38d266845e2d13c2.tar
nixlib-fb45a00d6353d89d67521acd38d266845e2d13c2.tar.gz
nixlib-fb45a00d6353d89d67521acd38d266845e2d13c2.tar.bz2
nixlib-fb45a00d6353d89d67521acd38d266845e2d13c2.tar.lz
nixlib-fb45a00d6353d89d67521acd38d266845e2d13c2.tar.xz
nixlib-fb45a00d6353d89d67521acd38d266845e2d13c2.tar.zst
nixlib-fb45a00d6353d89d67521acd38d266845e2d13c2.zip
Merge pull request #115523 from raboof/jre_minimal-strip-library
jre_minimal: strip libraries
-rw-r--r--pkgs/development/compilers/openjdk/jre.nix33
1 files changed, 24 insertions, 9 deletions
diff --git a/pkgs/development/compilers/openjdk/jre.nix b/pkgs/development/compilers/openjdk/jre.nix
index 817cdf9c26a9..436bd0468c52 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