From a353b2f4b200df22dcd420f99ee13d226f566f0e Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 26 May 2025 13:54:04 -0400 Subject: [PATCH] Test hacky way of making structured attrs --- tests/functional/structured-attrs.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/functional/structured-attrs.sh b/tests/functional/structured-attrs.sh index 64d136e99..fe9bcc0ee 100755 --- a/tests/functional/structured-attrs.sh +++ b/tests/functional/structured-attrs.sh @@ -40,3 +40,11 @@ jsonOut="$(nix print-dev-env -f structured-attrs-shell.nix --json)" test "$(<<<"$jsonOut" jq '.structuredAttrs|keys|.[]' -r)" = "$(printf ".attrs.json\n.attrs.sh")" test "$(<<<"$jsonOut" jq '.variables.outputs.value.out' -r)" = "$(<<<"$jsonOut" jq '.structuredAttrs.".attrs.json"' -r | jq -r '.outputs.out')" + +# Hacky way of making structured attrs. We should preserve for now for back compat, but also deprecate. + +hackyExpr='derivation { name = "a"; system = "foo"; builder = "/bin/sh"; __json = builtins.toJSON { a = 1; }; }' + +# Check it works with the expected structured attrs +hacky=$(nix-instantiate --expr "$hackyExpr") +nix derivation show "$hacky" | jq --exit-status '."'"$hacky"'".env.__json | fromjson | . == {"a": 1}'