diff --git a/pkgs/applications/terminal-emulators/rxvt-unicode/default.nix b/pkgs/applications/terminal-emulators/rxvt-unicode/default.nix index 7d0be835b33b..dada6d1e8545 100644 --- a/pkgs/applications/terminal-emulators/rxvt-unicode/default.nix +++ b/pkgs/applications/terminal-emulators/rxvt-unicode/default.nix @@ -135,12 +135,16 @@ stdenv.mkDerivation { ] ++ lib.optional emojiSupport "--enable-wide-glyphs"; - LDFLAGS = [ - "-lfontconfig" - "-lXrender" - "-lpthread" - ]; - CFLAGS = [ "-I${freetype.dev}/include/freetype2" ]; + env = { + LDFLAGS = toString [ + "-lfontconfig" + "-lXrender" + "-lpthread" + ]; + CFLAGS = toString [ + "-I${freetype.dev}/include/freetype2" + ]; + }; preConfigure = '' # without this the terminfo won't be compiled by tic, see man tic diff --git a/pkgs/by-name/gi/gifsicle/package.nix b/pkgs/by-name/gi/gifsicle/package.nix index 7290e8f086eb..17149ea57fd5 100644 --- a/pkgs/by-name/gi/gifsicle/package.nix +++ b/pkgs/by-name/gi/gifsicle/package.nix @@ -26,7 +26,7 @@ stdenv.mkDerivation rec { configureFlags = lib.optional (!gifview) "--disable-gifview"; - LDFLAGS = lib.optionalString static "-static"; + env.LDFLAGS = lib.optionalString static "-static"; doCheck = true; checkPhase = '' diff --git a/pkgs/by-name/if/iftop/package.nix b/pkgs/by-name/if/iftop/package.nix index c795c91f6ca4..c6ffaabd4ac0 100644 --- a/pkgs/by-name/if/iftop/package.nix +++ b/pkgs/by-name/if/iftop/package.nix @@ -26,7 +26,7 @@ stdenv.mkDerivation rec { # Explicitly link against libgcc_s, to work around the infamous # "libgcc_s.so.1 must be installed for pthread_cancel to work". - LDFLAGS = lib.optionalString stdenv.hostPlatform.isLinux "-lgcc_s"; + env.LDFLAGS = lib.optionalString stdenv.hostPlatform.isLinux "-lgcc_s"; buildInputs = [ ncurses diff --git a/pkgs/by-name/lc/lcms2/package.nix b/pkgs/by-name/lc/lcms2/package.nix index 89b0d2434e4c..bdb1ba358a73 100644 --- a/pkgs/by-name/lc/lcms2/package.nix +++ b/pkgs/by-name/lc/lcms2/package.nix @@ -29,7 +29,7 @@ stdenv.mkDerivation rec { ]; # See https://trac.macports.org/ticket/60656 - LDFLAGS = if stdenv.hostPlatform.isDarwin then "-Wl,-w" else null; + env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { LDFLAGS = "-Wl,-w"; }; meta = { description = "Color management engine"; diff --git a/pkgs/by-name/li/libax25/package.nix b/pkgs/by-name/li/libax25/package.nix index 0248e8f70d79..c15baf540496 100644 --- a/pkgs/by-name/li/libax25/package.nix +++ b/pkgs/by-name/li/libax25/package.nix @@ -29,10 +29,12 @@ stdenv.mkDerivation (finalAttrs: { configureFlags = [ "--sysconfdir=/etc" ]; - LDFLAGS = lib.optionals stdenv.hostPlatform.isStatic [ - "-static-libgcc" - "-static" - ]; + env = lib.optionalAttrs stdenv.hostPlatform.isStatic { + LDFLAGS = toString [ + "-static-libgcc" + "-static" + ]; + }; meta = { description = "AX.25 library for hamradio applications"; diff --git a/pkgs/by-name/sp/spral/package.nix b/pkgs/by-name/sp/spral/package.nix index e8f7a940e61c..bbe93f52aec5 100644 --- a/pkgs/by-name/sp/spral/package.nix +++ b/pkgs/by-name/sp/spral/package.nix @@ -67,7 +67,9 @@ stdenv.mkDerivation (finalAttrs: { mesonFlags = [ (lib.mesonBool "tests" true) ]; - LDFLAGS = lib.optionals stdenv.hostPlatform.isDarwin [ "-lomp" ]; + env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { + LDFLAGS = "-lomp"; + }; doCheck = true; diff --git a/pkgs/development/compilers/llvm/common/lld/default.nix b/pkgs/development/compilers/llvm/common/lld/default.nix index b9c9152ec98d..1940724ff1d7 100644 --- a/pkgs/development/compilers/llvm/common/lld/default.nix +++ b/pkgs/development/compilers/llvm/common/lld/default.nix @@ -64,7 +64,9 @@ stdenv.mkDerivation (finalAttrs: { ++ devExtraCmakeFlags; # Musl's default stack size is too small for lld to be able to link Firefox. - LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-Wl,-z,stack-size=2097152"; + env = lib.optionalAttrs stdenv.hostPlatform.isMusl { + LDFLAGS = "-Wl,-z,stack-size=2097152"; + }; outputs = [ "out" diff --git a/pkgs/development/compilers/llvm/common/llvm/default.nix b/pkgs/development/compilers/llvm/common/llvm/default.nix index 00171a97068e..2ad683977328 100644 --- a/pkgs/development/compilers/llvm/common/llvm/default.nix +++ b/pkgs/development/compilers/llvm/common/llvm/default.nix @@ -453,9 +453,9 @@ stdenv.mkDerivation ( ''; # E.g. Mesa uses the build-id as a cache key (see #93946): - LDFLAGS = optionalString ( - enableSharedLibraries && !stdenv.hostPlatform.isDarwin - ) "-Wl,--build-id=sha1"; + env = lib.optionalAttrs (enableSharedLibraries && !stdenv.hostPlatform.isDarwin) { + LDFLAGS = "-Wl,--build-id=sha1"; + }; cmakeBuildType = "Release"; diff --git a/pkgs/development/interpreters/guile/2.0.nix b/pkgs/development/interpreters/guile/2.0.nix index ef473214c324..9d207f70c0c7 100644 --- a/pkgs/development/interpreters/guile/2.0.nix +++ b/pkgs/development/interpreters/guile/2.0.nix @@ -90,14 +90,6 @@ builder rec { }) ]; - # Explicitly link against libgcc_s, to work around the infamous - # "libgcc_s.so.1 must be installed for pthread_cancel to work". - - # don't have "libgcc_s.so.1" on darwin - LDFLAGS = lib.optionalString ( - !stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isMusl - ) "-lgcc_s"; - configureFlags = [ "--with-libreadline-prefix" ] @@ -118,6 +110,12 @@ builder rec { env = { NIX_CFLAGS_COMPILE = "-std=gnu17"; + } + // lib.optionalAttrs (!stdenv.hostPlatform.isDarwin && !stdenv.hostPlatform.isMusl) { + # Explicitly link against libgcc_s, to work around the infamous + # "libgcc_s.so.1 must be installed for pthread_cancel to work". + # don't have "libgcc_s.so.1" on darwin + LDFLAGS = "-lgcc_s"; }; postInstall = '' diff --git a/pkgs/development/interpreters/guile/2.2.nix b/pkgs/development/interpreters/guile/2.2.nix index 146b29407b30..c48fa78594bd 100644 --- a/pkgs/development/interpreters/guile/2.2.nix +++ b/pkgs/development/interpreters/guile/2.2.nix @@ -85,7 +85,9 @@ builder rec { # "libgcc_s.so.1 must be installed for pthread_cancel to work". # don't have "libgcc_s.so.1" on clang - LDFLAGS = lib.optionalString (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) "-lgcc_s"; + env = lib.optionalAttrs (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) { + LDFLAGS = "-lgcc_s"; + }; configureFlags = [ "--with-libreadline-prefix=${lib.getDev readline}" diff --git a/pkgs/development/interpreters/guile/3.0.nix b/pkgs/development/interpreters/guile/3.0.nix index b0ff7ae3af26..d400a4059cec 100644 --- a/pkgs/development/interpreters/guile/3.0.nix +++ b/pkgs/development/interpreters/guile/3.0.nix @@ -100,11 +100,16 @@ builder rec { sha256 = "12wvwdna9j8795x59ldryv9d84c1j3qdk2iskw09306idfsis207"; }); - # Explicitly link against libgcc_s, to work around the infamous - # "libgcc_s.so.1 must be installed for pthread_cancel to work". - - # don't have "libgcc_s.so.1" on clang - LDFLAGS = lib.optionalString (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) "-lgcc_s"; + env = { + # Fix build with gcc15 + NIX_CFLAGS_COMPILE = toString [ "-std=gnu17" ]; + } + // lib.optionalAttrs (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) { + # Explicitly link against libgcc_s, to work around the infamous + # "libgcc_s.so.1 must be installed for pthread_cancel to work". + # don't have "libgcc_s.so.1" on clang + LDFLAGS = "-lgcc_s"; + }; configureFlags = [ "--with-libreadline-prefix=${lib.getDev readline}" @@ -126,9 +131,6 @@ builder rec { # https://github.com/NixOS/nixpkgs/pull/160051#issuecomment-1046193028 ++ lib.optional (stdenv.hostPlatform.isDarwin) "--disable-lto"; - # Fix build with gcc15 - env.NIX_CFLAGS_COMPILE = toString [ "-std=gnu17" ]; - postInstall = '' wrapProgram $out/bin/guile-snarf --prefix PATH : "${gawk}/bin" '' diff --git a/pkgs/development/libraries/gettext/default.nix b/pkgs/development/libraries/gettext/default.nix index 20edb670b8a0..3f0f44a189fc 100644 --- a/pkgs/development/libraries/gettext/default.nix +++ b/pkgs/development/libraries/gettext/default.nix @@ -35,8 +35,6 @@ stdenv.mkDerivation rec { "info" ]; - LDFLAGS = lib.optionalString stdenv.hostPlatform.isSunOS "-lm -lmd -lmp -luutil -lnvpair -lnsl -lidmap -lavl -lsec"; - configureFlags = [ "--disable-csharp" ] @@ -102,6 +100,9 @@ stdenv.mkDerivation rec { # https://github.com/Homebrew/homebrew-core/pull/199639 # https://savannah.gnu.org/bugs/index.php?66541 am_cv_func_iconv_works = "yes"; + } + // lib.optionalAttrs stdenv.hostPlatform.isSunOS { + LDFLAGS = "-lm -lmd -lmp -luutil -lnvpair -lnsl -lidmap -lavl -lsec"; }; enableParallelBuilding = true; diff --git a/pkgs/development/python-modules/google-crc32c/default.nix b/pkgs/development/python-modules/google-crc32c/default.nix index 282cb7d325c6..64e2b4bdfae2 100644 --- a/pkgs/development/python-modules/google-crc32c/default.nix +++ b/pkgs/development/python-modules/google-crc32c/default.nix @@ -29,8 +29,10 @@ buildPythonPackage rec { dependencies = [ cffi ]; - LDFLAGS = "-L${crc32c}/lib"; - CFLAGS = "-I${crc32c}/include"; + env = { + LDFLAGS = "-L${crc32c}/lib"; + CFLAGS = "-I${crc32c}/include"; + }; nativeCheckInputs = [ pytestCheckHook diff --git a/pkgs/development/rocm-modules/6/migraphx/default.nix b/pkgs/development/rocm-modules/6/migraphx/default.nix index 723e987c829b..84e70a9bf406 100644 --- a/pkgs/development/rocm-modules/6/migraphx/default.nix +++ b/pkgs/development/rocm-modules/6/migraphx/default.nix @@ -119,7 +119,7 @@ stdenv.mkDerivation (finalAttrs: { python3Packages.onnx ]; - LDFLAGS = "-Wl,--allow-shlib-undefined"; + env.LDFLAGS = "-Wl,--allow-shlib-undefined"; cmakeFlags = [ "-DMIGRAPHX_ENABLE_GPU=ON"