From 5a08316a3c26f6df10a62c8962b1b468ebb30290 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sat, 13 Feb 2021 20:54:57 +0100 Subject: fix(users/Profpatsch/netencode/gen/dwim): support derivations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested-by: BuildkiteCI --- users/Profpatsch/netencode/gen.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'users/Profpatsch/netencode/gen.nix') diff --git a/users/Profpatsch/netencode/gen.nix b/users/Profpatsch/netencode/gen.nix index 2d2456efeaa5..305ff7b08dd6 100644 --- a/users/Profpatsch/netencode/gen.nix +++ b/users/Profpatsch/netencode/gen.nix @@ -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; -- cgit 1.4.1