1{ lib, stdenv, fetchgit, ant, jdk8, git, xorg, udev, libGL, libGLU }:
2
3{
4 jogl_2_3_2 =
5 let
6 version = "2.3.2";
7
8 gluegen-src = fetchgit {
9 url = "git://jogamp.org/srv/scm/gluegen.git";
10 rev = "v${version}";
11 sha256 = "00hybisjwqs88p24dds652bzrwbbmhn2dpx56kp4j6xpadkp33d0";
12 fetchSubmodules = true;
13 };
14 in stdenv.mkDerivation {
15 pname = "jogl";
16 inherit version;
17
18 src = fetchgit {
19 url = "git://jogamp.org/srv/scm/jogl.git";
20 rev = "v${version}";
21 sha256 = "0msi2gxiqm2yqwkmxqbh521xdrimw1fly20g890r357rcgj8fsn3";
22 fetchSubmodules = true;
23 };
24
25 postPatch = ''
26 find . -type f -name '*.java' \
27 -exec sed -i 's@"libGL.so"@"${libGL}/lib/libGL.so"@' {} \; \
28 -exec sed -i 's@"libGLU.so"@"${libGLU}/lib/libGLU.so"@' {} \;
29 '';
30
31 # TODO: upgrade to jdk https://github.com/NixOS/nixpkgs/pull/89731
32 nativeBuildInputs = [ jdk8 ant git ];
33 buildInputs = [ udev xorg.libX11 xorg.libXrandr xorg.libXcursor xorg.libXt xorg.libXxf86vm xorg.libXrender ];
34
35 # Workaround build failure on -fno-common toolchains:
36 # ld: ../obj/Bindingtest1p1Impl_JNI.o:(.bss+0x8): multiple definition of
37 # `unsigned_size_t_1'; ../obj/TK_Surface_JNI.o:(.bss+0x8): first defined here
38 NIX_CFLAGS_COMPILE = "-fcommon";
39
40 buildPhase = ''
41 cp -r ${gluegen-src} $NIX_BUILD_TOP/gluegen
42 chmod -R +w $NIX_BUILD_TOP/gluegen
43 ( cd ../gluegen/make
44 ant )
45
46 ( cd make
47
48 # force way to do disfunctional "ant -Dsetup.addNativeBroadcom=false" and disable dependency on raspberrypi drivers
49 # if arm/aarch64 support will be added, this block might be commented out on those platforms
50 # on x86 compiling with default "setup.addNativeBroadcom=true" leads to unsatisfied import "vc_dispmanx_resource_delete" in libnewt.so
51 cp build-newt.xml build-newt.xml.old
52 fgrep -v 'if="setup.addNativeBroadcom"' build-newt.xml.old > build-newt.xml
53
54 ant )
55 '';
56
57 installPhase = ''
58 mkdir -p $out/share/java
59 cp $NIX_BUILD_TOP/gluegen/build/gluegen-rt{,-natives-linux-amd64}.jar $out/share/java/
60 cp $NIX_BUILD_TOP/jogl/build/jar/jogl-all{,-natives-linux-amd64}.jar $out/share/java/
61 '';
62
63 meta = with lib; {
64 description = "Java libraries for 3D Graphics, Multimedia and Processing";
65 homepage = "https://jogamp.org/";
66 license = licenses.bsd3;
67 platforms = [ "x86_64-linux" ];
68 };
69 };
70}