Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/services/mail/rspamd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions nixos/modules/services/web-apps/mattermost.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ let
mattermostConf = recursiveUpdate
mattermostConfWithoutPlugins
(
if mattermostPlugins == null then {}
else {
lib.optionalAttrs (mattermostPlugins != null) {
PluginSettings = {
Enable = true;
};
Expand Down
4 changes: 1 addition & 3 deletions pkgs/development/coq-modules/tlc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ];
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think missing parentheses here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #237631

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I guess, though I really suspect that that if-then-else version was more readable. Also supported by getting several +1 reviews without noticing that the new code parses wrong. (copied this from chat, for reference)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly relevant to the proposal for <| in NixOS/rfcs#148.

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: {});
Expand Down