From 8fa427ef9f4f7caa3b7c9ac218e83cd0ba2cae6d Mon Sep 17 00:00:00 2001 From: midchildan Date: Fri, 13 May 2022 22:47:16 +0900 Subject: [PATCH] ncurses: make static binaries not depend on Nix store paths One of the most popular features of static binaries is portability across distros. However, static binaries built against the ncurses package are currently not portable. This is because the current ncurses package configures dependant packages to use the ncurses store path as their terminfo search path. This unfortunately makes static binaries built against ncurses not portable across NixOS systems too, as it introduces a dependency on a specific build of ncurses. To fix this problem, this change adds common paths from FHS systems and the NixOS system profile path to the default terminfo search path. --- pkgs/development/libraries/ncurses/default.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix index 2740b95986c9..ec170664fb01 100644 --- a/pkgs/development/libraries/ncurses/default.nix +++ b/pkgs/development/libraries/ncurses/default.nix @@ -43,7 +43,17 @@ stdenv.mkDerivation rec { ++ lib.optionals stdenv.hostPlatform.isWindows [ "--enable-sp-funcs" "--enable-term-driver" - ]; + ] ++ lib.optionals (stdenv.hostPlatform.isUnix && stdenv.hostPlatform.isStatic) [ + # For static binaries, the point is to have a standalone binary with + # minimum dependencies. So here we make sure that binaries using this + # package won't depend on a terminfo database located in the Nix store. + "--with-terminfo-dirs=${lib.concatStringsSep ":" [ + "/etc/terminfo" # Debian, Fedora, Gentoo + "/lib/terminfo" # Debian + "/usr/share/terminfo" # upstream default, probably all FHS-based distros + "/run/current-system/sw/share/terminfo" # NixOS + ]}" + ]; # Only the C compiler, and explicitly not C++ compiler needs this flag on solaris: CFLAGS = lib.optionalString stdenv.isSunOS "-D_XOPEN_SOURCE_EXTENDED";