2021-03-19 15:36:28 +00:00
|
|
|
{ sourcePerArch, knownVulnerabilities ? [] }:
|
2018-10-13 14:42:21 +00:00
|
|
|
|
2019-07-21 19:40:18 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
2018-10-13 14:42:21 +00:00
|
|
|
, fetchurl
|
2019-07-21 19:40:18 +00:00
|
|
|
, autoPatchelfHook
|
2020-12-20 06:22:31 +00:00
|
|
|
, makeWrapper
|
2020-12-12 07:19:55 +00:00
|
|
|
, setJavaClassPath
|
2020-12-20 06:22:31 +00:00
|
|
|
# minimum dependencies
|
2021-06-10 02:57:09 +00:00
|
|
|
, alsa-lib
|
2019-08-10 18:47:54 +00:00
|
|
|
, fontconfig
|
2020-12-20 06:22:31 +00:00
|
|
|
, freetype
|
2019-10-12 03:22:18 +00:00
|
|
|
, libffi
|
2020-12-20 06:22:31 +00:00
|
|
|
, xorg
|
|
|
|
, zlib
|
|
|
|
# runtime dependencies
|
|
|
|
, cups
|
|
|
|
# runtime dependencies for GTK+ Look and Feel
|
|
|
|
, gtkSupport ? true
|
|
|
|
, cairo
|
|
|
|
, glib
|
|
|
|
, gtk3
|
2018-10-13 14:42:21 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2019-01-23 11:52:02 +00:00
|
|
|
cpuName = stdenv.hostPlatform.parsed.cpu.name;
|
2020-12-20 06:22:31 +00:00
|
|
|
runtimeDependencies = [
|
|
|
|
cups
|
|
|
|
] ++ lib.optionals gtkSupport [
|
|
|
|
cairo glib gtk3
|
|
|
|
];
|
|
|
|
runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies;
|
2018-10-13 14:42:21 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
let result = stdenv.mkDerivation rec {
|
2022-03-01 16:12:33 +00:00
|
|
|
pname = if sourcePerArch.packageType == "jdk"
|
|
|
|
then "adoptopenjdk-${sourcePerArch.vmType}-bin"
|
|
|
|
else "adoptopenjdk-${sourcePerArch.packageType}-${sourcePerArch.vmType}-bin";
|
2019-01-27 09:42:57 +00:00
|
|
|
|
|
|
|
version = sourcePerArch.${cpuName}.version or (throw "unsupported CPU ${cpuName}");
|
2018-10-13 14:42:21 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-01-23 11:52:02 +00:00
|
|
|
inherit (sourcePerArch.${cpuName}) url sha256;
|
2018-10-13 14:42:21 +00:00
|
|
|
};
|
|
|
|
|
2019-07-21 19:40:18 +00:00
|
|
|
buildInputs = [
|
2021-06-10 02:57:09 +00:00
|
|
|
alsa-lib # libasound.so wanted by lib/libjsound.so
|
2020-12-20 06:22:31 +00:00
|
|
|
fontconfig
|
|
|
|
freetype
|
|
|
|
stdenv.cc.cc.lib # libstdc++.so.6
|
|
|
|
xorg.libX11
|
|
|
|
xorg.libXext
|
|
|
|
xorg.libXi
|
|
|
|
xorg.libXrender
|
|
|
|
xorg.libXtst
|
|
|
|
zlib
|
2019-10-12 03:22:18 +00:00
|
|
|
] ++ lib.optional stdenv.isAarch32 libffi;
|
2019-07-21 19:40:18 +00:00
|
|
|
|
2020-12-20 06:22:31 +00:00
|
|
|
nativeBuildInputs = [ autoPatchelfHook makeWrapper ];
|
2018-10-13 14:42:21 +00:00
|
|
|
|
|
|
|
# See: https://github.com/NixOS/patchelf/issues/10
|
|
|
|
dontStrip = 1;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
mv $sourceRoot $out
|
|
|
|
|
2021-01-23 06:33:57 +00:00
|
|
|
# jni.h expects jni_md.h to be in the header search path.
|
|
|
|
ln -s $out/include/linux/*_md.h $out/include/
|
|
|
|
|
2018-10-13 14:42:21 +00:00
|
|
|
rm -rf $out/demo
|
|
|
|
|
|
|
|
# Remove some broken manpages.
|
|
|
|
rm -rf $out/man/ja*
|
|
|
|
|
2019-03-16 10:37:11 +00:00
|
|
|
# Remove embedded freetype to avoid problems like
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/57733
|
2019-07-21 19:40:18 +00:00
|
|
|
find "$out" -name 'libfreetype.so*' -delete
|
2018-10-13 14:42:21 +00:00
|
|
|
|
2020-12-12 07:19:55 +00:00
|
|
|
# Propagate the setJavaClassPath setup hook from the JDK so that
|
|
|
|
# any package that depends on the JDK has $CLASSPATH set up
|
|
|
|
# properly.
|
2018-10-13 14:42:21 +00:00
|
|
|
mkdir -p $out/nix-support
|
2020-12-12 07:19:55 +00:00
|
|
|
printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs
|
2018-10-13 14:42:21 +00:00
|
|
|
|
|
|
|
# Set JAVA_HOME automatically.
|
2019-08-10 18:47:54 +00:00
|
|
|
cat <<EOF >> "$out/nix-support/setup-hook"
|
2019-11-01 19:30:09 +00:00
|
|
|
if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
|
2018-10-13 14:42:21 +00:00
|
|
|
EOF
|
2020-12-20 06:22:31 +00:00
|
|
|
|
|
|
|
# We cannot use -exec since wrapProgram is a function but not a command.
|
2021-02-27 10:20:23 +00:00
|
|
|
#
|
|
|
|
# jspawnhelper is executed from JVM, so it doesn't need to wrap it, and it
|
|
|
|
# breaks building OpenJDK (#114495).
|
|
|
|
for bin in $( find "$out" -executable -type f -not -name jspawnhelper ); do
|
2020-12-20 06:22:31 +00:00
|
|
|
if patchelf --print-interpreter "$bin" &> /dev/null; then
|
|
|
|
wrapProgram "$bin" --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}"
|
|
|
|
fi
|
|
|
|
done
|
2018-10-13 14:42:21 +00:00
|
|
|
'';
|
|
|
|
|
2019-08-10 18:47:54 +00:00
|
|
|
preFixup = ''
|
|
|
|
find "$out" -name libfontmanager.so -exec \
|
|
|
|
patchelf --add-needed libfontconfig.so {} \;
|
|
|
|
'';
|
|
|
|
|
2018-10-13 14:42:21 +00:00
|
|
|
# FIXME: use multiple outputs or return actual JRE package
|
|
|
|
passthru.jre = result;
|
|
|
|
|
|
|
|
passthru.home = result;
|
|
|
|
|
2021-01-22 11:25:31 +00:00
|
|
|
meta = with lib; {
|
2018-10-13 14:42:21 +00:00
|
|
|
license = licenses.gpl2Classpath;
|
2022-06-01 08:01:19 +00:00
|
|
|
sourceProvenance = with sourceTypes; [ binaryNativeCode binaryBytecode ];
|
2018-10-13 14:42:21 +00:00
|
|
|
description = "AdoptOpenJDK, prebuilt OpenJDK binary";
|
2019-07-21 19:40:18 +00:00
|
|
|
platforms = lib.mapAttrsToList (arch: _: arch + "-linux") sourcePerArch; # some inherit jre.meta.platforms
|
|
|
|
maintainers = with lib.maintainers; [ taku0 ];
|
2021-03-19 15:36:28 +00:00
|
|
|
inherit knownVulnerabilities;
|
2021-04-29 13:48:57 +00:00
|
|
|
mainProgram = "java";
|
2018-10-13 14:42:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}; in result
|