Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions pkgs/development/compilers/openjdk/14.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
{ stdenv, lib, fetchurl, bash, pkgconfig, autoconf, cpio, file, which, unzip
, zip, perl, cups, freetype, alsaLib, libjpeg, giflib, libpng, zlib, lcms2
, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama
, libXcursor, libXrandr, fontconfig, openjdk14-bootstrap
, setJavaClassPath
, headless ? false
, enableJavaFX ? openjfx.meta.available, openjfx
, enableGnome2 ? true, gtk3, gnome_vfs, glib, GConf
}:

let
major = "14";
update = ".0.2";
build = "-ga";

openjdk = stdenv.mkDerivation rec {
pname = "openjdk" + lib.optionalString headless "-headless";
version = "${major}${update}${build}";

src = fetchurl {
url = "http://hg.openjdk.java.net/jdk-updates/jdk${major}u/archive/jdk-${version}.tar.gz";
sha256 = "1s1pc6ihzf0awp4hbaqfxmbica0hnrg8nr7s0yd2hfn7nan8xmf3";
};

nativeBuildInputs = [ pkgconfig autoconf ];
buildInputs = [
cpio file which unzip zip perl zlib cups freetype alsaLib libjpeg giflib
libpng zlib lcms2 libX11 libICE libXrender libXext libXtst libXt libXtst
libXi libXinerama libXcursor libXrandr fontconfig openjdk14-bootstrap
] ++ lib.optionals (!headless && enableGnome2) [
gtk3 gnome_vfs GConf glib
];

patches = [
./fix-java-home-jdk10.patch
./read-truststore-from-env-jdk10.patch
./currency-date-range-jdk10.patch
./increase-javadoc-heap-jdk13.patch
# -Wformat etc. are stricter in newer gccs, per
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79677
# so grab the work-around from
# https://src.fedoraproject.org/rpms/java-openjdk/pull-request/24
(fetchurl {
url = "https://src.fedoraproject.org/rpms/java-openjdk/raw/06c001c7d87f2e9fe4fedeef2d993bcd5d7afa2a/f/rh1673833-remove_removal_of_wformat_during_test_compilation.patch";
sha256 = "082lmc30x64x583vqq00c8y0wqih3y4r0mp1c4bqq36l22qv6b6r";
})
] ++ lib.optionals (!headless && enableGnome2) [
./swing-use-gtk-jdk13.patch
];

prePatch = ''
chmod +x configure
patchShebangs --build configure
'';

configureFlags = [
"--with-boot-jdk=${openjdk14-bootstrap.home}"
"--enable-unlimited-crypto"
"--with-native-debug-symbols=internal"
"--with-libjpeg=system"
"--with-giflib=system"
"--with-libpng=system"
"--with-zlib=system"
"--with-lcms=system"
"--with-stdc++lib=dynamic"
] ++ lib.optional stdenv.isx86_64 "--with-jvm-features=zgc"
++ lib.optional headless "--enable-headless-only"
++ lib.optional (!headless && enableJavaFX) "--with-import-modules=${openjfx}";

separateDebugInfo = true;

NIX_CFLAGS_COMPILE = "-Wno-error";

NIX_LDFLAGS = toString (lib.optionals (!headless) [
"-lfontconfig" "-lcups" "-lXinerama" "-lXrandr" "-lmagic"
] ++ lib.optionals (!headless && enableGnome2) [
"-lgtk-3" "-lgio-2.0" "-lgnomevfs-2" "-lgconf-2"
]);

buildFlags = [ "all" ];

installPhase = ''
mkdir -p $out/lib

mv build/*/images/jdk $out/lib/openjdk

# Remove some broken manpages.
rm -rf $out/lib/openjdk/man/ja*

# Mirror some stuff in top-level.
mkdir -p $out/share
ln -s $out/lib/openjdk/include $out/include
ln -s $out/lib/openjdk/man $out/share/man
ln -s $out/lib/openjdk/lib/src.zip $out/lib/src.zip

# jni.h expects jni_md.h to be in the header search path.
ln -s $out/include/linux/*_md.h $out/include/

# Remove crap from the installation.
rm -rf $out/lib/openjdk/demo
${lib.optionalString headless ''
rm $out/lib/openjdk/lib/{libjsound,libfontmanager}.so
''}

ln -s $out/lib/openjdk/bin $out/bin
'';

preFixup = ''
# Propagate the setJavaClassPath setup hook so that any package
# that depends on the JDK has $CLASSPATH set up properly.
mkdir -p $out/nix-support
#TODO or printWords? cf https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040
echo -n "${setJavaClassPath}" > $out/nix-support/propagated-build-inputs

# Set JAVA_HOME automatically.
mkdir -p $out/nix-support
cat <<EOF > $out/nix-support/setup-hook
if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out/lib/openjdk; fi
EOF
'';

postFixup = ''
# Build the set of output library directories to rpath against
LIBDIRS=""
for output in $outputs; do
if [ "$output" = debug ]; then continue; fi
LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort | uniq | tr '\n' ':'):$LIBDIRS"
done
# Add the local library paths to remove dependencies on the bootstrap
for output in $outputs; do
if [ "$output" = debug ]; then continue; fi
OUTPUTDIR=$(eval echo \$$output)
BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*)
echo "$BINLIBS" | while read i; do
patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true
patchelf --shrink-rpath "$i" || true
done
done
'';

disallowedReferences = [ openjdk14-bootstrap ];

meta = with stdenv.lib; {
homepage = "http://openjdk.java.net/";
license = licenses.gpl2;
description = "The open-source Java Development Kit";
maintainers = with maintainers; [ edwtjo ];
platforms = [ "i686-linux" "x86_64-linux" "aarch64-linux" "armv7l-linux" "armv6l-linux" ];
};

passthru = {
architecture = "";
home = "${openjdk}/lib/openjdk";
};
};
in openjdk
16 changes: 8 additions & 8 deletions pkgs/development/compilers/openjdk/default.nix
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{ stdenv, lib, fetchurl, bash, pkgconfig, autoconf, cpio, file, which, unzip
, zip, perl, cups, freetype, alsaLib, libjpeg, giflib, libpng, zlib, lcms2
, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama
, libXcursor, libXrandr, fontconfig, openjdk14-bootstrap
, libXcursor, libXrandr, fontconfig, openjdk15-bootstrap
, setJavaClassPath
, headless ? false
, enableJavaFX ? openjfx.meta.available, openjfx
, enableGnome2 ? true, gtk3, gnome_vfs, glib, GConf
}:

let
major = "14";
update = ".0.2";
major = "15";
update = "";
build = "-ga";

openjdk = stdenv.mkDerivation rec {
pname = "openjdk" + lib.optionalString headless "-headless";
version = "${major}${update}${build}";

src = fetchurl {
url = "http://hg.openjdk.java.net/jdk-updates/jdk${major}u/archive/jdk-${version}.tar.gz";
sha256 = "1s1pc6ihzf0awp4hbaqfxmbica0hnrg8nr7s0yd2hfn7nan8xmf3";
url = "https://hg.openjdk.java.net/jdk-updates/jdk${major}u/archive/jdk-${version}.tar.gz";
sha256 = "0dh1cx525f15h415vvnybnynnlps2w7yyws9dc7q7vygznw2v45j";
};

nativeBuildInputs = [ pkgconfig autoconf ];
buildInputs = [
cpio file which unzip zip perl zlib cups freetype alsaLib libjpeg giflib
libpng zlib lcms2 libX11 libICE libXrender libXext libXtst libXt libXtst
libXi libXinerama libXcursor libXrandr fontconfig openjdk14-bootstrap
libXi libXinerama libXcursor libXrandr fontconfig openjdk15-bootstrap
] ++ lib.optionals (!headless && enableGnome2) [
gtk3 gnome_vfs GConf glib
];
Expand Down Expand Up @@ -54,7 +54,7 @@ let
'';

configureFlags = [
"--with-boot-jdk=${openjdk14-bootstrap.home}"
"--with-boot-jdk=${openjdk15-bootstrap.home}"
"--enable-unlimited-crypto"
"--with-native-debug-symbols=internal"
"--with-libjpeg=system"
Expand Down Expand Up @@ -138,7 +138,7 @@ let
done
'';

disallowedReferences = [ openjdk14-bootstrap ];
disallowedReferences = [ openjdk15-bootstrap ];

meta = with stdenv.lib; {
homepage = "http://openjdk.java.net/";
Expand Down
116 changes: 116 additions & 0 deletions pkgs/development/compilers/openjdk/openjfx/15.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{ stdenv, lib, fetchFromGitHub, writeText, openjdk11_headless, gradleGen
, pkgconfig, perl, cmake, gperf, gtk2, gtk3, libXtst, libXxf86vm, glib, alsaLib
, ffmpeg_3, python, ruby }:

let
major = "15";
update = "9";
repover = "${major}+${update}";
gradle_ = (gradleGen.override {
java = openjdk11_headless;
}).gradle_5_6;

makePackage = args: stdenv.mkDerivation ({
version = "${major}+${update}";

src = fetchFromGitHub {
owner = "openjdk";
repo = "jfx";
rev = repover;
sha256 = "1f4pghgw9axqjswz3fh01p1h7wkg6n9vvzyk4ic7xbnqnzxgnnrj";
};

buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsaLib ffmpeg_3 ];
nativeBuildInputs = [ gradle_ perl pkgconfig cmake gperf python ruby ];

dontUseCmakeConfigure = true;

config = writeText "gradle.properties" (''
CONF = Release
JDK_HOME = ${openjdk11_headless.home}
'' + args.gradleProperties or "");

#avoids errors about deprecation of GTypeDebugFlags, GTimeVal, etc.
NIX_CFLAGS_COMPILE = [ "-DGLIB_DISABLE_DEPRECATION_WARNINGS" ];

buildPhase = ''
runHook preBuild

export GRADLE_USER_HOME=$(mktemp -d)
ln -s $config gradle.properties
export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE"
gradle --no-daemon $gradleFlags sdk

runHook postBuild
'';
} // args);

# Fake build to pre-download deps into fixed-output derivation.
# We run nearly full build because I see no other way to download everything that's needed.
# Anyone who knows a better way?
deps = makePackage {
pname = "openjfx-deps";

# perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
installPhase = ''
find $GRADLE_USER_HOME -type f -regex '.*/modules.*\.\(jar\|pom\)' \
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
| sh
rm -rf $out/tmp
'';

outputHashAlgo = "sha256";
outputHashMode = "recursive";
# Downloaded AWT jars differ by platform.
outputHash = {
x86_64-linux = "0hmyr5nnjgwyw3fcwqf0crqg9lny27jfirycg3xmkzbcrwqd6qkw";
# The build-time dependencies don't currently build for i686, so no
# reason to fetch this one correctly either...
i686-linux = "0000000000000000000000000000000000000000000000000000";
}.${stdenv.system} or (throw "Unsupported platform");
};

