2021-12-16 21:37:35 -05:00
|
|
|
{
|
2021-12-17 06:50:04 -05:00
|
|
|
description = "Adoptium Java";
|
2021-12-16 21:37:35 -05:00
|
|
|
|
2021-12-17 06:50:04 -05:00
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
utils.url = "github:numtide/flake-utils";
|
|
|
|
};
|
2021-12-16 21:37:35 -05:00
|
|
|
|
2021-12-17 06:50:04 -05:00
|
|
|
outputs = { self, nixpkgs, utils }:
|
2022-11-29 04:26:36 -05:00
|
|
|
utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
|
2021-12-17 06:50:04 -05:00
|
|
|
let
|
|
|
|
sources = builtins.fromJSON (builtins.readFile ./sources.json);
|
2022-11-29 01:16:44 -05:00
|
|
|
buildAdoptLike = with import nixpkgs { system = system; };
|
|
|
|
name: value:
|
2022-06-14 00:55:47 -04:00
|
|
|
let
|
|
|
|
cpuName = stdenv.hostPlatform.parsed.cpu.name;
|
2022-11-29 01:16:44 -05:00
|
|
|
runtimeDependencies = [ pkgs.cups pkgs.cairo pkgs.glib pkgs.gtk3 ];
|
2022-06-14 00:55:47 -04:00
|
|
|
runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies;
|
2022-11-29 01:16:44 -05:00
|
|
|
in stdenv.mkDerivation rec {
|
2022-06-14 00:55:47 -04:00
|
|
|
name = "jdk${toString value.major_version}";
|
|
|
|
src = builtins.fetchurl {
|
|
|
|
url = value.link;
|
|
|
|
sha256 = value.sha256;
|
2021-12-23 13:11:49 -05:00
|
|
|
};
|
2022-06-14 00:55:47 -04:00
|
|
|
version = value.java_version;
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
alsa-lib
|
|
|
|
fontconfig
|
|
|
|
freetype
|
|
|
|
stdenv.cc.cc.lib
|
|
|
|
xorg.libX11
|
|
|
|
xorg.libXext
|
|
|
|
xorg.libXi
|
|
|
|
xorg.libXrender
|
|
|
|
xorg.libXtst
|
|
|
|
zlib
|
|
|
|
];
|
2022-11-29 01:16:44 -05:00
|
|
|
nativeBuildInputs = with pkgs; [ autoPatchelfHook makeWrapper ];
|
2022-06-14 00:55:47 -04:00
|
|
|
dontStrip = 1;
|
|
|
|
installPhase = ''
|
|
|
|
cd ..
|
|
|
|
mv $sourceRoot $out
|
|
|
|
# jni.h expects jni_md.h to be in the header search path.
|
|
|
|
ln -s $out/include/linux/*_md.h $out/include/
|
|
|
|
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
|
|
|
|
# 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
|
|
|
|
# Set JAVA_HOME automatically.
|
|
|
|
cat <<EOF >> "$out/nix-support/setup-hook"
|
|
|
|
if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
|
|
|
|
EOF
|
|
|
|
# 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
|
2022-06-24 21:55:08 -04:00
|
|
|
wrapProgram "$bin" --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}" \
|
2022-11-29 01:16:44 -05:00
|
|
|
--prefix PATH : ${
|
|
|
|
lib.makeBinPath [ pkgs.util-linux ]
|
|
|
|
}
|
2022-06-14 00:55:47 -04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
preFixup = ''
|
|
|
|
find "$out" -name libfontmanager.so -exec \
|
|
|
|
patchelf --add-needed libfontconfig.so {} \;
|
|
|
|
'';
|
|
|
|
};
|
2022-11-29 01:16:44 -05:00
|
|
|
in with import nixpkgs { system = system; }; {
|
|
|
|
packages.temurin =
|
|
|
|
(builtins.mapAttrs (name: value: buildAdoptLike name value)
|
|
|
|
sources.${system}.temurin.versions) // {
|
|
|
|
latest = buildAdoptLike "latest" sources.${system}.temurin.latest;
|
|
|
|
stable = buildAdoptLike "stable" sources.${system}.temurin.stable;
|
|
|
|
lts = buildAdoptLike "lts" sources.${system}.temurin.lts;
|
|
|
|
};
|
2022-06-14 00:55:47 -04:00
|
|
|
|
2022-06-14 00:02:15 -04:00
|
|
|
packages.temurin-latest = self.packages.${system}.temurin.latest;
|
|
|
|
packages.temurin-stable = self.packages.${system}.temurin.stable;
|
|
|
|
packages.temurin-lts = self.packages.${system}.temurin.lts;
|
2022-06-14 00:55:47 -04:00
|
|
|
|
2022-11-29 01:16:44 -05:00
|
|
|
packages.semeru =
|
|
|
|
(builtins.mapAttrs (name: value: buildAdoptLike name value)
|
|
|
|
sources.${system}.semeru.versions) // {
|
|
|
|
latest = buildAdoptLike "latest" sources.${system}.semeru.latest;
|
|
|
|
stable = buildAdoptLike "stable" sources.${system}.semeru.stable;
|
|
|
|
lts = buildAdoptLike "lts" sources.${system}.semeru.lts;
|
|
|
|
};
|
2022-06-14 00:55:47 -04:00
|
|
|
|
|
|
|
packages.semeru-latest = self.packages.${system}.semeru.latest;
|
|
|
|
packages.semeru-stable = self.packages.${system}.semeru.stable;
|
|
|
|
packages.semeru-lts = self.packages.${system}.semeru.lts;
|
|
|
|
|
2023-05-15 17:14:09 -04:00
|
|
|
defaultPackage = self.packages.${system}.temurin.stable;
|
2021-12-23 13:11:49 -05:00
|
|
|
});
|
|
|
|
}
|