treewide: use lib.optionalAttrs

+18 -19
+1 -1
pkgs/build-support/release/default.nix
··· 5 5 rec { 6 6 7 7 sourceTarball = args: import ./source-tarball.nix ( 8 - { inherit stdenv autoconf automake libtool; 8 + { inherit lib stdenv autoconf automake libtool; 9 9 } // args); 10 10 11 11 makeSourceTarball = sourceTarball; # compatibility
+3 -3
pkgs/build-support/release/nix-build.nix
··· 154 154 155 155 // 156 156 157 - (if buildOutOfSourceTree 158 - then { 157 + (lib.optionalAttrs buildOutOfSourceTree 158 + { 159 159 preConfigure = 160 160 # Build out of source tree and make the source tree read-only. This 161 161 # helps catch violations of the GNU Coding Standards (info ··· 170 170 ${lib.optionalString (preConfigure != null) preConfigure} 171 171 ''; 172 172 } 173 - else {}) 173 + ) 174 174 )
+3 -3
pkgs/build-support/release/source-tarball.nix
··· 10 10 if officialRelease 11 11 then "" 12 12 else "pre${toString (src.rev or src.revCount or "")}" 13 - , src, stdenv, autoconf, automake, libtool 13 + , src, lib, stdenv, autoconf, automake, libtool 14 14 , # By default, provide all the GNU Build System as input. 15 15 bootstrapBuildInputs ? [ autoconf automake libtool ] 16 16 , ... } @ args: ··· 73 73 } 74 74 75 75 # Then, the caller-supplied attributes. 76 - // args // 76 + // (builtins.removeAttrs args [ "lib" ]) // 77 77 78 78 # And finally, our own stuff. 79 79 { ··· 117 117 version = version + versionSuffix; 118 118 }; 119 119 120 - meta = (if args ? meta then args.meta else {}) // { 120 + meta = (lib.optionalAttrs (args ? meta) args.meta) // { 121 121 description = "Source distribution"; 122 122 123 123 # Tarball builds are generally important, so give them a high
+11 -12
pkgs/top-level/all-packages.nix
··· 15545 15545 profiledCompiler = false; 15546 15546 15547 15547 libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; 15548 - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "4.8" else { }; 15548 + threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "4.8"); 15549 15549 15550 15550 isl = if !stdenv.isDarwin then isl_0_14 else null; 15551 15551 cloog = if !stdenv.isDarwin then cloog else null; ··· 15559 15559 profiledCompiler = false; 15560 15560 15561 15561 libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; 15562 - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "4.9" else { }; 15562 + threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "4.9"); 15563 15563 15564 15564 isl = if !stdenv.isDarwin then isl_0_11 else null; 15565 15565 ··· 15576 15576 profiledCompiler = false; 15577 15577 15578 15578 libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; 15579 - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "6" else { }; 15579 + threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "6"); 15580 15580 15581 15581 # gcc 10 is too strict to cross compile gcc <= 8 15582 15582 stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; ··· 15595 15595 profiledCompiler = false; 15596 15596 15597 15597 libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; 15598 - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "7" else { }; 15598 + threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "7"); 15599 15599 15600 15600 # gcc 10 is too strict to cross compile gcc <= 8 15601 15601 stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; ··· 15610 15610 profiledCompiler = false; 15611 15611 15612 15612 libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; 15613 - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "8" else { }; 15613 + threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "8"); 15614 15614 15615 15615 # gcc 10 is too strict to cross compile gcc <= 8 15616 15616 stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; ··· 15625 15625 profiledCompiler = false; 15626 15626 15627 15627 libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; 15628 - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "9" else { }; 15628 + threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "9"); 15629 15629 15630 15630 isl = if !stdenv.isDarwin then isl_0_20 else null; 15631 15631 })); ··· 15637 15637 profiledCompiler = false; 15638 15638 15639 15639 libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; 15640 - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "10" else { }; 15640 + threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "10"); 15641 15641 15642 15642 isl = if !stdenv.isDarwin then isl_0_20 else null; 15643 15643 })); ··· 15649 15649 profiledCompiler = false; 15650 15650 15651 15651 libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; 15652 - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "11" else { }; 15652 + threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "11"); 15653 15653 15654 15654 isl = if !stdenv.isDarwin then isl_0_20 else null; 15655 15655 })); ··· 15661 15661 profiledCompiler = false; 15662 15662 15663 15663 libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; 15664 - threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "12" else { }; 15664 + threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "12"); 15665 15665 15666 15666 isl = if !stdenv.isDarwin then isl_0_20 else null; 15667 15667 })); ··· 21340 21340 21341 21341 threadsCross = threadsCrossFor null; 21342 21342 threadsCrossFor = cc_version: 21343 - if stdenv.targetPlatform.isMinGW && !(stdenv.targetPlatform.useLLVM or false) 21344 - then { 21343 + lib.optionalAttrs (stdenv.targetPlatform.isMinGW && !(stdenv.targetPlatform.useLLVM or false)) { 21345 21344 # other possible values: win32 or posix 21346 21345 model = "mcf"; 21347 21346 # For win32 or posix set this to null ··· 21349 21348 if cc_version == null || lib.versionAtLeast cc_version "13" 21350 21349 then targetPackages.windows.mcfgthreads or windows.mcfgthreads 21351 21350 else targetPackages.windows.mcfgthreads_pre_gcc_13 or windows.mcfgthreads_pre_gcc_13; 21352 - } else { }; 21351 + }; 21353 21352 21354 21353 wasilibc = callPackage ../development/libraries/wasilibc { 21355 21354 stdenv = crossLibcStdenv;