From 56156c6405af53673c0e067d2dbf1201997ca4fc Mon Sep 17 00:00:00 2001 From: ilkecan Date: Wed, 7 Sep 2022 00:56:06 +0000 Subject: [PATCH] each{,Default}SystemMap: support optional `self` parameter Related: #78 --- default.nix | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/default.nix b/default.nix index 8cf4892..c704425 100644 --- a/default.nix +++ b/default.nix @@ -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 @@ -155,7 +149,8 @@ let eachDefaultSystemMap = eachSystemMap defaultSystems; # Builds a map from =value to . = 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. @@ -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