diff options
Diffstat (limited to 'pkgs/lwjgl')
| -rw-r--r-- | pkgs/lwjgl/default.nix | 148 | ||||
| -rw-r--r-- | pkgs/lwjgl/fix-library-paths.patch | 36 |
2 files changed, 184 insertions, 0 deletions
diff --git a/pkgs/lwjgl/default.nix b/pkgs/lwjgl/default.nix new file mode 100644 index 0000000..546c45c --- /dev/null +++ b/pkgs/lwjgl/default.nix @@ -0,0 +1,148 @@ +{ + lib, + stdenv, + breakpointHook, + ant, + at-spi2-atk, + buildPackages, + cairo, + dbus, + fetchAntDeps, + fetchFromGitHub, + gdk-pixbuf, + glib, + gtk3, + harfbuzz, + kotlin, + libGLU, + libffi, + libglvnd, + pango, + replaceVars, + xorg, + + version, + hash, + antHash, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "lwjgl"; + inherit version; + + src = fetchFromGitHub { + owner = "LWJGL"; + repo = "lwjgl3"; + tag = finalAttrs.version; + inherit hash; + }; + + patches = [ + (replaceVars ./fix-library-paths.patch ( + lib.mapAttrs (lib.const lib.getDev) { + inherit + at-spi2-atk + cairo + dbus + gdk-pixbuf + glib + gtk3 + harfbuzz + pango + ; + } + )) + ]; + + antJdk = buildPackages.jdk_headless; + antDeps = fetchAntDeps { + inherit (finalAttrs) + pname + version + src + antJdk + ; + hash = antHash; + }; + + strictDeps = true; + + nativeBuildInputs = [ + ant + kotlin + ] ++ lib.optional (lib.meta.availableOn stdenv.buildPlatform breakpointHook) breakpointHook; + + buildInputs = [ + at-spi2-atk + cairo + dbus + gdk-pixbuf + glib + gtk3 + harfbuzz + libGLU + libffi + pango + xorg.libX11 + xorg.libXt + ]; + + env = { + NIX_CFLAGS = "-funroll-loops -I${lib.getDev gtk3}/include/gtk-3.0"; + NIX_LDFLAGS = "-lffi"; + + JAVA_HOME = finalAttrs.antJdk.home; + JAVA8_HOME = buildPackages.jdk8_headless.home; + + # https://github.com/LWJGL/lwjgl3/tree/e8552d53624f789c8f8c3dc35976fa02cba73cff/doc#build-configuration + LWJGL_BUILD_OFFLINE = "yes"; + LWJGL_BUILD_ARCH = + if stdenv.hostPlatform.isx86_64 then + "x64" + else if stdenv.hostPlatform.isi686 then + "x86" + else if stdenv.hostPlatform.isAarch64 then + "arm64" + else if stdenv.hostPlatform.isArmv7 then + "arm32" + else if stdenv.hostPlatform.isRiscV64 then + "riscv64" + else + throw "${stdenv.hostPlatform.cpu.name} is not a supported architecture"; + }; + + # Put the dependencies we already downloaded in the right place + # NOTE: This directory *must* be writable + postConfigure = '' + mkdir bin + cp -dpr "$antDeps" ./bin/libs && chmod -R +w bin/libs + ''; + + postBuild = '' + mkdir $out + ant \ + -emacs \ + -Dgcc.libpath.opengl=${libglvnd}/lib \ + compile-templates compile-native + ''; + + postInstall = '' + exit 1 + ''; + + meta = { + platforms = + + let + architectures = lib.flatten [ + lib.platforms.x86_64 + lib.platforms.i686 + lib.platforms.aarch64 + lib.platforms.armv7 + lib.platforms.riscv64 + ]; + in + + lib.intersectLists architectures lib.platforms.linux; + }; +}) diff --git a/pkgs/lwjgl/fix-library-paths.patch b/pkgs/lwjgl/fix-library-paths.patch new file mode 100644 index 0000000..0d6b332 --- /dev/null +++ b/pkgs/lwjgl/fix-library-paths.patch @@ -0,0 +1,36 @@ +diff --git a/config/linux/build.xml b/config/linux/build.xml +index a1798b6aa..13a75815f 100644 +--- a/config/linux/build.xml ++++ b/config/linux/build.xml +@@ -282,15 +282,13 @@ + <build module="nfd" simple="true" linker="g++" if:true="${binding.nfd}"> + <beforeCompile> + <compile lang="c++"> +- <arg value="-I/usr/include/gtk-3.0"/> +- <arg value="-I/usr/include/glib-2.0"/> +- <arg value="-I/usr/include/pango-1.0"/> +- <arg value="-I/usr/include/harfbuzz"/> +- <arg value="-I/usr/include/cairo"/> +- <arg value="-I/usr/include/gdk-pixbuf-2.0"/> +- <arg value="-I/usr/include/atk-1.0"/> +- <arg value="-I/usr/lib64/glib-2.0/include"/> +- <arg value="-I/usr/lib/${linux.triplet}/glib-2.0/include"/> ++ <arg value="-I@gtk3@"/> ++ <arg value="-I@glib@"/> ++ <arg value="-I@pango@"/> ++ <arg value="-I@harfbuzz@"/> ++ <arg value="-I@cairo@"/> ++ <arg value="-I@gdk-pixbuf@"/> ++ <arg value="-I@at-spi2-atk@"/> + <arg value="-I${src.main.rel}/include"/> + <fileset dir="." includes="${src.main}/nfd_gtk.cpp"/> + </compile> +@@ -308,7 +306,7 @@ + <build module="nfd" suffix="_portal" simple="true" linker="g++" if:true="${binding.nfd}"> + <beforeCompile> + <compile lang="c++"> +- <arg line="-I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/lib/${linux.triplet}/dbus-1.0/include"/> ++ <arg line="-I@dbus@"/> + <arg value="-I${src.main.rel}/include"/> + <fileset dir="." includes="${src.main}/nfd_portal.cpp"/> + </compile> |
