treewide: use lib.optionalAttrs

This commit is contained in:
Felix Buehler 2023-02-14 20:50:47 +01:00
parent de272e4bcd
commit 099935b624
4 changed files with 18 additions and 19 deletions

View File

@ -5,7 +5,7 @@ with pkgs;
rec { rec {
sourceTarball = args: import ./source-tarball.nix ( sourceTarball = args: import ./source-tarball.nix (
{ inherit stdenv autoconf automake libtool; { inherit lib stdenv autoconf automake libtool;
} // args); } // args);
makeSourceTarball = sourceTarball; # compatibility makeSourceTarball = sourceTarball; # compatibility

View File

@ -154,8 +154,8 @@ stdenv.mkDerivation (
// //
(if buildOutOfSourceTree (lib.optionalAttrs buildOutOfSourceTree
then { {
preConfigure = preConfigure =
# Build out of source tree and make the source tree read-only. This # Build out of source tree and make the source tree read-only. This
# helps catch violations of the GNU Coding Standards (info # helps catch violations of the GNU Coding Standards (info
@ -170,5 +170,5 @@ stdenv.mkDerivation (
${lib.optionalString (preConfigure != null) preConfigure} ${lib.optionalString (preConfigure != null) preConfigure}
''; '';
} }
else {}) )
) )

View File

@ -10,7 +10,7 @@
if officialRelease if officialRelease
then "" then ""
else "pre${toString (src.rev or src.revCount or "")}" else "pre${toString (src.rev or src.revCount or "")}"
, src, stdenv, autoconf, automake, libtool , src, lib, stdenv, autoconf, automake, libtool
, # By default, provide all the GNU Build System as input. , # By default, provide all the GNU Build System as input.
bootstrapBuildInputs ? [ autoconf automake libtool ] bootstrapBuildInputs ? [ autoconf automake libtool ]
, ... } @ args: , ... } @ args:
@ -73,7 +73,7 @@ stdenv.mkDerivation (
} }
# Then, the caller-supplied attributes. # Then, the caller-supplied attributes.
// args // // (builtins.removeAttrs args [ "lib" ]) //
# And finally, our own stuff. # And finally, our own stuff.
{ {
@ -117,7 +117,7 @@ stdenv.mkDerivation (
version = version + versionSuffix; version = version + versionSuffix;
}; };
meta = (if args ? meta then args.meta else {}) // { meta = (lib.optionalAttrs (args ? meta) args.meta) // {
description = "Source distribution"; description = "Source distribution";
# Tarball builds are generally important, so give them a high # Tarball builds are generally important, so give them a high

View File

@ -15545,7 +15545,7 @@ with pkgs;
profiledCompiler = false; profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "4.8" else { }; threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "4.8");
isl = if !stdenv.isDarwin then isl_0_14 else null; isl = if !stdenv.isDarwin then isl_0_14 else null;
cloog = if !stdenv.isDarwin then cloog else null; cloog = if !stdenv.isDarwin then cloog else null;
@ -15559,7 +15559,7 @@ with pkgs;
profiledCompiler = false; profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "4.9" else { }; threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "4.9");
isl = if !stdenv.isDarwin then isl_0_11 else null; isl = if !stdenv.isDarwin then isl_0_11 else null;
@ -15576,7 +15576,7 @@ with pkgs;
profiledCompiler = false; profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "6" else { }; threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "6");
# gcc 10 is too strict to cross compile gcc <= 8 # gcc 10 is too strict to cross compile gcc <= 8
stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv;
@ -15595,7 +15595,7 @@ with pkgs;
profiledCompiler = false; profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "7" else { }; threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "7");
# gcc 10 is too strict to cross compile gcc <= 8 # gcc 10 is too strict to cross compile gcc <= 8
stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv;
@ -15610,7 +15610,7 @@ with pkgs;
profiledCompiler = false; profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "8" else { }; threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "8");
# gcc 10 is too strict to cross compile gcc <= 8 # gcc 10 is too strict to cross compile gcc <= 8
stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv; stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv;
@ -15625,7 +15625,7 @@ with pkgs;
profiledCompiler = false; profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "9" else { }; threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "9");
isl = if !stdenv.isDarwin then isl_0_20 else null; isl = if !stdenv.isDarwin then isl_0_20 else null;
})); }));
@ -15637,7 +15637,7 @@ with pkgs;
profiledCompiler = false; profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "10" else { }; threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "10");
isl = if !stdenv.isDarwin then isl_0_20 else null; isl = if !stdenv.isDarwin then isl_0_20 else null;
})); }));
@ -15649,7 +15649,7 @@ with pkgs;
profiledCompiler = false; profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "11" else { }; threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "11");
isl = if !stdenv.isDarwin then isl_0_20 else null; isl = if !stdenv.isDarwin then isl_0_20 else null;
})); }));
@ -15661,7 +15661,7 @@ with pkgs;
profiledCompiler = false; profiledCompiler = false;
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCrossFor "12" else { }; threadsCross = lib.optionalAttrs (stdenv.targetPlatform != stdenv.buildPlatform) (threadsCrossFor "12");
isl = if !stdenv.isDarwin then isl_0_20 else null; isl = if !stdenv.isDarwin then isl_0_20 else null;
})); }));
@ -21340,8 +21340,7 @@ with pkgs;
threadsCross = threadsCrossFor null; threadsCross = threadsCrossFor null;
threadsCrossFor = cc_version: threadsCrossFor = cc_version:
if stdenv.targetPlatform.isMinGW && !(stdenv.targetPlatform.useLLVM or false) lib.optionalAttrs (stdenv.targetPlatform.isMinGW && !(stdenv.targetPlatform.useLLVM or false)) {
then {
# other possible values: win32 or posix # other possible values: win32 or posix
model = "mcf"; model = "mcf";
# For win32 or posix set this to null # For win32 or posix set this to null
@ -21349,7 +21348,7 @@ with pkgs;
if cc_version == null || lib.versionAtLeast cc_version "13" if cc_version == null || lib.versionAtLeast cc_version "13"
then targetPackages.windows.mcfgthreads or windows.mcfgthreads then targetPackages.windows.mcfgthreads or windows.mcfgthreads
else targetPackages.windows.mcfgthreads_pre_gcc_13 or windows.mcfgthreads_pre_gcc_13; else targetPackages.windows.mcfgthreads_pre_gcc_13 or windows.mcfgthreads_pre_gcc_13;
} else { }; };
wasilibc = callPackage ../development/libraries/wasilibc { wasilibc = callPackage ../development/libraries/wasilibc {
stdenv = crossLibcStdenv; stdenv = crossLibcStdenv;