in makePackage {
pname = "openjfx-modular-sdk";

gradleProperties = ''
COMPILE_MEDIA = true
COMPILE_WEBKIT = true
'';

preBuild = ''
swtJar="$(find ${deps} -name org.eclipse.swt\*.jar)"
substituteInPlace build.gradle \
--replace 'mavenCentral()' 'mavenLocal(); maven { url uri("${deps}") }' \
--replace 'name: SWT_FILE_NAME' "files('$swtJar')"
'';

installPhase = ''
cp -r build/modular-sdk $out
'';

# glib-2.62 deprecations
NIX_CFLAGS_COMPILE = "-DGLIB_DISABLE_DEPRECATION_WARNINGS";

stripDebugList = [ "." ];

postFixup = ''
# Remove references to bootstrap.
find "$out" -name \*.so | while read lib; do
new_refs="$(patchelf --print-rpath "$lib" | sed -E 's,:?${lib.escape ["+"] openjdk11_headless.outPath}[^:]*,,')"
patchelf --set-rpath "$new_refs" "$lib"
done
'';

disallowedReferences = [ openjdk11_headless ];

passthru.deps = deps;

meta = with stdenv.lib; {
homepage = "http://openjdk.java.net/projects/openjfx/";
license = licenses.gpl2;
description = "The next-generation Java client toolkit.";
maintainers = with maintainers; [ abbradar ];
platforms = [ "i686-linux" "x86_64-linux" ];
};
}
17 changes: 15 additions & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9420,6 +9420,8 @@ in

openjfx14 = callPackage ../development/compilers/openjdk/openjfx/14.nix { };

openjfx15 = callPackage ../development/compilers/openjdk/openjfx/15.nix { };

openjdk8-bootstrap =
if adoptopenjdk-hotspot-bin-8.meta.available then
adoptopenjdk-hotspot-bin-8
Expand Down Expand Up @@ -9486,15 +9488,16 @@ in
};
};

openjdk15-bootstrap = openjdk14;

jdk11 = openjdk11;
jdk11_headless = openjdk11_headless;

/* Latest JDK */
openjdk14 =
if stdenv.isDarwin then
callPackage ../development/compilers/openjdk/darwin { }
else
callPackage ../development/compilers/openjdk {
callPackage ../development/compilers/openjdk/14.nix {
openjfx = openjfx14;
inherit (gnome2) GConf gnome_vfs;
};
Expand All @@ -9508,6 +9511,16 @@ in
jdk14 = openjdk14;
jdk14_headless = openjdk14_headless;

/* Latest JDK */
openjdk15 =
callPackage ../development/compilers/openjdk {
openjfx = openjfx15;
inherit (gnome2) GConf gnome_vfs;
};

jdk15 = openjdk15;


/* default JDK */

jdk = jdk14;
Expand Down