diff --git a/pkgs/applications/misc/prusa-slicer/default.nix b/pkgs/applications/misc/prusa-slicer/default.nix index 830601e189cf..6309889d9d91 100644 --- a/pkgs/applications/misc/prusa-slicer/default.nix +++ b/pkgs/applications/misc/prusa-slicer/default.nix @@ -145,14 +145,17 @@ stdenv.mkDerivation (finalAttrs: { doInstallCheck = true; - # The build system uses custom logic - defined in - # cmake/modules/FindNLopt.cmake in the package source - for finding the nlopt - # library, which doesn't pick up the package in the nix store. We - # additionally need to set the path via the NLOPT environment variable. - NLOPT = nlopt; - - # prusa-slicer uses dlopen on `libudev.so` at runtime - NIX_LDFLAGS = lib.optionalString withSystemd "-ludev"; + env = { + # The build system uses custom logic - defined in + # cmake/modules/FindNLopt.cmake in the package source - for finding the nlopt + # library, which doesn't pick up the package in the nix store. We + # additionally need to set the path via the NLOPT environment variable. + NLOPT = nlopt; + } + // lib.optionalAttrs withSystemd { + # prusa-slicer uses dlopen on `libudev.so` at runtime + NIX_LDFLAGS = "-ludev"; + }; prePatch = '' # Since version 2.5.0 of nlopt we need to link to libnlopt, as libnlopt_cxx diff --git a/pkgs/applications/version-management/svn-all-fast-export/default.nix b/pkgs/applications/version-management/svn-all-fast-export/default.nix index d62d83c117ab..71b450f442bb 100644 --- a/pkgs/applications/version-management/svn-all-fast-export/default.nix +++ b/pkgs/applications/version-management/svn-all-fast-export/default.nix @@ -39,7 +39,7 @@ stdenv.mkDerivation { "SVN_INCLUDE=${subversion.dev}/include/subversion-1" ]; - NIX_LDFLAGS = "-lsvn_fs-1"; + env.NIX_LDFLAGS = "-lsvn_fs-1"; dontWrapQtApps = true; diff --git a/pkgs/by-name/pa/pax/package.nix b/pkgs/by-name/pa/pax/package.nix index bf38bcd5c4b6..b63849172338 100644 --- a/pkgs/by-name/pa/pax/package.nix +++ b/pkgs/by-name/pa/pax/package.nix @@ -16,7 +16,9 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = lib.optional stdenv.hostPlatform.isMusl musl-fts; - NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-lfts"; + env = lib.optionalAttrs stdenv.hostPlatform.isMusl { + NIX_LDFLAGS = "-lfts"; + }; buildPhase = '' sh Build.sh -r -tpax diff --git a/pkgs/by-name/ph/phash/package.nix b/pkgs/by-name/ph/phash/package.nix index 656a89b2e832..3e9e961d2941 100644 --- a/pkgs/by-name/ph/phash/package.nix +++ b/pkgs/by-name/ph/phash/package.nix @@ -34,7 +34,7 @@ stdenv.mkDerivation (finalAttrs: { sha256 = "sha256-frISiZ89ei7XfI5F2nJJehfQZsk0Mlb4n91q/AiZ2vA="; }; - NIX_LDFLAGS = "-lfftw3_threads"; + env.NIX_LDFLAGS = "-lfftw3_threads"; patches = [ # proper pthread return value (https://github.com/clearscene/pHash/pull/20) diff --git a/pkgs/by-name/ph/phodav/package.nix b/pkgs/by-name/ph/phodav/package.nix index a5bb57ae66d0..c965f5856213 100644 --- a/pkgs/by-name/ph/phodav/package.nix +++ b/pkgs/by-name/ph/phodav/package.nix @@ -45,7 +45,9 @@ stdenv.mkDerivation rec { "-Dudevrulesdir=${placeholder "out"}/lib/udev/rules.d" ]; - NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-lintl"; + env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { + NIX_LDFLAGS = "-lintl"; + }; doInstallCheck = true; diff --git a/pkgs/by-name/pk/pktgen/package.nix b/pkgs/by-name/pk/pktgen/package.nix index bfb3aa43a347..2c7cf0cc9f32 100644 --- a/pkgs/by-name/pk/pktgen/package.nix +++ b/pkgs/by-name/pk/pktgen/package.nix @@ -45,15 +45,16 @@ stdenv.mkDerivation (finalAttrs: { gtk2 ]; - RTE_SDK = dpdk; - GUI = lib.optionalString withGtk "true"; + env = { + RTE_SDK = dpdk; + GUI = lib.optionalString withGtk "true"; - env.NIX_CFLAGS_COMPILE = toString [ - "-Wno-error=sign-compare" - ]; - - # requires symbols from this file - NIX_LDFLAGS = "-lrte_net_bond"; + NIX_CFLAGS_COMPILE = toString [ + "-Wno-error=sign-compare" + ]; + # requires symbols from this file + NIX_LDFLAGS = "-lrte_net_bond"; + }; postPatch = '' substituteInPlace lib/common/lscpu.h --replace /usr/bin/lscpu ${util-linux}/bin/lscpu diff --git a/pkgs/by-name/pl/plugdata/package.nix b/pkgs/by-name/pl/plugdata/package.nix index 66d9c571e179..d64452d3c066 100644 --- a/pkgs/by-name/pl/plugdata/package.nix +++ b/pkgs/by-name/pl/plugdata/package.nix @@ -92,18 +92,16 @@ stdenv.mkDerivation (finalAttrs: { }) ]; - NIX_LDFLAGS = ( - toString [ - "-lX11" - "-lXext" - "-lXcomposite" - "-lXcursor" - "-lXinerama" - "-lXrandr" - "-lXtst" - "-lXdmcp" - ] - ); + env.NIX_LDFLAGS = toString [ + "-lX11" + "-lXext" + "-lXcomposite" + "-lXcursor" + "-lXinerama" + "-lXrandr" + "-lXtst" + "-lXdmcp" + ]; patches = [ # fiddle~.c prevents building with gcc15. Upstream puredata has fixed this issue, diff --git a/pkgs/by-name/po/postfix/package.nix b/pkgs/by-name/po/postfix/package.nix index 8cbd827770bc..0989e9622ef7 100644 --- a/pkgs/by-name/po/postfix/package.nix +++ b/pkgs/by-name/po/postfix/package.nix @@ -147,7 +147,9 @@ stdenv.mkDerivation (finalAttrs: { enableParallelBuilding = true; - NIX_LDFLAGS = lib.optionalString withLDAP "-llber"; + env = lib.optionalAttrs withLDAP { + NIX_LDFLAGS = "-llber"; + }; installTargets = [ "non-interactive-package" ]; diff --git a/pkgs/by-name/pp/ppp/package.nix b/pkgs/by-name/pp/ppp/package.nix index a4c577d4c015..547c7ee8f7dd 100644 --- a/pkgs/by-name/pp/ppp/package.nix +++ b/pkgs/by-name/pp/ppp/package.nix @@ -73,7 +73,7 @@ stdenv.mkDerivation (finalAttrs: { "CC=${stdenv.cc.targetPrefix}cc" ]; - NIX_LDFLAGS = "-lcrypt"; + env.NIX_LDFLAGS = "-lcrypt"; installFlags = [ "sysconfdir=$(out)/etc" diff --git a/pkgs/by-name/qt/qtgreet/package.nix b/pkgs/by-name/qt/qtgreet/package.nix index 508e4a5f4d23..497777b37023 100644 --- a/pkgs/by-name/qt/qtgreet/package.nix +++ b/pkgs/by-name/qt/qtgreet/package.nix @@ -47,7 +47,7 @@ stdenv.mkDerivation (finalAttrs: { (lib.mesonOption "dynpath" "${placeholder "out"}/var/lib/qtgreet") ]; - NIX_LDFLAGS = "-lwayqt-utils-qt6"; + env.NIX_LDFLAGS = "-lwayqt-utils-qt6"; meta = { description = "Qt based greeter for greetd, to be run under wayfire or similar wlr-based compositors"; diff --git a/pkgs/by-name/ri/ripplerx/package.nix b/pkgs/by-name/ri/ripplerx/package.nix index 670b2cff797d..edbc55fd9a41 100644 --- a/pkgs/by-name/ri/ripplerx/package.nix +++ b/pkgs/by-name/ri/ripplerx/package.nix @@ -52,28 +52,30 @@ stdenv.mkDerivation (finalAttrs: { libXrandr ]; - # JUCE dlopens these at runtime, standalone executable crashes without them - NIX_LDFLAGS = [ - "-lX11" - "-lXext" - "-lXcursor" - "-lXinerama" - "-lXrandr" - ]; + env = { + # JUCE dlopens these at runtime, standalone executable crashes without them + NIX_LDFLAGS = toString [ + "-lX11" + "-lXext" + "-lXcursor" + "-lXinerama" + "-lXrandr" + ]; - env.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" - ]; + 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" + ]; - # Fontconfig error: Cannot load default config file: No such file: (null) - env.FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf"; + # Fontconfig error: Cannot load default config file: No such file: (null) + FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf"; + }; installPhase = '' runHook preInstall diff --git a/pkgs/by-name/sc/scorched3d/package.nix b/pkgs/by-name/sc/scorched3d/package.nix index 0df07831a439..8d781d15d676 100644 --- a/pkgs/by-name/sc/scorched3d/package.nix +++ b/pkgs/by-name/sc/scorched3d/package.nix @@ -65,7 +65,7 @@ stdenv.mkDerivation (finalAttrs: { configureFlags = [ "--with-fftw=${fftwSinglePrec.dev}" ]; - NIX_LDFLAGS = "-lopenal"; + env.NIX_LDFLAGS = "-lopenal"; meta = { homepage = "http://scorched3d.co.uk/"; diff --git a/pkgs/by-name/si/siege/package.nix b/pkgs/by-name/si/siege/package.nix index c3e5901b6477..0e074b880f96 100644 --- a/pkgs/by-name/si/siege/package.nix +++ b/pkgs/by-name/si/siege/package.nix @@ -15,9 +15,14 @@ stdenv.mkDerivation rec { hash = "sha256-7BQM7dFZl5OD1g2+h6AVHCwSraeHkQlaj6hK5jW5MCY="; }; - NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isLinux [ - "-lgcc_s" - ]; + env = + lib.optionalAttrs stdenv.hostPlatform.isLinux { + NIX_LDFLAGS = toString [ "-lgcc_s" ]; + } + // lib.optionalAttrs stdenv.cc.isClang { + # Borrowed solution from homebrew: https://github.com/Homebrew/homebrew-core/blob/1c7c95183c0984a84b1680422afab6578c300a27/Formula/s/siege.rb#L31 + CFLAGS = "-Wno-int-conversion"; + }; buildInputs = [ openssl @@ -33,9 +38,6 @@ stdenv.mkDerivation rec { "--with-zlib=${zlib.dev}" ]; - # Borrowed solution from homebrew: https://github.com/Homebrew/homebrew-core/blob/1c7c95183c0984a84b1680422afab6578c300a27/Formula/s/siege.rb#L31 - CFLAGS = lib.optionalString stdenv.cc.isClang "-Wno-int-conversion"; - meta = { description = "HTTP load tester"; homepage = "https://www.joedog.org/siege-home/"; diff --git a/pkgs/by-name/si/siesta/package.nix b/pkgs/by-name/si/siesta/package.nix index 36a6c07e3b82..7c6dd18d31c0 100644 --- a/pkgs/by-name/si/siesta/package.nix +++ b/pkgs/by-name/si/siesta/package.nix @@ -51,7 +51,7 @@ stdenv.mkDerivation (finalAttrs: { scalapack ]; - NIX_LDFLAGS = "-lm"; + env.NIX_LDFLAGS = "-lm"; cmakeFlags = [ "-DCMAKE_POLICY_VERSION_MINIMUM=3.5" diff --git a/pkgs/by-name/si/silver-searcher/package.nix b/pkgs/by-name/si/silver-searcher/package.nix index 87151fd393e2..6015d39697c6 100644 --- a/pkgs/by-name/si/silver-searcher/package.nix +++ b/pkgs/by-name/si/silver-searcher/package.nix @@ -22,13 +22,17 @@ stdenv.mkDerivation (finalAttrs: { patches = [ ./bash-completion.patch ]; - # Workaround build failure on -fno-common toolchains like upstream - # gcc-10. Otherwise build fails as: - # ld: src/zfile.o:/build/source/src/log.h:12: multiple definition of - # `print_mtx'; src/ignore.o:/build/source/src/log.h:12: first defined here - # TODO: remove once next release has https://github.com/ggreer/the_silver_searcher/pull/1377 - env.NIX_CFLAGS_COMPILE = "-fcommon"; - NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isLinux "-lgcc_s"; + env = { + # Workaround build failure on -fno-common toolchains like upstream + # gcc-10. Otherwise build fails as: + # ld: src/zfile.o:/build/source/src/log.h:12: multiple definition of + # `print_mtx'; src/ignore.o:/build/source/src/log.h:12: first defined here + # TODO: remove once next release has https://github.com/ggreer/the_silver_searcher/pull/1377 + NIX_CFLAGS_COMPILE = "-fcommon"; + } + // lib.optionalAttrs stdenv.hostPlatform.isLinux { + NIX_LDFLAGS = "-lgcc_s"; + }; nativeBuildInputs = [ autoreconfHook diff --git a/pkgs/by-name/sm/smpeg/package.nix b/pkgs/by-name/sm/smpeg/package.nix index c25a0c09ad77..53b2612f4e46 100644 --- a/pkgs/by-name/sm/smpeg/package.nix +++ b/pkgs/by-name/sm/smpeg/package.nix @@ -93,7 +93,9 @@ stdenv.mkDerivation (finalAttrs: { --prefix PKG_CONFIG_PATH ":" "${lib.getDev SDL}/lib/pkgconfig" ''; - NIX_LDFLAGS = lib.optionalString (!stdenv.hostPlatform.isDarwin) "-lX11"; + env = lib.optionalAttrs (!stdenv.hostPlatform.isDarwin) { + NIX_LDFLAGS = "-lX11"; + }; meta = { homepage = "https://icculus.org/smpeg/"; diff --git a/pkgs/by-name/so/socalabs-papu/package.nix b/pkgs/by-name/so/socalabs-papu/package.nix index 31632fc4ee2c..70ca9f7137e3 100644 --- a/pkgs/by-name/so/socalabs-papu/package.nix +++ b/pkgs/by-name/so/socalabs-papu/package.nix @@ -120,18 +120,16 @@ stdenv.mkDerivation (finalAttrs: { passthru.updateScript = nix-update-script { }; - NIX_LDFLAGS = ( - toString [ - "-lX11" - "-lXext" - "-lXcomposite" - "-lXcursor" - "-lXinerama" - "-lXrandr" - "-lXtst" - "-lXdmcp" - ] - ); + env.NIX_LDFLAGS = toString [ + "-lX11" + "-lXext" + "-lXcomposite" + "-lXcursor" + "-lXinerama" + "-lXrandr" + "-lXtst" + "-lXdmcp" + ]; meta = { description = "Socalabs Nintendo Gameboy PAPU Emulation Plugin"; diff --git a/pkgs/by-name/so/socalabs-rp2a03/package.nix b/pkgs/by-name/so/socalabs-rp2a03/package.nix index 64b38d9c86f0..7bee247d80ac 100644 --- a/pkgs/by-name/so/socalabs-rp2a03/package.nix +++ b/pkgs/by-name/so/socalabs-rp2a03/package.nix @@ -117,18 +117,16 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstall ''; - NIX_LDFLAGS = ( - toString [ - "-lX11" - "-lXext" - "-lXcomposite" - "-lXcursor" - "-lXinerama" - "-lXrandr" - "-lXtst" - "-lXdmcp" - ] - ); + env.NIX_LDFLAGS = toString [ + "-lX11" + "-lXext" + "-lXcomposite" + "-lXcursor" + "-lXinerama" + "-lXrandr" + "-lXtst" + "-lXdmcp" + ]; meta = { description = "Socalabs NES Ricoh 2A03 Emulation Plugin"; diff --git a/pkgs/by-name/so/socalabs-sid/package.nix b/pkgs/by-name/so/socalabs-sid/package.nix index bc9a6d7dcdaf..792b529a75b4 100644 --- a/pkgs/by-name/so/socalabs-sid/package.nix +++ b/pkgs/by-name/so/socalabs-sid/package.nix @@ -152,18 +152,16 @@ stdenv.mkDerivation { runHook postInstall ''; - NIX_LDFLAGS = ( - toString [ - "-lX11" - "-lXext" - "-lXcomposite" - "-lXcursor" - "-lXinerama" - "-lXrandr" - "-lXtst" - "-lXdmcp" - ] - ); + env.NIX_LDFLAGS = toString [ + "-lX11" + "-lXext" + "-lXcomposite" + "-lXcursor" + "-lXinerama" + "-lXrandr" + "-lXtst" + "-lXdmcp" + ]; meta = { description = "Socalabs Commodore 64 SID Emulation Plugin"; diff --git a/pkgs/by-name/so/socalabs-sn76489/package.nix b/pkgs/by-name/so/socalabs-sn76489/package.nix index aaf32ae6a205..a54c6b796bc2 100644 --- a/pkgs/by-name/so/socalabs-sn76489/package.nix +++ b/pkgs/by-name/so/socalabs-sn76489/package.nix @@ -127,18 +127,16 @@ stdenv.mkDerivation { runHook postInstall ''; - NIX_LDFLAGS = ( - toString [ - "-lX11" - "-lXext" - "-lXcomposite" - "-lXcursor" - "-lXinerama" - "-lXrandr" - "-lXtst" - "-lXdmcp" - ] - ); + env.NIX_LDFLAGS = toString [ + "-lX11" + "-lXext" + "-lXcomposite" + "-lXcursor" + "-lXinerama" + "-lXrandr" + "-lXtst" + "-lXdmcp" + ]; passthru.updateScript = nix-update-script { }; diff --git a/pkgs/by-name/so/socalabs-voc/package.nix b/pkgs/by-name/so/socalabs-voc/package.nix index 3de5e6148c9c..3be3fdd55677 100644 --- a/pkgs/by-name/so/socalabs-voc/package.nix +++ b/pkgs/by-name/so/socalabs-voc/package.nix @@ -130,18 +130,16 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstall ''; - NIX_LDFLAGS = ( - toString [ - "-lX11" - "-lXext" - "-lXcomposite" - "-lXcursor" - "-lXinerama" - "-lXrandr" - "-lXtst" - "-lXdmcp" - ] - ); + env.NIX_LDFLAGS = toString [ + "-lX11" + "-lXext" + "-lXcomposite" + "-lXcursor" + "-lXinerama" + "-lXrandr" + "-lXtst" + "-lXdmcp" + ]; passthru.updateScript = nix-update-script { }; diff --git a/pkgs/by-name/su/surge-XT/package.nix b/pkgs/by-name/su/surge-XT/package.nix index 82ec458255eb..daee093f35c0 100644 --- a/pkgs/by-name/su/surge-XT/package.nix +++ b/pkgs/by-name/su/surge-XT/package.nix @@ -77,15 +77,13 @@ stdenv.mkDerivation (finalAttrs: { ]; # JUCE dlopen's these at runtime, crashes without them - NIX_LDFLAGS = ( - toString [ - "-lX11" - "-lXext" - "-lXcursor" - "-lXinerama" - "-lXrandr" - ] - ); + env.NIX_LDFLAGS = toString [ + "-lX11" + "-lXext" + "-lXcursor" + "-lXinerama" + "-lXrandr" + ]; passthru = { rev-prefix = "release_xt_"; diff --git a/pkgs/by-name/sv/svnfs/package.nix b/pkgs/by-name/sv/svnfs/package.nix index 2c07913c63d2..d955b25b5a41 100644 --- a/pkgs/by-name/sv/svnfs/package.nix +++ b/pkgs/by-name/sv/svnfs/package.nix @@ -41,12 +41,20 @@ stdenv.mkDerivation (finalAttrs: { export LD_LIBRARY_PATH=${subversion.out}/lib ''; - # -fcommon: workaround build failure on -fno-common toolchains like upstream - # gcc-10. Otherwise build fails as: - # ld: svnclient.o:/build/svnfs-0.4/src/svnfs.h:40: multiple definition of - # `dirbuf'; svnfs.o:/build/svnfs-0.4/src/svnfs.h:40: first defined here - env.NIX_CFLAGS_COMPILE = "-I ${subversion.dev}/include/subversion-1 -fcommon"; - NIX_LDFLAGS = "-lsvn_client-1 -lsvn_subr-1"; + env = { + # -fcommon: workaround build failure on -fno-common toolchains like upstream + # gcc-10. Otherwise build fails as: + # ld: svnclient.o:/build/svnfs-0.4/src/svnfs.h:40: multiple definition of + # `dirbuf'; svnfs.o:/build/svnfs-0.4/src/svnfs.h:40: first defined here + NIX_CFLAGS_COMPILE = toString [ + "-I ${subversion.dev}/include/subversion-1" + "-fcommon" + ]; + NIX_LDFLAGS = toString [ + "-lsvn_client-1" + "-lsvn_subr-1" + ]; + }; meta = { description = "FUSE filesystem for accessing Subversion repositories"; diff --git a/pkgs/by-name/sy/sylpheed/package.nix b/pkgs/by-name/sy/sylpheed/package.nix index f6149e7e9b6f..f30cee26dba6 100644 --- a/pkgs/by-name/sy/sylpheed/package.nix +++ b/pkgs/by-name/sy/sylpheed/package.nix @@ -54,7 +54,9 @@ stdenv.mkDerivation rec { configureFlags = lib.optional gpgSupport "--enable-gpgme" ++ lib.optional sslSupport "--enable-ssl"; # Undefined symbols for architecture arm64: "_OBJC_CLASS_$_NSAutoreleasePool" - NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-framework Foundation"; + env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { + NIX_LDFLAGS = "-framework Foundation"; + }; meta = { homepage = "https://sylpheed.sraoss.jp/en/";