Skip to content

Commit f651edc

Browse files
committed
each{,Default}SystemMap: accept binary functions
Related: #78
1 parent 19d1236 commit f651edc

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

default.nix

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,7 @@ let
125125
# Merge together the outputs for all systems.
126126
op = attrs: system:
127127
let
128-
ret =
129-
let
130-
retOrFunc = f system;
131-
in
132-
if builtins.isFunction retOrFunc
133-
then retOrFunc ret
134-
else retOrFunc;
128+
ret = maybeFix (f system);
135129

136130
op = attrs: key:
137131
let
@@ -155,7 +149,8 @@ let
155149
eachDefaultSystemMap = eachSystemMap defaultSystems;
156150

157151
# Builds a map from <attr>=value to <system>.<attr> = value.
158-
eachSystemMap = systems: f: builtins.listToAttrs (builtins.map (system: { name = system; value = f system; }) systems);
152+
eachSystemMap = systems: f:
153+
builtins.listToAttrs (builtins.map (system: { name = system; value = maybeFix (f system); }) systems);
159154

160155
# Nix flakes insists on having a flat attribute set of derivations in
161156
# various places like the `packages` and `checks` attributes.
@@ -232,5 +227,11 @@ let
232227
system
233228
;
234229
};
230+
231+
maybeFix = arg:
232+
let
233+
fix = f: let x = f x; in x;
234+
in
235+
if builtins.isFunction arg then fix arg else arg;
235236
in
236237
lib

0 commit comments

Comments
 (0)