From 0164b8be49743f6aded818263995f9232c7b28c5 Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Wed, 24 Dec 2025 21:07:47 +0100 Subject: [PATCH 01/11] gifsicle: move LDFLAGS into env for structuredAttrs --- pkgs/by-name/gi/gifsicle/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = '' From 7f0c9b07e9d3936834cd014671e6071a06d7a661 Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Wed, 24 Dec 2025 21:07:47 +0100 Subject: [PATCH 02/11] iftop: move LDFLAGS into env for structuredAttrs --- pkgs/by-name/if/iftop/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 28d8286a15e87fbddcd3750d038707ce4545070f Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Wed, 24 Dec 2025 21:07:48 +0100 Subject: [PATCH 03/11] lcms2: move LDFLAGS into env for structuredAttrs --- pkgs/by-name/lc/lcms2/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"; From 1557a916a6464b90d52b0fd8a2d2a3d6f15ddd18 Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Wed, 24 Dec 2025 21:07:48 +0100 Subject: [PATCH 04/11] libax25: move LDFLAGS into env for structuredAttrs --- pkgs/by-name/li/libax25/package.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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"; From 5d35cfadb132dbe9c18833beec32c1b71e76c7ac Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Wed, 24 Dec 2025 21:07:48 +0100 Subject: [PATCH 05/11] spral: move LDFLAGS into env for structuredAttrs --- pkgs/by-name/sp/spral/package.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; From c47cabffc69e13279608304a89a4ae64523422aa Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Wed, 24 Dec 2025 21:08:45 +0100 Subject: [PATCH 06/11] rocmPackages: move LDFLAGS into env for structuredAttrs --- pkgs/development/rocm-modules/6/migraphx/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 32f133b65bd1abe5c66804174f472bc3b61ed15b Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Wed, 24 Dec 2025 21:09:00 +0100 Subject: [PATCH 07/11] python3Packages.google-crc32c: move LDFLAGS into env for structuredAttrs --- pkgs/development/python-modules/google-crc32c/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 From f3ff9c641319c984ee2da292055e4b5a7fca4f7f Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Wed, 24 Dec 2025 21:09:12 +0100 Subject: [PATCH 08/11] gettext: move LDFLAGS into env for structuredAttrs --- pkgs/development/libraries/gettext/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; From 099b2748245262bf9ddf3ad702e9f27d93d4fc71 Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Wed, 24 Dec 2025 21:09:29 +0100 Subject: [PATCH 09/11] llvm: move LDFLAGS into env for structuredAttrs --- pkgs/development/compilers/llvm/common/lld/default.nix | 4 +++- pkgs/development/compilers/llvm/common/llvm/default.nix | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) 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"; From 44aa31bee707f782f3b5f63a5642129fe806a639 Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Wed, 24 Dec 2025 21:09:43 +0100 Subject: [PATCH 10/11] rxvt-unicode: move LDFLAGS into env for structuredAttrs --- .../terminal-emulators/rxvt-unicode/default.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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 From e6865860d1456943af77d65bdebbcfa7bf9a8172 Mon Sep 17 00:00:00 2001 From: Stefan Frijters Date: Wed, 24 Dec 2025 21:09:55 +0100 Subject: [PATCH 11/11] guile: move LDFLAGS into env for structuredAttrs --- pkgs/development/interpreters/guile/2.0.nix | 14 ++++++-------- pkgs/development/interpreters/guile/2.2.nix | 4 +++- pkgs/development/interpreters/guile/3.0.nix | 18 ++++++++++-------- 3 files changed, 19 insertions(+), 17 deletions(-) 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" ''