nixpkgs/pkgs/applications/misc/dmenu/default.nix
Sergei Trofimovich 3c083ef2ee 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 <ft2build.h>
    dmenu>       |          ^~~~~~~~~~~~
    dmenu> compilation terminated.
    dmenu> make: *** [Makefile:12: dmenu.o] Error 1

The change uses `pkg-config` to discover library dependencies and lib paths.
2024-10-15 21:54:10 +01:00

53 lines
1.6 KiB
Nix

{ lib, stdenv, fetchurl, fontconfig, libX11, libXinerama, libXft, pkg-config, zlib, writeText
, conf ? null, patches ? null
# update script dependencies
, gitUpdater }:
stdenv.mkDerivation rec {
pname = "dmenu";
version = "5.3";
src = fetchurl {
url = "https://dl.suckless.org/tools/dmenu-${version}.tar.gz";
sha256 = "sha256-Go9T5v0tdJg57IcMXiez4U2lw+6sv8uUXRWeHVQzeV8=";
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ fontconfig libX11 libXinerama zlib libXft ];
inherit patches;
postPatch = let
configFile = if lib.isDerivation conf || builtins.isPath conf then
conf
else
writeText "config.def.h" conf;
in ''
sed -ri -e 's!\<(dmenu|dmenu_path|stest)\>!'"$out/bin"'/&!g' dmenu_run
sed -ri -e 's!\<stest\>!'"$out/bin"'/&!g' dmenu_path
${lib.optionalString (conf != null) "cp ${configFile} config.def.h"}
'';
preConfigure = ''
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`"
)
'';
passthru.updateScript = gitUpdater { url = "git://git.suckless.org/dmenu"; };
meta = with lib; {
description =
"Generic, highly customizable, and efficient menu for the X Window System";
homepage = "https://tools.suckless.org/dmenu";
license = licenses.mit;
maintainers = with maintainers; [ pSub globin qusic _0david0mp ];
platforms = platforms.all;
mainProgram = "dmenu";
};
}