about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/openjdk/jre.nix
blob: 02f6da928cdd3ed6ca8931a9310a55be822e68ef (plain) (blame)
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
{ stdenv
, jdk
, lib
, callPackage
, modules ? [ "java.base" ]
}:

let
  jre = stdenv.mkDerivation {
    pname = "${jdk.pname}-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}";
      tests = [
        (callPackage ./tests/test_jre_minimal.nix {})
        (callPackage ./tests/test_jre_minimal_with_logging.nix {})
      ];
    };
  };
in jre