openjdk: add derivation to generate bespoke minimal JRE's
Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
This commit is contained in:
19
pkgs/development/compilers/openjdk/jre.nix
Normal file
19
pkgs/development/compilers/openjdk/jre.nix
Normal 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
|
||||
Reference in New Issue
Block a user