openjdk: add derivation to generate bespoke minimal JRE's

Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
This commit is contained in:
Arnout Engelen
2020-09-19 13:30:09 +02:00
parent f6ee70d3ea
commit d4efa08b53
3 changed files with 45 additions and 3 deletions

View File

@@ -0,0 +1,19 @@
{ jdk
, runCommand
, patchelf
, lib
, modules ? [ "java.base" ]
}:
let
jre = runCommand "${jdk.name}-jre" {
nativeBuildInputs = [ patchelf ];
buildInputs = [ jdk ];
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