various: lib usage improvements - prefer elem over any for list inclusion conditions (#455789)
This commit is contained in:
@@ -30,12 +30,12 @@ in
|
||||
glibcLocales = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
default = pkgs.glibcLocales.override {
|
||||
allLocales = lib.any (x: x == "all") config.i18n.supportedLocales;
|
||||
allLocales = lib.elem "all" config.i18n.supportedLocales;
|
||||
locales = config.i18n.supportedLocales;
|
||||
};
|
||||
defaultText = lib.literalExpression ''
|
||||
pkgs.glibcLocales.override {
|
||||
allLocales = lib.any (x: x == "all") config.i18n.supportedLocales;
|
||||
allLocales = lib.elem "all" config.i18n.supportedLocales;
|
||||
locales = config.i18n.supportedLocales;
|
||||
}
|
||||
'';
|
||||
@@ -149,7 +149,7 @@ in
|
||||
(
|
||||
!(
|
||||
(lib.subtractLists config.i18n.supportedLocales aggregatedLocales) == [ ]
|
||||
|| lib.any (x: x == "all") config.i18n.supportedLocales
|
||||
|| lib.elem "all" config.i18n.supportedLocales
|
||||
)
|
||||
)
|
||||
''
|
||||
|
||||
@@ -130,7 +130,7 @@ in
|
||||
passwordFile = lib.mkOption {
|
||||
default =
|
||||
if localMpd then
|
||||
(lib.findFirst (c: lib.any (x: x == "read") c.permissions) {
|
||||
(lib.findFirst (c: lib.elem "read" c.permissions) {
|
||||
passwordFile = null;
|
||||
} mpdCfg.credentials).passwordFile
|
||||
else
|
||||
|
||||
@@ -13,11 +13,11 @@ let
|
||||
types
|
||||
concatStringsSep
|
||||
concatMapStringsSep
|
||||
any
|
||||
elem
|
||||
optionals
|
||||
;
|
||||
collectorIsEnabled = final: any (collector: (final == collector)) cfg.enabledCollectors;
|
||||
collectorIsDisabled = final: any (collector: (final == collector)) cfg.disabledCollectors;
|
||||
collectorIsEnabled = final: elem final cfg.enabledCollectors;
|
||||
collectorIsDisabled = final: elem final cfg.disabledCollectors;
|
||||
in
|
||||
{
|
||||
port = 9100;
|
||||
|
||||
@@ -198,7 +198,7 @@ in
|
||||
{
|
||||
assertion =
|
||||
initrdCfg.package.passthru.features.withWireguard
|
||||
|| !(builtins.any (kind: kind == "wireguard") initrdInterfaceTypes);
|
||||
|| !(builtins.elem "wireguard" initrdInterfaceTypes);
|
||||
message = "IfState initrd package is configured without the `wireguard` feature, but wireguard interfaces are configured. Please see the `boot.initrd.network.ifstate.package` option.";
|
||||
}
|
||||
{
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
any
|
||||
boolToString
|
||||
concatStringsSep
|
||||
elem
|
||||
isBool
|
||||
isString
|
||||
mapAttrsToList
|
||||
@@ -46,7 +46,7 @@ let
|
||||
|
||||
toStr =
|
||||
k: v:
|
||||
if (any (str: k == str) secretKeys) then
|
||||
if (elem k secretKeys) then
|
||||
v
|
||||
else if isString v then
|
||||
"'${v}'"
|
||||
|
||||
@@ -338,10 +338,10 @@ in
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
''
|
||||
+ lib.optionalString (lib.any (m: m.name == "brotli") config.services.nginx.additionalModules) ''
|
||||
+ lib.optionalString (lib.elem "brotli" config.services.nginx.additionalModules) ''
|
||||
brotli off;
|
||||
''
|
||||
+ lib.optionalString (lib.any (m: m.name == "zstd") config.services.nginx.additionalModules) ''
|
||||
+ lib.optionalString (lib.elem "zstd" config.services.nginx.additionalModules) ''
|
||||
zstd off;
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ let
|
||||
locs: defs:
|
||||
if defs == [ ] then
|
||||
abort "This case should never happen."
|
||||
else if any (x: x == false) (getValues defs) then
|
||||
else if elem false (getValues defs) then
|
||||
false
|
||||
else
|
||||
true;
|
||||
|
||||
@@ -18,9 +18,7 @@ let
|
||||
}:
|
||||
let
|
||||
masterName = head (
|
||||
filter (machineName: any (role: role == "master") machines.${machineName}.roles) (
|
||||
attrNames machines
|
||||
)
|
||||
filter (machineName: lib.elem "master" machines.${machineName}.roles) (attrNames machines)
|
||||
);
|
||||
master = machines.${masterName};
|
||||
extraHosts = ''
|
||||
|
||||
@@ -25,7 +25,7 @@ let
|
||||
groupName:
|
||||
# users.users attrset
|
||||
user:
|
||||
lib.any (x: x == user.name) config.users.groups.${groupName}.members;
|
||||
lib.elem user.name config.users.groups.${groupName}.members;
|
||||
|
||||
# Generates a valid SFTPGo user configuration for a given user
|
||||
# Will be converted to JSON and loaded on application startup.
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
ctestCheckHook,
|
||||
}:
|
||||
|
||||
assert builtins.any (g: guiModule == g) [
|
||||
assert builtins.elem guiModule [
|
||||
"fltk"
|
||||
"ntk"
|
||||
"zest"
|
||||
|
||||
@@ -62,7 +62,7 @@ in
|
||||
"logo64"
|
||||
"extraPaths"
|
||||
];
|
||||
kernel = lib.filterAttrs (n: v: (lib.any (x: x == n) allowedKernelKeys)) unfilteredKernel;
|
||||
kernel = lib.filterAttrs (n: v: (lib.elem n allowedKernelKeys)) unfilteredKernel;
|
||||
config = builtins.toJSON (
|
||||
kernel
|
||||
// {
|
||||
|
||||
@@ -142,14 +142,12 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
# the following are distributed with calibre, but we use upstream instead
|
||||
odfpy
|
||||
]
|
||||
++
|
||||
lib.optionals (lib.lists.any (p: p == stdenv.hostPlatform.system) pyqt6-webengine.meta.platforms)
|
||||
[
|
||||
# much of calibre's functionality is usable without a web
|
||||
# browser, so we enable building on platforms which qtwebengine
|
||||
# does not support by simply omitting qtwebengine.
|
||||
pyqt6-webengine
|
||||
]
|
||||
++ lib.optionals (lib.lists.elem stdenv.hostPlatform.system pyqt6-webengine.meta.platforms) [
|
||||
# much of calibre's functionality is usable without a web
|
||||
# browser, so we enable building on platforms which qtwebengine
|
||||
# does not support by simply omitting qtwebengine.
|
||||
pyqt6-webengine
|
||||
]
|
||||
++ lib.optional unrarSupport unrardll
|
||||
))
|
||||
piper-tts
|
||||
|
||||
@@ -52,7 +52,7 @@ stdenv.mkDerivation {
|
||||
|
||||
env.NIX_CFLAGS_COMPILE = toString [ "-fpermissive" ];
|
||||
|
||||
postFixup = lib.optionalString (lib.any (x: x == "vitalium") plugins || plugins == [ ]) ''
|
||||
postFixup = lib.optionalString (lib.elem "vitalium" plugins || plugins == [ ]) ''
|
||||
for file in \
|
||||
$out/lib/lv2/vitalium.lv2/vitalium.so \
|
||||
$out/lib/vst/vitalium.so \
|
||||
|
||||
@@ -24,7 +24,7 @@ let
|
||||
# libcs in nixpkgs (musl and glibc).
|
||||
compatible =
|
||||
lib: drv:
|
||||
lib.any (lic: lic == (drv.meta.license or { })) [
|
||||
lib.elem (drv.meta.license or { }) [
|
||||
lib.licenses.mit # musl
|
||||
lib.licenses.lgpl2Plus # glibc
|
||||
];
|
||||
|
||||
@@ -106,9 +106,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
description = "More modular rewrite of most components from VGMPlay";
|
||||
homepage = "https://github.com/ValleyBell/libvgm";
|
||||
license =
|
||||
if
|
||||
(enableEmulation && (withAllEmulators || (lib.lists.any (core: core == "WSWAN_ALL") emulators)))
|
||||
then
|
||||
if (enableEmulation && (withAllEmulators || (lib.lists.elem "WSWAN_ALL" emulators))) then
|
||||
lib.licenses.unfree # https://github.com/ValleyBell/libvgm/issues/43
|
||||
else
|
||||
lib.licenses.gpl2Only;
|
||||
|
||||
@@ -59,7 +59,7 @@ let
|
||||
# https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/issues/2454#note_112821
|
||||
"fftw"
|
||||
];
|
||||
itkIsInDepsToRemove = dep: builtins.any (d: d == dep.name) itkDepsToRemove;
|
||||
itkIsInDepsToRemove = dep: builtins.elem dep.name itkDepsToRemove;
|
||||
|
||||
# remove after https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/issues/2451
|
||||
otbSwig = swig.overrideAttrs (oldArgs: {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
withStyle ? "light", # use override to specify one of "dark" / "orange" / "bigSur"
|
||||
}:
|
||||
|
||||
assert builtins.any (s: withStyle == s) [
|
||||
assert builtins.elem withStyle [
|
||||
"light"
|
||||
"dark"
|
||||
"orange"
|
||||
|
||||
@@ -145,7 +145,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
# this is a hack to make the php plugin link with session.so (which on nixos is a separate package)
|
||||
# the hack works in coordination with ./additional-php-ldflags.patch
|
||||
UWSGICONFIG_PHP_LDFLAGS = lib.optionalString (builtins.any (x: x.name == "php") needed) (
|
||||
UWSGICONFIG_PHP_LDFLAGS = lib.optionalString (lib.elem "php" needed) (
|
||||
lib.concatStringsSep "," [
|
||||
"-Wl"
|
||||
"-rpath=${php-embed.extensions.session}/lib/php/extensions/"
|
||||
@@ -176,7 +176,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postFixup = lib.optionalString (builtins.any (x: x.name == "php") needed) ''
|
||||
postFixup = lib.optionalString (lib.elem "php" needed) ''
|
||||
wrapProgram $out/bin/uwsgi --set PHP_INI_SCAN_DIR ${php-embed}/lib
|
||||
'';
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ stdenv.mkDerivation rec {
|
||||
]
|
||||
++
|
||||
lib.optionals
|
||||
(lib.any (l: l == optimizationLevel) [
|
||||
(lib.elem optimizationLevel [
|
||||
"0"
|
||||
"1"
|
||||
"2"
|
||||
|
||||
@@ -14,7 +14,7 @@ let
|
||||
builtins.toJSON (
|
||||
lib.filterAttrs (
|
||||
n: v:
|
||||
builtins.any (x: x == n) [
|
||||
builtins.elem n [
|
||||
"name"
|
||||
"system"
|
||||
]
|
||||
|
||||
@@ -57,7 +57,7 @@ let
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
any
|
||||
elem
|
||||
optionalString
|
||||
optionals
|
||||
optional
|
||||
@@ -66,11 +66,11 @@ let
|
||||
|
||||
smartmon = smartmontools.override { inherit enableMail; };
|
||||
|
||||
buildKernel = any (n: n == configFile) [
|
||||
buildKernel = elem configFile [
|
||||
"kernel"
|
||||
"all"
|
||||
];
|
||||
buildUser = any (n: n == configFile) [
|
||||
buildUser = elem configFile [
|
||||
"user"
|
||||
"all"
|
||||
];
|
||||
|
||||
@@ -43,7 +43,7 @@ let
|
||||
license,
|
||||
...
|
||||
}@args:
|
||||
assert lib.any (x: x == type) [
|
||||
assert lib.elem type [
|
||||
"plugin"
|
||||
"theme"
|
||||
"language"
|
||||
|
||||
@@ -426,7 +426,7 @@ let
|
||||
|
||||
concretizeFlagImplications =
|
||||
flag: impliesFlags: list:
|
||||
if any (x: x == flag) list then (list ++ impliesFlags) else list;
|
||||
if builtins.elem flag list then (list ++ impliesFlags) else list;
|
||||
|
||||
hardeningDisable' = unique (
|
||||
pipe hardeningDisable [
|
||||
|
||||
@@ -69,7 +69,7 @@ lib.flip builtins.mapAttrs json (
|
||||
);
|
||||
in
|
||||
spdxLicenses.${spdx};
|
||||
broken = builtins.any (x: x == null) reqDeps;
|
||||
broken = builtins.elem null reqDeps;
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs (entry.isPoetry or false) {
|
||||
|
||||
Reference in New Issue
Block a user