fix(users/Profpatsch/netencode/gen/dwim): support derivations

We forgot the special casing of derivations; if we recurse into a
derivation like we’d recurse into an attrset, it always ends in tears,
so dwim will just print the derivation path instead, which is usually
what you want anyway.

Change-Id: Ieed1b68dfcf8f2925ee3a75ae4f460fa5081da28
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2526
Reviewed-by: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
This commit is contained in:
Profpatsch 2021-02-13 20:54:57 +01:00
parent 18e6db0f21
commit 5a08316a3c

View file

@ -36,11 +36,15 @@ let
"bool" = n1;
"int" = i6;
"string" = text;
"set" = attrs: record (lib.mapAttrsToList
(k: v: {
key = k;
val = dwim v;
}) attrs);
"set" = attrs:
# it could be a derivation, then just return the path
if attrs.type or "" == "derivation" then text "${attrs}"
else
record (lib.mapAttrsToList
(k: v: {
key = k;
val = dwim v;
}) attrs);
"list" = l: list (map dwim l);
};
in match.${builtins.typeOf val} val;