|
26 | 26 | # eachSystem using defaultSystems |
27 | 27 | eachDefaultSystem = eachSystem defaultSystems; |
28 | 28 |
|
29 | | - # Builds a map from <attr>=value to <attr>.<system>=value for each system |
30 | | - # |
31 | | - eachSystem = systems: f: |
| 29 | + # eachSystemPassThrough using defaultSystems |
| 30 | + eachDefaultSystemPassThrough = eachSystemPassThrough defaultSystems; |
| 31 | + |
| 32 | + # Builds a map from <attr>=value to <attr>.<system>=value for each system. |
| 33 | + eachSystem = eachSystemOp ( |
| 34 | + # Merge outputs for each system. |
| 35 | + f: attrs: system: |
32 | 36 | let |
33 | | - # Merge together the outputs for all systems. |
34 | | - op = attrs: system: |
35 | | - let |
36 | | - ret = f system; |
37 | | - op = attrs: key: attrs // |
38 | | - { |
39 | | - ${key} = (attrs.${key} or { }) |
40 | | - // { ${system} = ret.${key}; }; |
41 | | - } |
42 | | - ; |
43 | | - in |
44 | | - builtins.foldl' op attrs (builtins.attrNames ret); |
| 37 | + ret = f system; |
45 | 38 | in |
46 | | - builtins.foldl' op { } |
47 | | - (systems |
48 | | - ++ # add the current system if --impure is used |
49 | | - (if builtins?currentSystem then |
50 | | - if builtins.elem builtins.currentSystem systems |
51 | | - then [] |
52 | | - else [ builtins.currentSystem ] |
53 | | - else |
54 | | - [])) |
55 | | - ; |
| 39 | + builtins.foldl' ( |
| 40 | + attrs: key: |
| 41 | + attrs |
| 42 | + // { |
| 43 | + ${key} = (attrs.${key} or { }) // { |
| 44 | + ${system} = ret.${key}; |
| 45 | + }; |
| 46 | + } |
| 47 | + ) attrs (builtins.attrNames ret) |
| 48 | + ); |
| 49 | + |
| 50 | + # Applies a merge operation accross systems. |
| 51 | + eachSystemOp = |
| 52 | + op: systems: f: |
| 53 | + builtins.foldl' (op f) { } ( |
| 54 | + if |
| 55 | + !builtins ? currentSystem || builtins.elem builtins.currentSystem systems |
| 56 | + then |
| 57 | + systems |
| 58 | + else |
| 59 | + # Add the current system if the --impure flag is used. |
| 60 | + systems ++ [ builtins.currentSystem ] |
| 61 | + ); |
| 62 | + |
| 63 | + # Merely provides the system argument to the function. |
| 64 | + # |
| 65 | + # Unlike eachSystem, this function does not inject the `${system}` key. |
| 66 | + eachSystemPassThrough = eachSystemOp ( |
| 67 | + f: attrs: system: |
| 68 | + attrs // (f system) |
| 69 | + ); |
56 | 70 |
|
57 | 71 | # eachSystemMap using defaultSystems |
58 | 72 | eachDefaultSystemMap = eachSystemMap defaultSystems; |
|
198 | 212 | check-utils |
199 | 213 | defaultSystems |
200 | 214 | eachDefaultSystem |
201 | | - eachSystem |
202 | 215 | eachDefaultSystemMap |
| 216 | + eachDefaultSystemPassThrough |
| 217 | + eachSystem |
203 | 218 | eachSystemMap |
| 219 | + eachSystemPassThrough |
204 | 220 | filterPackages |
205 | 221 | flattenTree |
206 | 222 | meld |
|
0 commit comments