Skip to content

Commit

Permalink
each{,Default}SystemMap: support optional self parameter
Browse files Browse the repository at this point in the history
Related: numtide#78
  • Loading branch information
ilkecan committed Sep 7, 2022
1 parent df6dacb commit a1f2e27
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,7 @@ let
# Merge together the outputs for all systems.
op = attrs: system:
let
ret =
let
retOrFunc = f system;
in
if builtins.isFunction retOrFunc
then retOrFunc ret
else retOrFunc;
ret = maybeFix (f system);

op = attrs: key:
let
Expand All @@ -155,7 +149,8 @@ let
eachDefaultSystemMap = eachSystemMap defaultSystems;

# Builds a map from <attr>=value to <system>.<attr> = value.
eachSystemMap = systems: f: builtins.listToAttrs (builtins.map (system: { name = system; value = f system; }) systems);
eachSystemMap = systems: f:
builtins.listToAttrs (builtins.map (system: { name = system; value = maybeFix (f system); }) systems);

# Nix flakes insists on having a flat attribute set of derivations in
# various places like the `packages` and `checks` attributes.
Expand Down Expand Up @@ -232,5 +227,11 @@ let
system
;
};

maybeFix = arg:
let
fix = f: let x = f x; in x;
in
if builtins.isFunction arg then fix arg else arg;
in
lib

0 comments on commit a1f2e27

Please sign in to comment.