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