2024-05-13 21:24:10 +00:00
|
|
|
{ sourcePerArch, knownVulnerabilities ? [ ] }:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
{ swingSupport ? true # not used for now
|
2024-05-13 21:24:10 +00:00
|
|
|
, lib, stdenv, fetchurl, setJavaClassPath }:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
assert (stdenv.isDarwin && stdenv.isx86_64);
|
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
let
|
|
|
|
cpuName = stdenv.hostPlatform.parsed.cpu.name;
|
|
|
|
result = stdenv.mkDerivation {
|
|
|
|
pname = if sourcePerArch.packageType == "jdk" then
|
|
|
|
"adoptopenjdk-${sourcePerArch.vmType}-bin"
|
|
|
|
else
|
|
|
|
"adoptopenjdk-${sourcePerArch.packageType}-${sourcePerArch.vmType}-bin";
|
|
|
|
version =
|
|
|
|
sourcePerArch.${cpuName}.version or (throw "unsupported CPU ${cpuName}");
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
src = fetchurl { inherit (sourcePerArch.${cpuName}) url sha256; };
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
# See: https://github.com/NixOS/patchelf/issues/10
|
|
|
|
dontStrip = 1;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
installPhase = ''
|
|
|
|
cd ..
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
mv $sourceRoot $out
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
# jni.h expects jni_md.h to be in the header search path.
|
|
|
|
ln -s $out/Contents/Home/include/darwin/*_md.h $out/Contents/Home/include/
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
rm -rf $out/Home/demo
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
# Remove some broken manpages.
|
|
|
|
rm -rf $out/Home/man/ja*
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
ln -s $out/Contents/Home/* $out/
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
# Propagate the setJavaClassPath setup hook from the JDK so that
|
|
|
|
# any package that depends on the JDK has $CLASSPATH set up
|
|
|
|
# properly.
|
|
|
|
mkdir -p $out/nix-support
|
|
|
|
printWords ${setJavaClassPath} > $out/nix-support/propagated-build-inputs
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
# Set JAVA_HOME automatically.
|
|
|
|
cat <<EOF >> $out/nix-support/setup-hook
|
|
|
|
if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
|
|
|
|
EOF
|
|
|
|
'';
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
# FIXME: use multiple outputs or return actual JRE package
|
|
|
|
passthru.jre = result;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
passthru.home = result;
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
meta = with lib; {
|
|
|
|
license = licenses.gpl2Classpath;
|
|
|
|
description = "AdoptOpenJDK, prebuilt OpenJDK binary";
|
|
|
|
platforms = [ "x86_64-darwin" ]; # some inherit jre.meta.platforms
|
|
|
|
maintainers = with lib.maintainers; [ taku0 ];
|
|
|
|
inherit knownVulnerabilities;
|
|
|
|
mainProgram = "java";
|
|
|
|
};
|
2024-05-02 00:46:19 +00:00
|
|
|
|
2024-05-13 21:24:10 +00:00
|
|
|
};
|
|
|
|
in result
|