Skip to content

Commit cdb61a0

Browse files
committed
each{,Default}SystemMap: accept binary functions
related: #78
1 parent 78b3158 commit cdb61a0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib.nix

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ let
3333
# Merge together the outputs for all systems.
3434
op = attrs: system:
3535
let
36-
ret =
37-
let
38-
retOrFunc = f system;
39-
in
40-
if builtins.isFunction retOrFunc
41-
then retOrFunc ret
42-
else retOrFunc;
36+
ret = maybeFix (f system);
4337
op = attrs: key: attrs //
4438
{
4539
${key} = (attrs.${key} or { })
@@ -56,7 +50,8 @@ let
5650
eachDefaultSystemMap = eachSystemMap defaultSystems;
5751

5852
# Builds a map from <attr>=value to <system>.<attr> = value.
59-
eachSystemMap = systems: f: builtins.listToAttrs (builtins.map (system: { name = system; value = f system; }) systems);
53+
eachSystemMap = systems: f:
54+
builtins.listToAttrs (builtins.map (system: { name = system; value = maybeFix (f system); }) systems);
6055

6156
# Nix flakes insists on having a flat attribute set of derivations in
6257
# various places like the `packages` and `checks` attributes.
@@ -207,5 +202,11 @@ let
207202
system
208203
;
209204
};
205+
206+
maybeFix = arg:
207+
let
208+
fix = f: let x = f x; in x;
209+
in
210+
if builtins.isFunction arg then fix arg else arg;
210211
in
211212
lib

0 commit comments

Comments
 (0)