treewide: use remove when possible

See https://github.com/nix-community/home-manager/pull/2566.
This commit is contained in:
Robert Helgesson 2021-12-27 09:03:18 +01:00
parent 48f2b381dd
commit 0b197562ab
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
7 changed files with 14 additions and 20 deletions

View file

@ -212,7 +212,7 @@ let
# Note: Missing option `D=`.
transformChannel = channelName:
let channel = cfg.channels.${channelName};
in concatStringsSep "\n" (filter (v: v != null) [
in concatStringsSep "\n" (remove null [
"" # leave a space between one server and another
(transformField "N" channelName)
(loginMethod channel)

View file

@ -180,9 +180,8 @@ in {
"${k} ${if isInt v then toString v else ''"${v}"''}"
}";
settingsStr = concatStringsSep "\n" (filter (x: x != "")
(mapAttrsToList fmtSetting
(builtins.intersectAttrs knownSettings cfg.settings)));
settingsStr = concatStringsSep "\n" (remove "" (mapAttrsToList fmtSetting
(builtins.intersectAttrs knownSettings cfg.settings)));
fmtCmdMap = before: k: v:
"${before} ${k}${optionalString (v != null && v != "") " ${v}"}";

View file

@ -158,8 +158,8 @@ let
genGroupsChannels = group:
concatStringsSep "\n" (genChannelStrings group.name group.channels);
# Generate all channel configurations for all groups for this account.
in concatStringsSep "\n" (filter (s: s != "")
(mapAttrsToList (name: group: genGroupsChannels group) groups));
in concatStringsSep "\n"
(remove "" (mapAttrsToList (name: group: genGroupsChannels group) groups));
# Given the attr set of groups, return a string which maps channels to groups
genAccountGroups = groups:
@ -177,9 +177,9 @@ let
# of the groups and its consituent channels.
genGroupsStrings = mapAttrsToList (name: info:
concatStringsSep "\n" (genGroupChannelString groups.${name})) groups;
in concatStringsSep "\n\n" (filter (s: s != "")
genGroupsStrings) # filter for the cases of empty groups
+ "\n"; # Put all strings together.
# Join all non-empty groups.
combined = concatStringsSep "\n\n" (remove "" genGroupsStrings) + "\n";
in combined;
genGroupConfig = name: channels:
let

View file

@ -46,10 +46,10 @@ let
moduleConfigure = {
packages.home-manager = {
start = filter (f: f != null) (map
start = remove null (map
(x: if x ? plugin && x.optional == true then null else (x.plugin or x))
cfg.plugins);
opt = filter (f: f != null)
opt = remove null
(map (x: if x ? plugin && x.optional == true then x.plugin else null)
cfg.plugins);
};

View file

@ -136,7 +136,7 @@ in {
config = (let
customRC = ''
${concatStringsSep "\n" (filter (v: v != "") (mapAttrsToList setExpr
${concatStringsSep "\n" (remove "" (mapAttrsToList setExpr
(builtins.intersectAttrs knownSettings cfg.settings)))}
${cfg.extraConfig}

View file

@ -5,8 +5,7 @@ with lib;
let
cfg = config.services.fnott;
concatStringsSep' = sep: list:
concatStringsSep sep (filter (x: x != "") list);
concatStringsSep' = sep: list: concatStringsSep sep (remove "" list);
iniFormat = pkgs.formats.ini { };
in {

View file

@ -56,12 +56,8 @@ rec {
fontConfigStr = let
toFontStr = { names, style ? "", size ? "" }:
optionalString (names != [ ]) concatStringsSep " " (filter (x: x != "") [
"font"
"pango:${concatStringsSep ", " names}"
style
size
]);
optionalString (names != [ ]) concatStringsSep " "
(remove "" [ "font" "pango:${concatStringsSep ", " names}" style size ]);
in fontCfg:
if isList fontCfg then
toFontStr { names = fontCfg; }