treewide: use lib.optionals
This commit is contained in:
parent
3bee4ab8db
commit
bc3d5934d7
@ -25,8 +25,7 @@
|
||||
}:
|
||||
let
|
||||
mutableExtensionsFilePath = toString mutableExtensionsFile;
|
||||
mutableExtensions = if builtins.pathExists mutableExtensionsFile
|
||||
then import mutableExtensionsFilePath else [];
|
||||
mutableExtensions = lib.optionals builtins.pathExists mutableExtensionsFile (import mutableExtensionsFilePath);
|
||||
vscodeWithConfiguration = import ./vscodeWithConfiguration.nix {
|
||||
inherit lib writeShellScriptBin extensionsFromVscodeMarketplace;
|
||||
vscodeDefault = vscode;
|
||||
|
@ -49,7 +49,7 @@ stdenv.mkDerivation rec {
|
||||
buildInputs = [
|
||||
gtk3 udev desktop-file-utils shared-mime-info
|
||||
wrapGAppsHook ffmpegthumbnailer jmtpfs lsof udisks2
|
||||
] ++ (if ifuseSupport then [ ifuse ] else []);
|
||||
] ++ (lib.optionals ifuseSupport [ ifuse ]);
|
||||
# Introduced because ifuse doesn't build due to CVEs in libplist
|
||||
# Revert when libplist builds again…
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{ symlinkJoin, kdevelop-unwrapped, plugins ? null }:
|
||||
{ lib, symlinkJoin, kdevelop-unwrapped, plugins ? null }:
|
||||
|
||||
symlinkJoin {
|
||||
name = "kdevelop-with-plugins";
|
||||
|
||||
paths = [ kdevelop-unwrapped ] ++ (if plugins != null then plugins else []);
|
||||
paths = [ kdevelop-unwrapped ] ++ (lib.optionals (plugins != null) plugins);
|
||||
}
|
||||
|
@ -90,9 +90,7 @@ mkChromiumDerivation (base: rec {
|
||||
license = if enableWideVine then lib.licenses.unfree else lib.licenses.bsd3;
|
||||
platforms = lib.platforms.linux;
|
||||
mainProgram = "chromium";
|
||||
hydraPlatforms = if (channel == "stable" || channel == "ungoogled-chromium")
|
||||
then ["aarch64-linux" "x86_64-linux"]
|
||||
else [];
|
||||
hydraPlatforms = lib.optionals (channel == "stable" || channel == "ungoogled-chromium") ["aarch64-linux" "x86_64-linux"];
|
||||
timeout = 172800; # 48 hours (increased from the Hydra default of 10h)
|
||||
};
|
||||
})
|
||||
|
@ -98,7 +98,7 @@ let
|
||||
|
||||
usesNixExtensions = nixExtensions != null;
|
||||
|
||||
nameArray = builtins.map(a: a.name) (if usesNixExtensions then nixExtensions else []);
|
||||
nameArray = builtins.map(a: a.name) (lib.optionals usesNixExtensions nixExtensions);
|
||||
|
||||
requiresSigning = browser ? MOZ_REQUIRE_SIGNING
|
||||
-> toString browser.MOZ_REQUIRE_SIGNING != "";
|
||||
@ -114,7 +114,7 @@ let
|
||||
throw "nixExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
|
||||
else
|
||||
a
|
||||
) (if usesNixExtensions then nixExtensions else []);
|
||||
) (lib.optionals usesNixExtensions nixExtensions);
|
||||
|
||||
enterprisePolicies =
|
||||
{
|
||||
|
@ -37,20 +37,18 @@ rec {
|
||||
);
|
||||
nativeBuildInputs = lib.flatten (lib.mapAttrsToList (
|
||||
feat: info: (
|
||||
if hasFeature feat then
|
||||
(if builtins.hasAttr "native" info then info.native else []) ++
|
||||
(if builtins.hasAttr "pythonNative" info then info.pythonNative else [])
|
||||
else
|
||||
[]
|
||||
lib.optionals (hasFeature feat) (
|
||||
(lib.optionals (builtins.hasAttr "native" info) info.native) ++
|
||||
(lib.optionals (builtins.hasAttr "pythonNative" info) info.pythonNative)
|
||||
)
|
||||
)
|
||||
) featuresInfo);
|
||||
buildInputs = lib.flatten (lib.mapAttrsToList (
|
||||
feat: info: (
|
||||
if hasFeature feat then
|
||||
(if builtins.hasAttr "runtime" info then info.runtime else []) ++
|
||||
(if builtins.hasAttr "pythonRuntime" info then info.pythonRuntime else [])
|
||||
else
|
||||
[]
|
||||
lib.optionals (hasFeature feat) (
|
||||
(lib.optionals (builtins.hasAttr "runtime" info) info.runtime) ++
|
||||
(lib.optionals (builtins.hasAttr "pythonRuntime" info) info.pythonRuntime)
|
||||
)
|
||||
)
|
||||
) featuresInfo);
|
||||
cmakeFlags = lib.mapAttrsToList (
|
||||
|
@ -41,12 +41,9 @@ let
|
||||
++ (builtins.map unwrapped.python.pkgs.toPythonModule extraPackages)
|
||||
++ lib.flatten (lib.mapAttrsToList (
|
||||
feat: info: (
|
||||
if unwrapped.hasFeature feat then
|
||||
(if builtins.hasAttr "pythonRuntime" info then info.pythonRuntime else [])
|
||||
else
|
||||
[]
|
||||
lib.optionals ((unwrapped.hasFeature feat) && (builtins.hasAttr "pythonRuntime" info)) info.pythonRuntime
|
||||
)
|
||||
) unwrapped.featuresInfo)
|
||||
) unwrapped.featuresInfo)
|
||||
;
|
||||
pythonEnv = unwrapped.python.withPackages(ps: pythonPkgs);
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
# * application: Whether this package is a python library or an
|
||||
# application which happens to be written in python.
|
||||
# * doCheck: Whether to run the test suites.
|
||||
pythonPackages:
|
||||
{ src, info, meta ? {}, application ? false, doCheck ? true }: let
|
||||
lib: pythonPackages:
|
||||
{ src, info, meta ? {}, application ? false, doCheck ? true}: let
|
||||
build = if application
|
||||
then pythonPackages.buildPythonApplication
|
||||
else pythonPackages.buildPythonPackage;
|
||||
@ -18,7 +18,8 @@ in build {
|
||||
|
||||
nativeBuildInputs = map (p: pythonPackages.${p}) (
|
||||
(info.setup_requires or []) ++
|
||||
(if doCheck then (info.tests_require or []) else []));
|
||||
(lib.optionals doCheck (info.tests_require or []))
|
||||
);
|
||||
|
||||
propagatedBuildInputs = map (p: pythonPackages.${p})
|
||||
(info.install_requires or []);
|
||||
|
@ -30,9 +30,7 @@ let
|
||||
meta.licence = let
|
||||
depLicenses = lib.splitString "\n" (builtins.readFile "${nuget-source}/share/licenses");
|
||||
in (lib.flatten (lib.forEach depLicenses (spdx:
|
||||
if (spdx != "")
|
||||
then lib.getLicenseFromSpdxId spdx
|
||||
else []
|
||||
lib.optionals (spdx != "") (lib.getLicenseFromSpdxId spdx)
|
||||
)));
|
||||
};
|
||||
in nuget-source
|
||||
|
@ -63,7 +63,7 @@
|
||||
hooks = import ./hooks/default.nix;
|
||||
keep = lib.extends hooks pythonPackagesFun;
|
||||
extra = _: {};
|
||||
optionalExtensions = cond: as: if cond then as else [];
|
||||
optionalExtensions = cond: as: lib.optionals cond as;
|
||||
pythonExtension = import ../../../top-level/python-packages.nix;
|
||||
python2Extension = import ../../../top-level/python2-packages.nix;
|
||||
extensions = lib.composeManyExtensions ([
|
||||
|
@ -39,7 +39,7 @@ let
|
||||
}));
|
||||
|
||||
# See build-setupcfg/default.nix for documentation.
|
||||
buildSetupcfg = import ../../../build-support/build-setupcfg self;
|
||||
buildSetupcfg = import ../../../build-support/build-setupcfg lib self;
|
||||
|
||||
# Check whether a derivation provides a Python module.
|
||||
hasPythonModule = drv: drv?pythonModule && drv.pythonModule == python;
|
||||
|
@ -5,7 +5,7 @@
|
||||
, sha512
|
||||
, type ? "jar"
|
||||
, suffix ? ""
|
||||
, sourceProvenance ? (if type == "jar" then [ lib.sourceTypes.binaryBytecode ] else [])
|
||||
, sourceProvenance ? (lib.optionals (type == "jar") [ lib.sourceTypes.binaryBytecode ])
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -186,7 +186,7 @@ rec {
|
||||
system-images = lib.flatten (map (apiVersion:
|
||||
map (type:
|
||||
map (abiVersion:
|
||||
if lib.hasAttrByPath [apiVersion type abiVersion] system-images-packages then
|
||||
lib.optionals (lib.hasAttrByPath [apiVersion type abiVersion] system-images-packages) (
|
||||
deployAndroidPackage {
|
||||
inherit os;
|
||||
package = system-images-packages.${apiVersion}.${type}.${abiVersion};
|
||||
@ -197,7 +197,7 @@ rec {
|
||||
sed -i '/^Addon.Vendor/d' source.properties
|
||||
'';
|
||||
}
|
||||
else []
|
||||
)
|
||||
) abiVersions
|
||||
) systemImageTypes
|
||||
) platformVersions);
|
||||
@ -217,7 +217,7 @@ rec {
|
||||
};
|
||||
|
||||
# All NDK bundles.
|
||||
ndk-bundles = if includeNDK then map makeNdkBundle ndkVersions else [];
|
||||
ndk-bundles = lib.optionals includeNDK (map makeNdkBundle ndkVersions);
|
||||
|
||||
# The "default" NDK bundle.
|
||||
ndk-bundle = if includeNDK then lib.findFirst (x: x != null) null ndk-bundles else null;
|
||||
|
@ -42,7 +42,7 @@ buildPythonPackage {
|
||||
# Revisit this whenever package or Rust is upgraded
|
||||
RUSTC_BOOTSTRAP = 1;
|
||||
|
||||
propagatedBuildInputs = if pythonOlder "3.10" then [ typing-extensions ] else [];
|
||||
propagatedBuildInputs = lib.optionals (pythonOlder "3.10") [ typing-extensions ];
|
||||
|
||||
nativeBuildInputs = with rustPlatform; [ cargoSetupHook maturinBuildHook ];
|
||||
|
||||
|
@ -12,12 +12,8 @@ stdenv.mkDerivation {
|
||||
nativeBuildInputs = [ autoconf automake ];
|
||||
buildInputs = [ libX11 libXt libXpm libXaw ];
|
||||
preConfigure = "autoreconf --install";
|
||||
patches = if stdenv.buildPlatform.isDarwin then [ ./darwin.patch ] else [];
|
||||
configureFlags =
|
||||
if localStateDir != null then
|
||||
["--localstatedir=${localStateDir}"]
|
||||
else
|
||||
[];
|
||||
patches = lib.optionals stdenv.buildPlatform.isDarwin [ ./darwin.patch ];
|
||||
configureFlags = lib.optionals (localStateDir != null) ["--localstatedir=${localStateDir}"];
|
||||
|
||||
meta = with lib; {
|
||||
description = "The falling tower game";
|
||||
|
@ -322,7 +322,7 @@ let
|
||||
}"
|
||||
else
|
||||
"key 'meta.${k}' is unrecognized; expected one of: \n [${lib.concatMapStringsSep ", " (x: "'${x}'") (lib.attrNames metaTypes)}]";
|
||||
checkMeta = meta: if config.checkMeta then lib.remove null (lib.mapAttrsToList checkMetaAttr meta) else [];
|
||||
checkMeta = meta: lib.optionals config.checkMeta (lib.remove null (lib.mapAttrsToList checkMetaAttr meta));
|
||||
|
||||
checkOutputsToInstall = attrs: let
|
||||
expectedOutputs = attrs.meta.outputsToInstall or [];
|
||||
|
@ -12,9 +12,9 @@ let
|
||||
else "/bin/bash";
|
||||
|
||||
path =
|
||||
(if system == "i686-solaris" then [ "/usr/gnu" ] else []) ++
|
||||
(if system == "i686-netbsd" then [ "/usr/pkg" ] else []) ++
|
||||
(if system == "x86_64-solaris" then [ "/opt/local/gnu" ] else []) ++
|
||||
(lib.optionals (system == "i686-solaris") [ "/usr/gnu" ]) ++
|
||||
(lib.optionals (system == "i686-netbsd") [ "/usr/pkg" ]) ++
|
||||
(lib.optionals (system == "x86_64-solaris") [ "/opt/local/gnu" ]) ++
|
||||
["/" "/usr" "/usr/local"];
|
||||
|
||||
prehookBase = ''
|
||||
|
@ -26,7 +26,7 @@ stdenv.mkDerivation rec {
|
||||
"INSTALL=cp"
|
||||
];
|
||||
|
||||
patches = if (enableNLS && !stdenv.isCygwin) then [ ./natspec-gentoo.patch.bz2 ] else [];
|
||||
patches = lib.optionals (enableNLS && !stdenv.isCygwin) [ ./natspec-gentoo.patch.bz2 ];
|
||||
|
||||
buildInputs = lib.optional enableNLS libnatspec
|
||||
++ lib.optional stdenv.isCygwin libiconv;
|
||||
|
@ -9,7 +9,7 @@ stdenv.mkDerivation {
|
||||
|
||||
path = lib.makeBinPath ([
|
||||
coreutils findutils gnugrep
|
||||
] ++ (if stdenv.isDarwin then [ darwin.DarwinTools ] else []));
|
||||
] ++ (lib.optionals stdenv.isDarwin [ darwin.DarwinTools ]));
|
||||
is_darwin = if stdenv.isDarwin then "yes" else "no";
|
||||
|
||||
sandboxtest = ./sandbox.nix;
|
||||
|
@ -82,7 +82,8 @@ rec {
|
||||
|
||||
|
||||
findLhs2TeXIncludes =
|
||||
{ rootFile
|
||||
{ lib
|
||||
, rootFile
|
||||
}:
|
||||
|
||||
builtins.genericClosure {
|
||||
@ -97,7 +98,7 @@ rec {
|
||||
{ src = key; }
|
||||
"${pkgs.stdenv.bash}/bin/bash ${./find-lhs2tex-includes.sh}");
|
||||
|
||||
in pkgs.lib.concatMap (x: if builtins.pathExists x then [{key = x;}] else [])
|
||||
in pkgs.lib.concatMap (x: lib.optionals (builtins.pathExists x) [{key = x;}])
|
||||
(map (x: dirOf key + ("/" + x)) deps);
|
||||
};
|
||||
|
||||
|
@ -41,7 +41,7 @@ makeScopeWithSplicing (generateSplicesForMkScope "darwin") (_: {}) (spliced: spl
|
||||
useAppleSDKLibs = stdenv.hostPlatform.isAarch64;
|
||||
|
||||
selectAttrs = attrs: names:
|
||||
lib.listToAttrs (lib.concatMap (n: if attrs ? "${n}" then [(lib.nameValuePair n attrs."${n}")] else []) names);
|
||||
lib.listToAttrs (lib.concatMap (n: lib.optionals (attrs ? "${n}") [(lib.nameValuePair n attrs."${n}")]) names);
|
||||
|
||||
chooseLibs = (
|
||||
# There are differences in which libraries are exported. Avoid evaluation
|
||||
|
@ -39,9 +39,7 @@ let
|
||||
attrs:
|
||||
if lib.isDerivation attrs
|
||||
then [ attrs ]
|
||||
else if lib.isAttrs attrs
|
||||
then accumulateDerivations (lib.attrValues attrs)
|
||||
else []
|
||||
else lib.optionals (lib.isAttrs attrs) (accumulateDerivations (lib.attrValues attrs))
|
||||
) jobList;
|
||||
|
||||
# names of all subsets of `pkgs.haskell.packages`
|
||||
|
@ -24,7 +24,7 @@ let
|
||||
packagePython value
|
||||
else
|
||||
[]);
|
||||
in if res.success then res.value else []
|
||||
in lib.optionals res.success res.value
|
||||
);
|
||||
|
||||
jobs = {
|
||||
|
Loading…
Reference in New Issue
Block a user