jre: fix missing meta, simplify the expression

This commit is contained in:
Pol Dellaiera 2025-07-03 14:27:47 +02:00
parent 0e71da91f0
commit 73661d9fb4

View File

@ -7,38 +7,43 @@
modules ? [ "java.base" ],
}:
let
jre = stdenv.mkDerivation {
pname = "${jdk.pname}-minimal-jre";
version = jdk.version;
stdenv.mkDerivation (finalAttrs: {
pname = "${jdk.pname}-minimal-jre";
version = jdk.version;
nativeBuildInputs = [ jdkOnBuild ];
buildInputs = [ jdk ];
strictDeps = true;
nativeBuildInputs = [ jdkOnBuild ];
buildInputs = [ jdk ];
strictDeps = true;
dontUnpack = true;
dontUnpack = true;
# Strip more heavily than the default '-S', since if you're
# using this derivation you probably care about this.
stripDebugFlags = [ "--strip-unneeded" ];
# 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
buildPhase = ''
runHook preBuild
jlink --module-path ${jdk}/lib/openjdk/jmods --add-modules ${lib.concatStringsSep "," modules} --output $out
jlink --module-path ${jdk}/lib/openjdk/jmods --add-modules ${lib.concatStringsSep "," modules} --output $out
runHook postBuild
'';
runHook postBuild
'';
dontInstall = true;
dontInstall = true;
passthru = {
home = "${jre}";
tests = {
jre_minimal-hello = callPackage ./tests/test_jre_minimal.nix { };
jre_minimal-hello-logging = callPackage ./tests/test_jre_minimal_with_logging.nix { };
};
passthru = {
home = "${finalAttrs.finalPackage}";
tests = {
jre_minimal-hello = callPackage ./tests/test_jre_minimal.nix { };
jre_minimal-hello-logging = callPackage ./tests/test_jre_minimal_with_logging.nix { };
};
};
in
jre
meta = jdk.meta // {
description = "Minimal JRE for OpenJDK ${jdk.version}";
longDescription = ''
This is a minimal JRE built from OpenJDK, containing only the specified modules.
It is suitable for running Java applications that do not require the full JDK.
'';
};
})