From 77f2cc5791904caf4077c526fbdaca4ad27e2374 Mon Sep 17 00:00:00 2001 From: Seth Flynn Date: Thu, 6 Mar 2025 03:00:58 -0500 Subject: apply build system patches This is a more upstreamable approach, and doesn't require any kind of weird substitution on our end. It also avoids downloading Kotlin in our antDeps and fixes cross compilation!! (only tested on aarch64) Signed-off-by: Seth Flynn --- lwjgl.nix | 4 +- pkgs/fetch-ant-deps.nix | 3 +- ...ild-use-pkg-config-for-linux-dependencies.patch | 81 ++++++++++++++++++++++ pkgs/lwjgl/0002-build-allow-local-kotlin.patch | 50 +++++++++++++ ...build-allow-linking-against-system-libffi.patch | 38 ++++++++++ ...ild-add-dbus-as-dependency-for-nfd_portal.patch | 50 +++++++++++++ ...ld-allow-setting-pkg-config-prefix-suffix.patch | 64 +++++++++++++++++ pkgs/lwjgl/default.nix | 80 ++++++++++----------- pkgs/lwjgl/fix-library-paths.patch | 36 ---------- 9 files changed, 322 insertions(+), 84 deletions(-) create mode 100644 pkgs/lwjgl/0001-build-use-pkg-config-for-linux-dependencies.patch create mode 100644 pkgs/lwjgl/0002-build-allow-local-kotlin.patch create mode 100644 pkgs/lwjgl/0003-build-allow-linking-against-system-libffi.patch create mode 100644 pkgs/lwjgl/0004-build-add-dbus-as-dependency-for-nfd_portal.patch create mode 100644 pkgs/lwjgl/0005-build-allow-setting-pkg-config-prefix-suffix.patch delete mode 100644 pkgs/lwjgl/fix-library-paths.patch diff --git a/lwjgl.nix b/lwjgl.nix index f860abb..1d633d7 100644 --- a/lwjgl.nix +++ b/lwjgl.nix @@ -13,12 +13,12 @@ versions = { "3.3.4" = { hash = "sha256-U0pPeTqVoruqqhhMrBrczy0qt83a8atr8DyRcGgX/yI="; - antHash = "sha256-7jVlKBia8dJGuBjNwaljHBrXUep9KjOHHyZESayFnhs="; + antHash = "sha256-BE2sSPgYELCkww8aJV5DYTgHy4LT14RTVh6gRXA64+Q="; }; "3.3.6" = { hash = "sha256-iXwsTo394uoq8/jIlfNuQlXW1lnuge+5/+00O4UdvyA="; - antHash = "sha256-XNJpu6nS7gloQuKJadaUHeW0N9EpFKmJEib6/I2exVE="; + antHash = "sha256-n2ON2eMBWZbu4A2yPBR4wN17dpWkBrf+1nq2l4uK3yk="; }; }; }; diff --git a/pkgs/fetch-ant-deps.nix b/pkgs/fetch-ant-deps.nix index 69e29b4..a63f76e 100644 --- a/pkgs/fetch-ant-deps.nix +++ b/pkgs/fetch-ant-deps.nix @@ -32,7 +32,8 @@ lib.makeOverridable ( buildPhase = '' runHook preBuild - ant init + concatTo flagsArray buildFlags buildFlagsArray antFlags antFlagsArray + ant init "''${flagsArray[@]}" runHook postBuild ''; diff --git a/pkgs/lwjgl/0001-build-use-pkg-config-for-linux-dependencies.patch b/pkgs/lwjgl/0001-build-use-pkg-config-for-linux-dependencies.patch new file mode 100644 index 0000000..38c3878 --- /dev/null +++ b/pkgs/lwjgl/0001-build-use-pkg-config-for-linux-dependencies.patch @@ -0,0 +1,81 @@ +From cee6a98721d8417802fcd394df0215312be9a7ea Mon Sep 17 00:00:00 2001 +From: Seth Flynn +Date: Wed, 5 Mar 2025 16:20:59 -0500 +Subject: [PATCH 1/5] build: use pkg-config for linux dependencies + +Adapted from https://cgit.freebsd.org/ports/commit/?id=680dc7bb031d0f708c2dd38f055ec8d63ee68b8a +--- + config/linux/build.xml | 37 ++++++++++++++++++++++--------------- + 1 file changed, 22 insertions(+), 15 deletions(-) + +diff --git a/config/linux/build.xml b/config/linux/build.xml +index a1798b6aa..11e4743ab 100644 +--- a/config/linux/build.xml ++++ b/config/linux/build.xml +@@ -281,16 +281,17 @@ + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ + +- +- +- +- +- +- +- +- +- ++ + + + +@@ -299,16 +300,22 @@ + + + +- +- +- +- ++ + + + + ++ ++ ++ ++ ++ ++ ++ ++ ++ + +- ++ + + + +@@ -317,7 +324,7 @@ + + + +- ++ + + + +-- +2.48.1 + diff --git a/pkgs/lwjgl/0002-build-allow-local-kotlin.patch b/pkgs/lwjgl/0002-build-allow-local-kotlin.patch new file mode 100644 index 0000000..7b7a4a2 --- /dev/null +++ b/pkgs/lwjgl/0002-build-allow-local-kotlin.patch @@ -0,0 +1,50 @@ +From 05573f96ed4b73591679bdf2c17a83f57acfd171 Mon Sep 17 00:00:00 2001 +From: Seth Flynn +Date: Wed, 5 Mar 2025 16:34:50 -0500 +Subject: [PATCH 2/5] build: allow local kotlin + +Adapted from https://cgit.freebsd.org/ports/commit/?id=680dc7bb031d0f708c2dd38f055ec8d63ee68b8a +--- + config/build-definitions.xml | 3 ++- + update-dependencies.xml | 4 ++-- + 2 files changed, 4 insertions(+), 3 deletions(-) + +diff --git a/config/build-definitions.xml b/config/build-definitions.xml +index 407195ff7..4026a057c 100644 +--- a/config/build-definitions.xml ++++ b/config/build-definitions.xml +@@ -121,7 +121,8 @@ This script is included in /build.xml and /config/update-dependencies.xml. + + + +- ++ ++ + + + +diff --git a/update-dependencies.xml b/update-dependencies.xml +index 98fd77b19..39501492a 100644 +--- a/update-dependencies.xml ++++ b/update-dependencies.xml +@@ -27,7 +27,7 @@ + + + +- ++ + + + +@@ -54,7 +54,7 @@ + + + +- ++ + + + +-- +2.48.1 + diff --git a/pkgs/lwjgl/0003-build-allow-linking-against-system-libffi.patch b/pkgs/lwjgl/0003-build-allow-linking-against-system-libffi.patch new file mode 100644 index 0000000..e212bfa --- /dev/null +++ b/pkgs/lwjgl/0003-build-allow-linking-against-system-libffi.patch @@ -0,0 +1,38 @@ +From f79338f70f72e5d4606b8d99c2f49f85b486be3e Mon Sep 17 00:00:00 2001 +From: Seth Flynn +Date: Wed, 5 Mar 2025 16:43:57 -0500 +Subject: [PATCH 3/5] build: allow linking against system libffi + +Adapted from https://cgit.freebsd.org/ports/commit/?id=680dc7bb031d0f708c2dd38f055ec8d63ee68b8a +--- + config/linux/build.xml | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/config/linux/build.xml b/config/linux/build.xml +index 11e4743ab..4500d23c0 100644 +--- a/config/linux/build.xml ++++ b/config/linux/build.xml +@@ -194,16 +194,18 @@ + + + +- ++ + + + + + +- ++ + + + ++ ++ + + + +-- +2.48.1 + diff --git a/pkgs/lwjgl/0004-build-add-dbus-as-dependency-for-nfd_portal.patch b/pkgs/lwjgl/0004-build-add-dbus-as-dependency-for-nfd_portal.patch new file mode 100644 index 0000000..0f6eb87 --- /dev/null +++ b/pkgs/lwjgl/0004-build-add-dbus-as-dependency-for-nfd_portal.patch @@ -0,0 +1,50 @@ +From 3aa1fc52ef6a72c99f1224e4c8ba2aedeb515277 Mon Sep 17 00:00:00 2001 +From: Seth Flynn +Date: Wed, 5 Mar 2025 17:10:20 -0500 +Subject: [PATCH 4/5] build: add dbus as dependency for nfd_portal + +--- + config/linux/build.xml | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/config/linux/build.xml b/config/linux/build.xml +index 4500d23c0..829ce2b1d 100644 +--- a/config/linux/build.xml ++++ b/config/linux/build.xml +@@ -307,9 +307,17 @@ + + + ++ ++ + + + ++ ++ ++ ++ ++ ++ + + + +@@ -317,6 +325,7 @@ + + + ++ + + + +@@ -326,6 +335,7 @@ + + + ++ + + + +-- +2.48.1 + diff --git a/pkgs/lwjgl/0005-build-allow-setting-pkg-config-prefix-suffix.patch b/pkgs/lwjgl/0005-build-allow-setting-pkg-config-prefix-suffix.patch new file mode 100644 index 0000000..ff39bec --- /dev/null +++ b/pkgs/lwjgl/0005-build-allow-setting-pkg-config-prefix-suffix.patch @@ -0,0 +1,64 @@ +From 57db58f899e99bc37cbc98b6403ab9aa2f04862f Mon Sep 17 00:00:00 2001 +From: Seth Flynn +Date: Thu, 6 Mar 2025 02:31:35 -0500 +Subject: [PATCH 5/5] build: allow setting pkg-config prefix & suffix + +--- + config/linux/build.xml | 19 +++++++++++++------ + 1 file changed, 13 insertions(+), 6 deletions(-) + +diff --git a/config/linux/build.xml b/config/linux/build.xml +index 829ce2b1d..0c0700fb9 100644 +--- a/config/linux/build.xml ++++ b/config/linux/build.xml +@@ -18,6 +18,13 @@ + + + ++ ++ ++ ++ ++ ++ ++ + + + +@@ -286,10 +293,10 @@ + + + +- ++ + + +- ++ + + + +@@ -312,16 +319,16 @@ + + + +- ++ + + +- ++ + + +- ++ + + +- ++ + + + +-- +2.48.1 + diff --git a/pkgs/lwjgl/default.nix b/pkgs/lwjgl/default.nix index 546c45c..bebd70a 100644 --- a/pkgs/lwjgl/default.nix +++ b/pkgs/lwjgl/default.nix @@ -3,22 +3,17 @@ stdenv, breakpointHook, ant, - at-spi2-atk, buildPackages, - cairo, dbus, fetchAntDeps, fetchFromGitHub, - gdk-pixbuf, glib, gtk3, - harfbuzz, kotlin, libGLU, libffi, libglvnd, - pango, - replaceVars, + pkg-config, xorg, version, @@ -38,20 +33,11 @@ stdenv.mkDerivation (finalAttrs: { }; patches = [ - (replaceVars ./fix-library-paths.patch ( - lib.mapAttrs (lib.const lib.getDev) { - inherit - at-spi2-atk - cairo - dbus - gdk-pixbuf - glib - gtk3 - harfbuzz - pango - ; - } - )) + ./0001-build-use-pkg-config-for-linux-dependencies.patch + ./0002-build-allow-local-kotlin.patch + ./0003-build-allow-linking-against-system-libffi.patch + ./0004-build-add-dbus-as-dependency-for-nfd_portal.patch + ./0005-build-allow-setting-pkg-config-prefix-suffix.patch ]; antJdk = buildPackages.jdk_headless; @@ -60,7 +46,9 @@ stdenv.mkDerivation (finalAttrs: { pname version src + patches antJdk + antFlags ; hash = antHash; }; @@ -70,32 +58,40 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ ant kotlin + pkg-config ] ++ 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 ]; + antFlags = + [ + "-Dgcc.libpath.opengl=${libglvnd}/lib" + + "-Dlibffi.path=${lib.getLib libffi}/lib" + "-Duse.libffi.so=true" + + "-Dlocal.kotlin=${lib.getBin kotlin}" + ] + ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "-Dgcc.prefix=${stdenv.cc.targetPrefix}" + "-Dpkg-config.prefix=${stdenv.cc.targetPrefix}" + ]; + 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" @@ -109,6 +105,8 @@ stdenv.mkDerivation (finalAttrs: { "riscv64" else throw "${stdenv.hostPlatform.cpu.name} is not a supported architecture"; + LWJGL_BUILD_OFFLINE = "yes"; + LWJGL_BUILD_TYPE = "release/${finalAttrs.version}"; }; # Put the dependencies we already downloaded in the right place @@ -120,29 +118,21 @@ stdenv.mkDerivation (finalAttrs: { postBuild = '' mkdir $out - ant \ - -emacs \ - -Dgcc.libpath.opengl=${libglvnd}/lib \ - compile-templates compile-native + concatTo flagsArray buildFlags buildFlagsArray antFlags antFlagsArray + ant compile-templates compile compile-native "''${flagsArray[@]}" ''; postInstall = '' - exit 1 + mkdir -p $out/lib + find . -type f -name '*.so' -exec install -Dm755 -t $out/lib {} \; ''; 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; + description = "Lightweight Java Game Library"; + homepage = "https://www.lwjgl.org/"; + changelog = "https://github.com/LWJGL/lwjgl3/releases/tag/${toString finalAttrs.src.tag}"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ getchoo ]; + platforms = lib.platforms.linux; }; }) diff --git a/pkgs/lwjgl/fix-library-paths.patch b/pkgs/lwjgl/fix-library-paths.patch deleted file mode 100644 index 0d6b332..0000000 --- a/pkgs/lwjgl/fix-library-paths.patch +++ /dev/null @@ -1,36 +0,0 @@ -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 @@ - - - -- -- -- -- -- -- -- -- -- -+ -+ -+ -+ -+ -+ -+ - - - -@@ -308,7 +306,7 @@ - - - -- -+ - - - -- cgit v1.2.3