1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-09-11 15:08:33 +01:00

treewide: use use lib.optionalAttrs instead of 'then {}'

This commit is contained in:
Felix Buehler 2023-06-04 14:20:51 +02:00
parent f47f0a525c
commit ed3b102d1e
5 changed files with 5 additions and 9 deletions

View file

@ -11,7 +11,7 @@ let
default = null;
description = lib.mdDoc description;
type = types.nullOr types.lines;
} // (if example == null then {} else { inherit example; });
} // (lib.optionalAttrs (example != null) { inherit example; });
};
mkHookOptions = hooks: listToAttrs (map mkHookOption hooks);

View file

@ -215,7 +215,7 @@ let
text = v.extraConfig;
})
(filterAttrs (n: v: v.extraConfig != "") cfg.workers))
// (if cfg.extraConfig == "" then {} else {
// (lib.optionalAttrs (cfg.extraConfig != "") {
"extra-config.inc".text = cfg.extraConfig;
});
in

View file

@ -86,8 +86,7 @@ let
mattermostConf = recursiveUpdate
mattermostConfWithoutPlugins
(
if mattermostPlugins == null then {}
else {
lib.optionalAttrs (mattermostPlugins != null) {
PluginSettings = {
Enable = true;
};

View file

@ -23,9 +23,7 @@
maintainers = [ maintainers.vbgl ];
};
}).overrideAttrs (x:
if lib.versionAtLeast x.version "20210316"
then {}
else {
lib.optionalAttrs (lib.versionOlder x.version "20210316") {
installFlags = [ "CONTRIB=$(out)/lib/coq/${coq.coq-version}/user-contrib" ];
}
)

View file

@ -4,8 +4,7 @@ let
skipBuildPhase = x: {
overrides = y: ((x.overrides y) // { buildPhase = "true"; });
};
multiOverride = l: x: if l == [] then {} else
((builtins.head l) x) // (multiOverride (builtins.tail l) x);
multiOverride = l: x: pkgs.lib.optionalAttrs (l != []) ((builtins.head l) x) // (multiOverride (builtins.tail l) x);
lispName = (clwrapper.lisp.pname or (builtins.parseDrvName clwrapper.lisp.name).name);
ifLispIn = l: f: if (pkgs.lib.elem lispName l) then f else (x: {});
ifLispNotIn = l: f: if ! (pkgs.lib.elem lispName l) then f else (x: {});