Revert "mass replace "flip map -> foreach""

This reverts commit 3b0534310c.
This commit is contained in:
danbst 2019-08-05 14:01:45 +03:00
parent 3b0534310c
commit 91bb646e98
18 changed files with 28 additions and 28 deletions

View file

@ -45,7 +45,7 @@ let
+ "</listitem>"; + "</listitem>";
in "<itemizedlist>${lib.concatStringsSep "\n" (map (p: describe (unpack p)) packages)}</itemizedlist>"; in "<itemizedlist>${lib.concatStringsSep "\n" (map (p: describe (unpack p)) packages)}</itemizedlist>";
optionsListDesc = lib.foreach optionsListVisible (opt: opt // { optionsListDesc = lib.flip map optionsListVisible (opt: opt // {
# Clean up declaration sites to not refer to the NixOS source tree. # Clean up declaration sites to not refer to the NixOS source tree.
declarations = map stripAnyPrefixes opt.declarations; declarations = map stripAnyPrefixes opt.declarations;
} }

View file

@ -54,11 +54,11 @@ rec {
machinesNumbered = zipLists machines (range 1 254); machinesNumbered = zipLists machines (range 1 254);
nodes_ = foreach machinesNumbered (m: nameValuePair m.fst nodes_ = flip map machinesNumbered (m: nameValuePair m.fst
[ ( { config, nodes, ... }: [ ( { config, nodes, ... }:
let let
interfacesNumbered = zipLists config.virtualisation.vlans (range 1 255); interfacesNumbered = zipLists config.virtualisation.vlans (range 1 255);
interfaces = foreach interfacesNumbered ({ fst, snd }: interfaces = flip map interfacesNumbered ({ fst, snd }:
nameValuePair "eth${toString snd}" { ipv4.addresses = nameValuePair "eth${toString snd}" { ipv4.addresses =
[ { address = "192.168.${toString fst}.${toString m.snd}"; [ { address = "192.168.${toString fst}.${toString m.snd}";
prefixLength = 24; prefixLength = 24;
@ -88,7 +88,7 @@ rec {
"${config.networking.hostName}\n")); "${config.networking.hostName}\n"));
virtualisation.qemu.options = virtualisation.qemu.options =
foreach interfacesNumbered flip map interfacesNumbered
({ fst, snd }: qemuNICFlags snd fst m.snd); ({ fst, snd }: qemuNICFlags snd fst m.snd);
}; };
} }

View file

@ -102,7 +102,7 @@ let
# builtins multiply by 4 the memory usage and the time used to compute # builtins multiply by 4 the memory usage and the time used to compute
# each options. # each options.
tryCollectOptions = moduleResult: tryCollectOptions = moduleResult:
foreach (excludeOptions (collect isOption moduleResult)) (opt: flip map (excludeOptions (collect isOption moduleResult)) (opt:
{ name = showOption opt.loc; } // builtins.tryEval (strict opt.value)); { name = showOption opt.loc; } // builtins.tryEval (strict opt.value));
in in
keepNames ( keepNames (

View file

@ -248,7 +248,7 @@ with lib;
# KSM # KSM
(mkRenamedOptionModule [ "hardware" "enableKSM" ] [ "hardware" "ksm" "enable" ]) (mkRenamedOptionModule [ "hardware" "enableKSM" ] [ "hardware" "ksm" "enable" ])
] ++ (foreach [ "blackboxExporter" "collectdExporter" "fritzboxExporter" ] ++ (flip map [ "blackboxExporter" "collectdExporter" "fritzboxExporter"
"jsonExporter" "minioExporter" "nginxExporter" "nodeExporter" "jsonExporter" "minioExporter" "nginxExporter" "nodeExporter"
"snmpExporter" "unifiExporter" "varnishExporter" ] "snmpExporter" "unifiExporter" "varnishExporter" ]
(opt: mkRemovedOptionModule [ "services" "prometheus" "${opt}" ] '' (opt: mkRemovedOptionModule [ "services" "prometheus" "${opt}" ] ''

View file

@ -225,7 +225,7 @@ in
'' ''
maxstartdelay = ${toString cfg.maxStartDelay} maxstartdelay = ${toString cfg.maxStartDelay}
${flip concatStringsSep (foreach (attrValues cfg.ups) (ups: ups.summary)) " ${flip concatStringsSep (flip map (attrValues cfg.ups) (ups: ups.summary)) "
"} "}
''; '';

View file

@ -15,7 +15,7 @@ let
++ cfg.extraConfigFiles; ++ cfg.extraConfigFiles;
devices = attrValues (filterAttrs (_: i: i != null) cfg.interface); devices = attrValues (filterAttrs (_: i: i != null) cfg.interface);
systemdDevices = foreach devices systemdDevices = flip map devices
(i: "sys-subsystem-net-devices-${utils.escapeSystemdPath i}.device"); (i: "sys-subsystem-net-devices-${utils.escapeSystemdPath i}.device");
in in
{ {

View file

@ -7,7 +7,7 @@ let
inherit (lib) concatStringsSep optionalString; inherit (lib) concatStringsSep optionalString;
cfg = config.services.hylafax; cfg = config.services.hylafax;
mapModems = lib.foreach (lib.attrValues cfg.modems); mapModems = lib.flip map (lib.attrValues cfg.modems);
mkConfigFile = name: conf: mkConfigFile = name: conf:
# creates hylafax config file, # creates hylafax config file,

View file

@ -502,7 +502,7 @@ in
assertions = [{ assertion = if cfg.forwardX11 then cfgc.setXAuthLocation else true; assertions = [{ assertion = if cfg.forwardX11 then cfgc.setXAuthLocation else true;
message = "cannot enable X11 forwarding without setting xauth location";}] message = "cannot enable X11 forwarding without setting xauth location";}]
++ foreach cfg.listenAddresses ({ addr, ... }: { ++ flip map cfg.listenAddresses ({ addr, ... }: {
assertion = addr != null; assertion = addr != null;
message = "addr must be specified in each listenAddresses entry"; message = "addr must be specified in each listenAddresses entry";
}); });

View file

@ -129,7 +129,7 @@ in
assertion = cfg.killer != null -> cfg.killtime >= 10; assertion = cfg.killer != null -> cfg.killtime >= 10;
message = "killtime has to be at least 10 minutes according to `man xautolock`"; message = "killtime has to be at least 10 minutes according to `man xautolock`";
} }
] ++ (lib.foreach [ "locker" "notifier" "nowlocker" "killer" ] ] ++ (lib.flip map [ "locker" "notifier" "nowlocker" "killer" ]
(option: (option:
{ {
assertion = cfg."${option}" != null -> builtins.substring 0 1 cfg."${option}" == "/"; assertion = cfg."${option}" != null -> builtins.substring 0 1 cfg."${option}" == "/";

View file

@ -75,7 +75,7 @@ let
in imap1 mkHead cfg.xrandrHeads; in imap1 mkHead cfg.xrandrHeads;
xrandrDeviceSection = let xrandrDeviceSection = let
monitors = foreach xrandrHeads (h: '' monitors = flip map xrandrHeads (h: ''
Option "monitor-${h.config.output}" "${h.name}" Option "monitor-${h.config.output}" "${h.name}"
''); '');
# First option is indented through the space in the config but any # First option is indented through the space in the config but any

View file

@ -684,7 +684,7 @@ in
assertion = if args.efiSysMountPoint == null then true else hasPrefix "/" args.efiSysMountPoint; assertion = if args.efiSysMountPoint == null then true else hasPrefix "/" args.efiSysMountPoint;
message = "EFI paths must be absolute, not ${args.efiSysMountPoint}"; message = "EFI paths must be absolute, not ${args.efiSysMountPoint}";
} }
] ++ foreach args.devices (device: { ] ++ flip map args.devices (device: {
assertion = device == "nodev" || hasPrefix "/" device; assertion = device == "nodev" || hasPrefix "/" device;
message = "GRUB devices must be absolute paths, not ${device} in ${args.path}"; message = "GRUB devices must be absolute paths, not ${device} in ${args.path}";
})); }));

View file

@ -74,7 +74,7 @@ in
enable = true; enable = true;
networks."99-main" = genericNetwork mkDefault; networks."99-main" = genericNetwork mkDefault;
} }
(mkMerge (foreach interfaces (i: { (mkMerge (flip map interfaces (i: {
netdevs = mkIf i.virtual ({ netdevs = mkIf i.virtual ({
"40-${i.name}" = { "40-${i.name}" = {
netdevConfig = { netdevConfig = {
@ -90,7 +90,7 @@ in
name = mkDefault i.name; name = mkDefault i.name;
DHCP = mkForce (dhcpStr DHCP = mkForce (dhcpStr
(if i.useDHCP != null then i.useDHCP else cfg.useDHCP && interfaceIps i == [ ])); (if i.useDHCP != null then i.useDHCP else cfg.useDHCP && interfaceIps i == [ ]));
address = foreach (interfaceIps i) address = flip map (interfaceIps i)
(ip: "${ip.address}/${toString ip.prefixLength}"); (ip: "${ip.address}/${toString ip.prefixLength}");
networkConfig.IPv6PrivacyExtensions = "kernel"; networkConfig.IPv6PrivacyExtensions = "kernel";
} ]; } ];
@ -102,7 +102,7 @@ in
Kind = "bridge"; Kind = "bridge";
}; };
}; };
networks = listToAttrs (foreach bridge.interfaces (bi: networks = listToAttrs (flip map bridge.interfaces (bi:
nameValuePair "40-${bi}" (mkMerge [ (genericNetwork (mkOverride 999)) { nameValuePair "40-${bi}" (mkMerge [ (genericNetwork (mkOverride 999)) {
DHCP = mkOverride 0 (dhcpStr false); DHCP = mkOverride 0 (dhcpStr false);
networkConfig.Bridge = name; networkConfig.Bridge = name;
@ -173,7 +173,7 @@ in
}; };
networks = listToAttrs (foreach bond.interfaces (bi: networks = listToAttrs (flip map bond.interfaces (bi:
nameValuePair "40-${bi}" (mkMerge [ (genericNetwork (mkOverride 999)) { nameValuePair "40-${bi}" (mkMerge [ (genericNetwork (mkOverride 999)) {
DHCP = mkOverride 0 (dhcpStr false); DHCP = mkOverride 0 (dhcpStr false);
networkConfig.Bond = name; networkConfig.Bond = name;

View file

@ -926,7 +926,7 @@ in
warnings = concatMap (i: i.warnings) interfaces; warnings = concatMap (i: i.warnings) interfaces;
assertions = assertions =
(foreach interfaces (i: { (flip map interfaces (i: {
# With the linux kernel, interface name length is limited by IFNAMSIZ # With the linux kernel, interface name length is limited by IFNAMSIZ
# to 16 bytes, including the trailing null byte. # to 16 bytes, including the trailing null byte.
# See include/linux/if.h in the kernel sources # See include/linux/if.h in the kernel sources
@ -934,12 +934,12 @@ in
message = '' message = ''
The name of networking.interfaces."${i.name}" is too long, it needs to be less than 16 characters. The name of networking.interfaces."${i.name}" is too long, it needs to be less than 16 characters.
''; '';
})) ++ (foreach slaveIfs (i: { })) ++ (flip map slaveIfs (i: {
assertion = i.ipv4.addresses == [ ] && i.ipv6.addresses == [ ]; assertion = i.ipv4.addresses == [ ] && i.ipv6.addresses == [ ];
message = '' message = ''
The networking.interfaces."${i.name}" must not have any defined ips when it is a slave. The networking.interfaces."${i.name}" must not have any defined ips when it is a slave.
''; '';
})) ++ (foreach interfaces (i: { })) ++ (flip map interfaces (i: {
assertion = i.preferTempAddress -> cfg.enableIPv6; assertion = i.preferTempAddress -> cfg.enableIPv6;
message = '' message = ''
Temporary addresses are only needed when IPv6 is enabled. Temporary addresses are only needed when IPv6 is enabled.
@ -967,8 +967,8 @@ in
"net.ipv6.conf.default.disable_ipv6" = mkDefault (!cfg.enableIPv6); "net.ipv6.conf.default.disable_ipv6" = mkDefault (!cfg.enableIPv6);
"net.ipv6.conf.all.forwarding" = mkDefault (any (i: i.proxyARP) interfaces); "net.ipv6.conf.all.forwarding" = mkDefault (any (i: i.proxyARP) interfaces);
} // listToAttrs (flip concatMap (filter (i: i.proxyARP) interfaces) } // listToAttrs (flip concatMap (filter (i: i.proxyARP) interfaces)
(i: foreach [ "4" "6" ] (v: nameValuePair "net.ipv${v}.conf.${i.name}.proxy_arp" true))) (i: flip map [ "4" "6" ] (v: nameValuePair "net.ipv${v}.conf.${i.name}.proxy_arp" true)))
// listToAttrs (foreach (filter (i: i.preferTempAddress) interfaces) // listToAttrs (flip map (filter (i: i.preferTempAddress) interfaces)
(i: nameValuePair "net.ipv6.conf.${i.name}.use_tempaddr" 2)); (i: nameValuePair "net.ipv6.conf.${i.name}.use_tempaddr" 2));
# Capabilities won't work unless we have at-least a 4.3 Linux # Capabilities won't work unless we have at-least a 4.3 Linux
@ -1051,7 +1051,7 @@ in
${cfg.localCommands} ${cfg.localCommands}
''; '';
}; };
} // (listToAttrs (foreach interfaces (i: } // (listToAttrs (flip map interfaces (i:
let let
deviceDependency = if (config.boot.isContainer || i.name == "lo") deviceDependency = if (config.boot.isContainer || i.name == "lo")
then [] then []

View file

@ -21,7 +21,7 @@ let
useNetworkd = networkd; useNetworkd = networkd;
firewall.checkReversePath = true; firewall.checkReversePath = true;
firewall.allowedUDPPorts = [ 547 ]; firewall.allowedUDPPorts = [ 547 ];
interfaces = mkOverride 0 (listToAttrs (foreach vlanIfs (n: interfaces = mkOverride 0 (listToAttrs (flip map vlanIfs (n:
nameValuePair "eth${toString n}" { nameValuePair "eth${toString n}" {
ipv4.addresses = [ { address = "192.168.${toString n}.1"; prefixLength = 24; } ]; ipv4.addresses = [ { address = "192.168.${toString n}.1"; prefixLength = 24; } ];
ipv6.addresses = [ { address = "fd00:1234:5678:${toString n}::1"; prefixLength = 64; } ]; ipv6.addresses = [ { address = "fd00:1234:5678:${toString n}::1"; prefixLength = 64; } ];

View file

@ -54,7 +54,7 @@ let
init = let init = let
init = builtins.replaceStrings [ "\n" ] [ ";" ] (config.init or ""); init = builtins.replaceStrings [ "\n" ] [ ";" ] (config.init or "");
mkScript = drv: lib.foreach drv.scripts (script: "/script load ${drv}/share/${script}"); mkScript = drv: lib.flip map drv.scripts (script: "/script load ${drv}/share/${script}");
scripts = builtins.concatStringsSep ";" (lib.foldl (scripts: drv: scripts ++ mkScript drv) scripts = builtins.concatStringsSep ";" (lib.foldl (scripts: drv: scripts ++ mkScript drv)
[ ] (config.scripts or [])); [ ] (config.scripts or []));

View file

@ -58,7 +58,7 @@ let
versions = [ "13.8.0" "13.9.0" "13.9.1" ]; versions = [ "13.8.0" "13.9.0" "13.9.1" ];
in in
lib.listToAttrs lib.listToAttrs
(lib.foreach versions (lib.flip map versions
(v: lib.nameValuePair v (throw "Unsupported citrix_receiver version: ${v}"))); (v: lib.nameValuePair v (throw "Unsupported citrix_receiver version: ${v}")));
in in
deprecatedVersions // supportedVersions; deprecatedVersions // supportedVersions;

View file

@ -59,7 +59,7 @@ let
versions = [ ]; versions = [ ];
in in
lib.listToAttrs lib.listToAttrs
(lib.foreach versions (lib.flip map versions
(v: lib.nameValuePair v (throw "Unsupported citrix_workspace version: ${v}"))); (v: lib.nameValuePair v (throw "Unsupported citrix_workspace version: ${v}")));
in in
deprecatedVersions // supportedVersions; deprecatedVersions // supportedVersions;

View file

@ -4,7 +4,7 @@
let let
hunspellDirs = with lib; makeSearchPath ":" (flatten (foreach langs (lang: [ hunspellDirs = with lib; makeSearchPath ":" (flatten (flip map langs (lang: [
"${hunspellDicts.${lang}}/share/hunspell" "${hunspellDicts.${lang}}/share/hunspell"
"${hunspellDicts.${lang}}/share/myspell" "${hunspellDicts.${lang}}/share/myspell"
"${hunspellDicts.${lang}}/share/myspell/dicts" "${hunspellDicts.${lang}}/share/myspell/dicts"