From 3c083ef2ee3ceb78bb38daebb17d87419710a365 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Tue, 15 Oct 2024 21:50:53 +0100 Subject: [PATCH] dmenu: fix build on `staging-next` Without the change `dmenu` fails to build on `staging-next` as: $ nix build --no-link -f. dmenu -L ... dmenu> build flags: SHELL=/nix/store/mm0pa3z7kk6jh1i9rkxqxjqmd8h1qpxf-bash-5.2p37/bin/bash CC:=\$\(CC\) dmenu> cp config.def.h config.h dmenu> gcc -c -std=c99 -pedantic -Wall -Os -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"5.3\" -DXINERAMA dmenu.c dmenu> In file included from dmenu.c:17: dmenu> /nix/store/2rxphcg0qabc3a8c4lvy610sm03bh72y-libXft-2.3.8-dev/include/X11/Xft/Xft.h:40:10: fatal error: ft2build.h: No such file or directory dmenu> 40 | #include dmenu> | ^~~~~~~~~~~~ dmenu> compilation terminated. dmenu> make: *** [Makefile:12: dmenu.o] Error 1 The change uses `pkg-config` to discover library dependencies and lib paths. --- pkgs/applications/misc/dmenu/default.nix | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/misc/dmenu/default.nix b/pkgs/applications/misc/dmenu/default.nix index 089a421ccc15..75ae73179cf3 100644 --- a/pkgs/applications/misc/dmenu/default.nix +++ b/pkgs/applications/misc/dmenu/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, libX11, libXinerama, libXft, zlib, writeText +{ lib, stdenv, fetchurl, fontconfig, libX11, libXinerama, libXft, pkg-config, zlib, writeText , conf ? null, patches ? null # update script dependencies , gitUpdater }: @@ -12,7 +12,8 @@ stdenv.mkDerivation rec { sha256 = "sha256-Go9T5v0tdJg57IcMXiez4U2lw+6sv8uUXRWeHVQzeV8="; }; - buildInputs = [ libX11 libXinerama zlib libXft ]; + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ fontconfig libX11 libXinerama zlib libXft ]; inherit patches; @@ -28,11 +29,15 @@ stdenv.mkDerivation rec { ''; preConfigure = '' - sed -i "s@PREFIX = /usr/local@PREFIX = $out@g" config.mk + makeFlagsArray+=( + PREFIX="$out" + CC="$CC" + # default config.mk hardcodes dependent libraries and include paths + INCS="`$PKG_CONFIG --cflags fontconfig x11 xft xinerama`" + LIBS="`$PKG_CONFIG --libs fontconfig x11 xft xinerama`" + ) ''; - makeFlags = [ "CC:=$(CC)" ]; - passthru.updateScript = gitUpdater { url = "git://git.suckless.org/dmenu"; }; meta = with lib; {