treewide: move NIX_LDFLAGS into env for structuredAttrs (t-z) (#486082)

This commit is contained in:
Wolfgang Walther 2026-02-09 08:05:47 +00:00 committed by GitHub
commit 7fd330e907
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 154 additions and 106 deletions

View file

@ -32,9 +32,11 @@ stdenv.mkDerivation (finalAttrs: {
ncurses
];
# By no known reason libtirpc is not detected
env.NIX_CFLAGS_COMPILE = toString [ "-I${libtirpc.dev}/include/tirpc" ];
NIX_LDFLAGS = [ "-ltirpc" ];
env = {
# By no known reason libtirpc is not detected
NIX_CFLAGS_COMPILE = toString [ "-I${libtirpc.dev}/include/tirpc" ];
NIX_LDFLAGS = [ "-ltirpc" ];
};
postPatch = ''
substituteInPlace CMakeLists.txt \

View file

@ -108,18 +108,20 @@ stdenv.mkDerivation (finalAttrs: {
--prefix XDG_DATA_DIRS : "$out/share:$GSETTINGS_SCHEMAS_PATH"
'';
# Tenacity only looks for ffmpeg at runtime, so we need to link it in manually.
# On darwin, these are ignored by the ffmpeg search even when linked.
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isLinux (toString [
"-lavcodec"
"-lavdevice"
"-lavfilter"
"-lavformat"
"-lavutil"
"-lpostproc"
"-lswresample"
"-lswscale"
]);
env = lib.optionalAttrs stdenv.hostPlatform.isLinux {
# Tenacity only looks for ffmpeg at runtime, so we need to link it in manually.
# On darwin, these are ignored by the ffmpeg search even when linked.
NIX_LDFLAGS = toString [
"-lavcodec"
"-lavdevice"
"-lavfilter"
"-lavformat"
"-lavutil"
"-lpostproc"
"-lswresample"
"-lswscale"
];
};
nativeBuildInputs = [
cmake

View file

@ -33,7 +33,7 @@ stdenv.mkDerivation (finalAttrs: {
preConfigure = "./autogen.sh";
NIX_LDFLAGS = "-lm";
env.NIX_LDFLAGS = "-lm";
meta = {
description = "JACK audio recorder";

View file

@ -47,7 +47,7 @@ stdenv.mkDerivation rec {
openssl
];
NIX_LDFLAGS = ''
env.NIX_LDFLAGS = ''
-L${lib.getLib stdenv.cc.cc}/lib -lX11 -lglib-2.0 -lgtk-x11-2.0
-lgdk-x11-2.0 -lgdk_pixbuf-2.0 -lpango-1.0 -latk-1.0 -lcairo
-lc -lcrypto
@ -71,7 +71,7 @@ stdenv.mkDerivation rec {
"INSTALL_PREFIX=$(out)"
];
LCL_PLATFORM = "gtk2";
env.LCL_PLATFORM = "gtk2";
desktopItem = makeDesktopItem {
name = pname;

View file

@ -44,14 +44,16 @@ stdenv.mkDerivation {
sed -i 's|^_select(int|select(int|' trickle-overload.c
'';
NIX_LDFLAGS = [
"-levent"
"-ltirpc"
];
env.NIX_CFLAGS_COMPILE = toString [
"-I${libtirpc.dev}/include/tirpc"
"-Wno-error=incompatible-pointer-types"
];
env = {
NIX_LDFLAGS = toString [
"-levent"
"-ltirpc"
];
NIX_CFLAGS_COMPILE = toString [
"-I${libtirpc.dev}/include/tirpc"
"-Wno-error=incompatible-pointer-types"
];
};
configureFlags = [ "--with-libevent" ];

View file

@ -23,8 +23,10 @@ stdenv.mkDerivation (finalAttrs: {
pkg-config
];
# Ensure the linker is using atomic when compiling for RISC-V, otherwise fails
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isRiscV "-latomic";
env = lib.optionalAttrs stdenv.hostPlatform.isRiscV {
# Ensure the linker is using atomic when compiling for RISC-V, otherwise fails
NIX_LDFLAGS = "-latomic";
};
cmakeFlags = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
# Some x86 tests are interrupted by signal 10

View file

@ -26,8 +26,10 @@ stdenv.mkDerivation (finalAttrs: {
cctools
];
# Ensure the linker is using atomic when compiling for RISC-V, otherwise fails
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isRiscV "-latomic";
env = lib.optionalAttrs stdenv.hostPlatform.isRiscV {
# Ensure the linker is using atomic when compiling for RISC-V, otherwise fails
NIX_LDFLAGS = "-latomic";
};
cmakeFlags = lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
# Some x86 tests are interrupted by signal 10

View file

@ -125,11 +125,13 @@ stdenv.mkDerivation (finalAttrs: {
doCheck = true;
dontUseNinjaCheck = true;
NIX_LDFLAGS = lib.optionalString finalAttrs.doCheck "-rpath ${
lib.makeLibraryPath [
onetbb
]
}";
env = lib.optionalAttrs finalAttrs.doCheck {
NIX_LDFLAGS = "-rpath ${
lib.makeLibraryPath [
onetbb
]
}";
};
disabledTests = [
# These tests try to access sysfs, which is unavailable in the sandbox

View file

@ -79,7 +79,16 @@ stdenv.mkDerivation rec {
makefile = "unix/Makefile";
NIX_LDFLAGS = "-lbz2" + lib.optionalString enableNLS " -lnatspec";
env = {
NIX_LDFLAGS = toString (
[
"-lbz2"
]
++ lib.optionals enableNLS [
"-lnatspec"
]
);
};
buildFlags = [
"generic"

View file

@ -56,7 +56,14 @@ stdenv.mkDerivation (finalAttrs: {
"CC=${stdenv.cc.targetPrefix}cc"
];
NIX_LDFLAGS = "-lcrypt -lssl -lcrypto -lpam -lcap -lseccomp";
env.NIX_LDFLAGS = toString [
"-lcrypt"
"-lssl"
"-lcrypto"
"-lpam"
"-lcap"
"-lseccomp"
];
enableParallelBuilding = true;

View file

@ -22,7 +22,12 @@ rustPlatform.buildRustPackage (finalAttrs: {
nativeBuildInputs = [ installShellFiles ];
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-framework AppKit";
env = lib.optionalAttrs stdenv.hostPlatform.isDarwin {
NIX_LDFLAGS = toString [
"-framework"
"AppKit"
];
};
checkFlags = [
"--skip=help"

View file

@ -38,7 +38,7 @@ stdenv.mkDerivation {
spice-protocol
];
NIX_LDFLAGS = "-lpthread";
env.NIX_LDFLAGS = "-lpthread";
meta = {
description = "Enable a running X11 desktop to be available via a Spice server";

View file

@ -37,7 +37,9 @@ stdenv.mkDerivation (finalAttrs: {
libintl
];
NIX_LDFLAGS = if stdenv.isDarwin then "-liconv" else null;
env = lib.optionalAttrs stdenv.isDarwin {
NIX_LDFLAGS = "-liconv";
};
preFixup = ''
# fallback values need to be last

View file

@ -66,10 +66,10 @@ stdenv.mkDerivation {
'cmake_minimum_required(VERSION 3.10)'
'';
env.NIX_CFLAGS_COMPILE = lib.optionalString (
stdenv.hostPlatform.libc == "glibc"
) "-I${libtirpc.dev}/include/tirpc";
NIX_LDFLAGS = lib.optional (stdenv.hostPlatform.libc == "glibc") "-ltirpc";
env = lib.optionalAttrs (stdenv.hostPlatform.libc == "glibc") {
NIX_CFLAGS_COMPILE = "-I${libtirpc.dev}/include/tirpc";
NIX_LDFLAGS = "-ltirpc";
};
hardeningDisable = [ "format" ];

View file

@ -52,7 +52,7 @@ stdenv.mkDerivation {
nativeBuildInputs = [ fpc ];
buildInputs = [ openssl ];
NIX_LDFLAGS = [ "-lcrypto" ];
env.NIX_LDFLAGS = toString [ "-lcrypto" ];
patchPhase = ''
patchShebangs \

View file

@ -79,7 +79,7 @@ lib.fix (
configureFlags = [ "--enable-soap" ];
# otherwise libxmlsec1-gnutls.so won't find libgcrypt.so, after #909
NIX_LDFLAGS = "-lgcrypt";
env.NIX_LDFLAGS = "-lgcrypt";
postInstall = ''
moveToOutput "bin/xmlsec1-config" "$dev"

View file

@ -67,24 +67,25 @@ clangStdenv.mkDerivation (finalAttrs: {
];
# JUCE dlopen's these at runtime, crashes without them
NIX_LDFLAGS = lib.optionalString clangStdenv.hostPlatform.isLinux (toString [
"-lX11"
"-lXext"
"-lXcursor"
"-lXinerama"
"-lXrandr"
]);
env.NIX_CFLAGS_COMPILE = lib.optionalString clangStdenv.hostPlatform.isLinux (toString [
# juce, compiled in this build as part of a Git submodule, uses `-flto` as
# a Link Time Optimization flag, and instructs the plugin compiled here to
# use this flag to. This breaks the build for us. Using _fat_ LTO allows
# successful linking while still providing LTO benefits. If our build of
# `juce` was used as a dependency, we could have patched that `-flto` line
# in our juce's source, but that is not possible because it is used as a
# Git Submodule.
"-ffat-lto-objects"
]);
env = lib.optionalAttrs clangStdenv.hostPlatform.isLinux {
NIX_LDFLAGS = toString [
"-lX11"
"-lXext"
"-lXcursor"
"-lXinerama"
"-lXrandr"
];
NIX_CFLAGS_COMPILE = toString [
# juce, compiled in this build as part of a Git submodule, uses `-flto` as
# a Link Time Optimization flag, and instructs the plugin compiled here to
# use this flag to. This breaks the build for us. Using _fat_ LTO allows
# successful linking while still providing LTO benefits. If our build of
# `juce` was used as a dependency, we could have patched that `-flto` line
# in our juce's source, but that is not possible because it is used as a
# Git Submodule.
"-ffat-lto-objects"
];
};
cmakeFlags = [
# see: https://github.com/ZL-Audio/ZlEqualizer#clone-and-build

View file

@ -66,25 +66,27 @@ clangStdenv.mkDerivation (finalAttrs: {
libxkbcommon
];
# JUCE dlopen's these at runtime, crashes without them
NIX_LDFLAGS = lib.optionalString clangStdenv.hostPlatform.isLinux (toString [
"-lX11"
"-lXext"
"-lXcursor"
"-lXinerama"
"-lXrandr"
]);
env = lib.optionalAttrs clangStdenv.hostPlatform.isLinux {
# JUCE dlopen's these at runtime, crashes without them
NIX_LDFLAGS = toString [
"-lX11"
"-lXext"
"-lXcursor"
"-lXinerama"
"-lXrandr"
];
env.NIX_CFLAGS_COMPILE = lib.optionalString clangStdenv.hostPlatform.isLinux (toString [
# juce, compiled in this build as part of a Git submodule, uses `-flto` as
# a Link Time Optimization flag, and instructs the plugin compiled here to
# use this flag to. This breaks the build for us. Using _fat_ LTO allows
# successful linking while still providing LTO benefits. If our build of
# `juce` was used as a dependency, we could have patched that `-flto` line
# in our juce's source, but that is not possible because it is used as a
# Git Submodule.
"-ffat-lto-objects"
]);
NIX_CFLAGS_COMPILE = toString [
# juce, compiled in this build as part of a Git submodule, uses `-flto` as
# a Link Time Optimization flag, and instructs the plugin compiled here to
# use this flag to. This breaks the build for us. Using _fat_ LTO allows
# successful linking while still providing LTO benefits. If our build of
# `juce` was used as a dependency, we could have patched that `-flto` line
# in our juce's source, but that is not possible because it is used as a
# Git Submodule.
"-ffat-lto-objects"
];
};
cmakeFlags = [
# see: https://github.com/ZL-Audio/ZLEqualizer#clone-and-build

View file

@ -66,25 +66,26 @@ clangStdenv.mkDerivation (finalAttrs: {
libxkbcommon
];
# JUCE dlopen's these at runtime, crashes without them
NIX_LDFLAGS = lib.optionalString clangStdenv.hostPlatform.isLinux (toString [
"-lX11"
"-lXext"
"-lXcursor"
"-lXinerama"
"-lXrandr"
]);
env.NIX_CFLAGS_COMPILE = lib.optionalString clangStdenv.hostPlatform.isLinux (toString [
# juce, compiled in this build as part of a Git submodule, uses `-flto` as
# a Link Time Optimization flag, and instructs the plugin compiled here to
# use this flag to. This breaks the build for us. Using _fat_ LTO allows
# successful linking while still providing LTO benefits. If our build of
# `juce` was used as a dependency, we could have patched that `-flto` line
# in our juce's source, but that is not possible because it is used as a
# Git Submodule.
"-ffat-lto-objects"
]);
env = lib.optionalAttrs clangStdenv.hostPlatform.isLinux {
# JUCE dlopen's these at runtime, crashes without them
NIX_LDFLAGS = toString [
"-lX11"
"-lXext"
"-lXcursor"
"-lXinerama"
"-lXrandr"
];
NIX_CFLAGS_COMPILE = toString [
# juce, compiled in this build as part of a Git submodule, uses `-flto` as
# a Link Time Optimization flag, and instructs the plugin compiled here to
# use this flag to. This breaks the build for us. Using _fat_ LTO allows
# successful linking while still providing LTO benefits. If our build of
# `juce` was used as a dependency, we could have patched that `-flto` line
# in our juce's source, but that is not possible because it is used as a
# Git Submodule.
"-ffat-lto-objects"
];
};
cmakeFlags = [
# see: https://github.com/ZL-Audio/ZlEqualizer#clone-and-build

View file

@ -178,11 +178,14 @@ stdenv.mkDerivation (finalAttrs: {
# "-Duser_manual=true" # needs sphinx-intl
];
NIX_LDFLAGS = ''
-lfftw3_threads -lfftw3f_threads
'';
env = {
NIX_LDFLAGS = toString [
"-lfftw3_threads"
"-lfftw3f_threads"
];
GUILE_AUTO_COMPILE = 0;
GUILE_AUTO_COMPILE = 0;
};
dontStrip = true;

View file

@ -70,7 +70,13 @@ stdenv.mkDerivation {
];
# these libraries are only searched for at runtime so we need to force-link them
NIX_LDFLAGS = "-lgvc -lmysqlclient -lecpg -lssl -L${libmysqlclient}/lib/mariadb";
env.NIX_LDFLAGS = toString [
"-lgvc"
"-lmysqlclient"
"-lecpg"
"-lssl"
"-L${libmysqlclient}/lib/mariadb"
];
qtWrapperArgs = [
"--prefix PATH : ${lib.getBin graphviz}/bin"