blob: 9e9498f4d6dca6084fd76d30ac7754975e68d02f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
{
stdenv,
jdk,
jdkOnBuild, # must provide jlink
lib,
callPackage,
modules ? [ "java.base" ],
}:
stdenv.mkDerivation (finalAttrs: {
pname = "${jdk.pname}-minimal-jre";
version = jdk.version;
nativeBuildInputs = [ jdkOnBuild ];
buildInputs = [ jdk ];
strictDeps = 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" ];
buildPhase = ''
runHook preBuild
jlink --module-path ${jdk}/lib/openjdk/jmods --add-modules ${lib.concatStringsSep "," modules} --output $out
runHook postBuild
'';
dontInstall = true;
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 { };
};
};
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.
'';
};
})
|