mirror of
https://github.com/numtide/flake-utils.git
synced 2025-03-14 20:56:50 +00:00
lib: eachSystem: inline single-use local variables
Inline single-use local variables to minimize cognitive load while reading the code, unless they cache computational results.
This commit is contained in:
parent
274ed073aa
commit
ce5c962a8c
1 changed files with 27 additions and 26 deletions
17
lib.nix
17
lib.nix
|
@ -29,24 +29,25 @@ let
|
|||
# Builds a map from <attr>=value to <attr>.<system>=value for each system.
|
||||
eachSystem =
|
||||
systems: f:
|
||||
let
|
||||
builtins.foldl'
|
||||
(
|
||||
# Merge outputs for each system.
|
||||
op =
|
||||
attrs: system:
|
||||
let
|
||||
ret = f system;
|
||||
op =
|
||||
in
|
||||
builtins.foldl' (
|
||||
attrs: key:
|
||||
attrs
|
||||
// {
|
||||
${key} = (attrs.${key} or { }) // {
|
||||
${system} = ret.${key};
|
||||
};
|
||||
};
|
||||
in
|
||||
builtins.foldl' op attrs (builtins.attrNames ret);
|
||||
in
|
||||
builtins.foldl' op { } (
|
||||
}
|
||||
) attrs (builtins.attrNames ret)
|
||||
)
|
||||
{ }
|
||||
(
|
||||
systems
|
||||
++
|
||||
# Add the current system if the --impure flag is used.
|
||||
|
|
Loading…
Add table
Reference in a new issue