treewide: replace builtins.map usage to lib.map

This commit is contained in:
Gabriel Arazas 2025-04-13 15:15:55 +08:00
parent 6fd69b1005
commit c09faac74f
No known key found for this signature in database
GPG Key ID: 62104B43D00AA360
21 changed files with 33 additions and 33 deletions

View File

@ -2,7 +2,7 @@
let userConfig = hmConfig.users.foo-dogsquared; let userConfig = hmConfig.users.foo-dogsquared;
in { in {
extraPlugins = builtins.map (path: extraPlugins = lib.map (path:
pkgs.runCommand "vim-plugin-bare" { } '' pkgs.runCommand "vim-plugin-bare" { } ''
mkdir -p "$out" mkdir -p "$out"
cp -r ${path}/* "$out" cp -r ${path}/* "$out"

View File

@ -27,13 +27,13 @@ let
inherit name; inherit name;
inherit (value) subscriptions extraArgs; inherit (value) subscriptions extraArgs;
}) db); }) db);
jobsList = builtins.map (category: jobsList = lib.map (category:
let jobExtraArgs = lib.attrByPath [ "data" "extraArgs" ] [ ] category; let jobExtraArgs = lib.attrByPath [ "data" "extraArgs" ] [ ] category;
in { in {
name = category.data.name; name = category.data.name;
value = { value = {
extraArgs = extraArgs ++ jobExtraArgs; extraArgs = extraArgs ++ jobExtraArgs;
urls = builtins.map (subscription: subscription.url) urls = lib.map (subscription: subscription.url)
category.data.subscriptions; category.data.subscriptions;
startAt = startAt =
lib.elemAt days (lib.mod category.index (lib.length days)); lib.elemAt days (lib.mod category.index (lib.length days));

View File

@ -103,7 +103,7 @@ in {
}; };
applySystemdAttr = secretPaths: applySystemdAttr = secretPaths:
lib.listToAttrs lib.listToAttrs
(builtins.map (path: lib.nameValuePair path systemdNetworkFileAttrs)) (lib.map (path: lib.nameValuePair path systemdNetworkFileAttrs))
secretPaths; secretPaths;
in applySystemdAttr [ in applySystemdAttr [
"wireguard/private-key" "wireguard/private-key"

View File

@ -16,7 +16,7 @@ let
mode = "repokey-blake2"; mode = "repokey-blake2";
}; };
extraCreateArgs = lib.concatStringsSep " " extraCreateArgs = lib.concatStringsSep " "
(builtins.map (patternFile: "--patterns-from ${patternFile}") patterns); (lib.map (patternFile: "--patterns-from ${patternFile}") patterns);
extraInitArgs = "--make-parent-dirs"; extraInitArgs = "--make-parent-dirs";
# We're emptying them since we're specifying them all through the patterns file. # We're emptying them since we're specifying them all through the patterns file.

View File

@ -92,13 +92,13 @@ in {
inherit name; inherit name;
inherit (value) subscriptions extraArgs; inherit (value) subscriptions extraArgs;
}) db); }) db);
jobsList = builtins.map (category: jobsList = lib.map (category:
let jobExtraArgs = lib.attrByPath [ "data" "extraArgs" ] [ ] category; let jobExtraArgs = lib.attrByPath [ "data" "extraArgs" ] [ ] category;
in { in {
name = category.data.name; name = category.data.name;
value = { value = {
extraArgs = extraArgs ++ jobExtraArgs; extraArgs = extraArgs ++ jobExtraArgs;
urls = builtins.map (subscription: subscription.url) urls = lib.map (subscription: subscription.url)
category.data.subscriptions; category.data.subscriptions;
startAt = startAt =
lib.elemAt days (lib.mod category.index (lib.length days)); lib.elemAt days (lib.mod category.index (lib.length days));

View File

@ -22,10 +22,10 @@ let
}; };
extraCreateArgs = let extraCreateArgs = let
args = lib.flatten [ args = lib.flatten [
(builtins.map (lib.map
(patternFile: "--patterns-from ${lib.escapeShellArg patternFile}") (patternFile: "--patterns-from ${lib.escapeShellArg patternFile}")
patternFiles) patternFiles)
(builtins.map (pattern: "--pattern ${lib.escapeShellArg pattern}") (lib.map (pattern: "--pattern ${lib.escapeShellArg pattern}")
patterns) patterns)
]; ];
in lib.concatStringsSep " " args; in lib.concatStringsSep " " args;

View File

@ -88,7 +88,7 @@ in {
# A set of bindings to be used for each jump direction. # A set of bindings to be used for each jump direction.
bindings: bindings:
let let
mappings = builtins.map (motion: mappings = lib.map (motion:
let let
inherit (motion) region jumpDirection variant; inherit (motion) region jumpDirection variant;
jumpDirection' = lib.strings.toLower jumpDirection; jumpDirection' = lib.strings.toLower jumpDirection;
@ -164,7 +164,7 @@ in {
binding: binding:
let let
mappingsList = builtins.map (variant: mappingsList = lib.map (variant:
let prefixMap' = prefixMap.${variant}; let prefixMap' = prefixMap.${variant};
in lib.nameValuePair "${prefixMap'.key}${binding}" { in lib.nameValuePair "${prefixMap'.key}${binding}" {
query = "@${query}.${variant}"; query = "@${query}.${variant}";
@ -200,7 +200,7 @@ in {
mkQueryMappings = acc: query: bindings: mkQueryMappings = acc: query: bindings:
let let
mappings = builtins.map (motion: mappings = lib.map (motion:
let let
inherit (motion) jumpDirection variant; inherit (motion) jumpDirection variant;
jumpDirection' = lib.strings.toLower jumpDirection; jumpDirection' = lib.strings.toLower jumpDirection;

View File

@ -65,7 +65,7 @@ in {
mkEnableServerConfig = server: mkEnableServerConfig = server:
lib.nameValuePair server { enable = true; }; lib.nameValuePair server { enable = true; };
in lib.listToAttrs (builtins.map mkEnableServerConfig servers); in lib.listToAttrs (lib.map mkEnableServerConfig servers);
} }
{ {

View File

@ -63,7 +63,7 @@ let
sha256 = hash; sha256 = hash;
}; };
in if version == 3 then in if version == 3 then
builtins.mapAttrs (_: mkSource) data.pins lib.mapAttrs (_: mkSource) data.pins
else else
throw "Unsupported format version ${ throw "Unsupported format version ${
toString version toString version

View File

@ -53,7 +53,7 @@ in {
config = lib.mkIf (config.diskoConfigs != [ ]) (let config = lib.mkIf (config.diskoConfigs != [ ]) (let
diskoConfigs = diskoConfigs =
builtins.map (name: "${partsConfig.setups.configDir}/disko/${name}") lib.map (name: "${partsConfig.setups.configDir}/disko/${name}")
config.diskoConfigs; config.diskoConfigs;
in { in {
modules = lib.singleton { modules = lib.singleton {

View File

@ -363,7 +363,7 @@ in {
# A quick data structure we can pass through multiple build pipelines. # A quick data structure we can pass through multiple build pipelines.
pureHomeManagerConfigs = let pureHomeManagerConfigs = let
generatePureConfigs = username: metadata: generatePureConfigs = username: metadata:
lib.listToAttrs (builtins.map (system: lib.listToAttrs (lib.map (system:
let let
nixpkgs = inputs.${metadata.nixpkgs.branch}; nixpkgs = inputs.${metadata.nixpkgs.branch};

View File

@ -283,7 +283,7 @@ in {
cfg.configs; cfg.configs;
generatePureConfigs = hostname: metadata: generatePureConfigs = hostname: metadata:
lib.listToAttrs (builtins.map (system: lib.listToAttrs (lib.map (system:
let let
nixpkgs = inputs.${metadata.nixpkgs.branch}; nixpkgs = inputs.${metadata.nixpkgs.branch};
@ -344,7 +344,7 @@ in {
extraModules = cfg.sharedModules ++ metadata.modules; extraModules = cfg.sharedModules ++ metadata.modules;
}); });
images = builtins.map buildImage metadata.formats; images = lib.map buildImage metadata.formats;
in lib.listToAttrs images; in lib.listToAttrs images;
in lib.concatMapAttrs generateImages validImages; in lib.concatMapAttrs generateImages validImages;
}; };

View File

@ -254,7 +254,7 @@ in {
modules = cfg.sharedModules ++ cfg.standaloneConfigModules modules = cfg.sharedModules ++ cfg.standaloneConfigModules
++ metadata.modules ++ [{ package = neovimPackage; }]; ++ metadata.modules ++ [{ package = neovimPackage; }];
}); });
nixvimConfigs = builtins.map mkNixvimConfig' metadata.components; nixvimConfigs = lib.map mkNixvimConfig' metadata.components;
in lib.listToAttrs nixvimConfigs; in lib.listToAttrs nixvimConfigs;
in lib.concatMapAttrs generateNixvimConfigs validConfigs; in lib.concatMapAttrs generateNixvimConfigs validConfigs;
in { in {

View File

@ -7,7 +7,7 @@ let
# `$out/share/pop-launcher`. # `$out/share/pop-launcher`.
pluginsDir = pkgs.symlinkJoin { pluginsDir = pkgs.symlinkJoin {
name = "pop-launcher-plugins-system"; name = "pop-launcher-plugins-system";
paths = builtins.map (p: "${p}/share/pop-launcher") cfg.plugins; paths = lib.map (p: "${p}/share/pop-launcher") cfg.plugins;
}; };
in { in {
options.programs.pop-launcher = { options.programs.pop-launcher = {

View File

@ -131,7 +131,7 @@ in {
"app.drey.Dialect" "app.drey.Dialect"
"com.belmoussaoui.Authenticator" "com.belmoussaoui.Authenticator"
]; ];
apply = builtins.map (x: "${x}.desktop"); apply = lib.map (x: "${x}.desktop");
}; };
disableNotifications = lib.mkOption { disableNotifications = lib.mkOption {
@ -222,14 +222,14 @@ in {
}; };
"org/gnome/shell" = { "org/gnome/shell" = {
enabled-extensions = enabled-extensions =
builtins.map (p: p.extensionUuid) shellExtensions'; lib.map (p: p.extensionUuid) shellExtensions';
}; };
} }
# Disable all of the messenger's notification (only the annoying # Disable all of the messenger's notification (only the annoying
# ones). # ones).
(lib.pipe cfg.disableNotifications [ (lib.pipe cfg.disableNotifications [
(builtins.map (app: (lib.map (app:
lib.nameValuePair lib.nameValuePair
"org/gnome/desktop/notifications/application/${app}" { "org/gnome/desktop/notifications/application/${app}" {
show-banners = false; show-banners = false;

View File

@ -158,7 +158,7 @@ in {
requiredComponents = requiredComponents =
let let
gsdComponents = gsdComponents =
builtins.map lib.map
(gsdc: "org.gnome.SettingsDaemon.''${gsdc}") (gsdc: "org.gnome.SettingsDaemon.''${gsdc}")
[ [
"A11ySettings" "A11ySettings"
@ -175,7 +175,7 @@ in {
systemd.targetUnit = { systemd.targetUnit = {
requires = [ "org.gnome.Shell.target" ]; requires = [ "org.gnome.Shell.target" ];
wants = builtins.map (c: "''${c}.target") (lib.lists.remove "org.gnome.Shell" sessionCfg.requiredComponents); wants = lib.map (c: "''${c}.target") (lib.lists.remove "org.gnome.Shell" sessionCfg.requiredComponents);
}; };
}; };

View File

@ -67,7 +67,7 @@ in {
default = [ config.fullName ]; default = [ config.fullName ];
defaultText = "[ <session>.fullName ]"; defaultText = "[ <session>.fullName ]";
apply = names: apply = names:
builtins.map (name: lib.map (name:
if (lib.elem name validDesktopNames) || (lib.hasPrefix "X-" name) then if (lib.elem name validDesktopNames) || (lib.hasPrefix "X-" name) then
name name
else else
@ -222,7 +222,7 @@ in {
systemd.targetUnit = { systemd.targetUnit = {
overrideStrategy = lib.mkForce "asDropin"; overrideStrategy = lib.mkForce "asDropin";
wants = lib.mkDefault wants = lib.mkDefault
(builtins.map (c: "${c}.target") config.requiredComponents); (lib.map (c: "${c}.target") config.requiredComponents);
}; };
settings."GNOME Session" = { settings."GNOME Session" = {

View File

@ -7,7 +7,7 @@ let
# `$out/share/pop-launcher`. # `$out/share/pop-launcher`.
pluginsDir = pkgs.symlinkJoin { pluginsDir = pkgs.symlinkJoin {
name = "pop-launcher-plugins-system"; name = "pop-launcher-plugins-system";
paths = builtins.map (p: "${p}/share/pop-launcher") cfg.plugins; paths = lib.map (p: "${p}/share/pop-launcher") cfg.plugins;
}; };
in { in {
options.programs.pop-launcher = { options.programs.pop-launcher = {

View File

@ -70,7 +70,7 @@ in {
default = [ config.fullName ]; default = [ config.fullName ];
defaultText = "[ <session>.fullName ]"; defaultText = "[ <session>.fullName ]";
apply = names: apply = names:
builtins.map (name: lib.map (name:
if (lib.elem name validDesktopNames) || (lib.hasPrefix "X-" name) then if (lib.elem name validDesktopNames) || (lib.hasPrefix "X-" name) then
name name
else else

View File

@ -110,8 +110,8 @@ in {
config.extraArgs = let inherit (config) policies; config.extraArgs = let inherit (config) policies;
in lib.optionals (policies.level != null) in lib.optionals (policies.level != null)
[ "--${policies.level}=${name}" ] [ "--${policies.level}=${name}" ]
++ builtins.map (rule: "--call=${name}=${rule}") policies.call ++ lib.map (rule: "--call=${name}=${rule}") policies.call
++ builtins.map (rule: "--broadcast=${name}=${rule}") policies.broadcast; ++ lib.map (rule: "--broadcast=${name}=${rule}") policies.broadcast;
}; };
bubblewrapModule = { config, lib, pkgs, name, ... }: bubblewrapModule = { config, lib, pkgs, name, ... }:

View File

@ -235,13 +235,13 @@ in {
(lib.mkIf (submoduleCfg.sharedNixPaths != [ ]) { (lib.mkIf (submoduleCfg.sharedNixPaths != [ ]) {
wraparound.bubblewrap.extraArgs = wraparound.bubblewrap.extraArgs =
let closurePaths = getClosurePaths submoduleCfg.sharedNixPaths; let closurePaths = getClosurePaths submoduleCfg.sharedNixPaths;
in builtins.map (p: "--ro-bind ${p} ${p}") closurePaths; in lib.map (p: "--ro-bind ${p} ${p}") closurePaths;
}) })
(lib.mkIf submoduleCfg.dbus.enable { (lib.mkIf submoduleCfg.dbus.enable {
wraparound.bubblewrap.dbus.filter.bwrapArgs = wraparound.bubblewrap.dbus.filter.bwrapArgs =
let closurePaths = getClosurePaths submoduleCfg.sharedNixPaths; let closurePaths = getClosurePaths submoduleCfg.sharedNixPaths;
in builtins.map (p: "--ro-bind ${p} ${p}") closurePaths; in lib.map (p: "--ro-bind ${p} ${p}") closurePaths;
}) })
]); ]);
}; };