1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-22 17:01:08 +01:00

Add warning for non-JSON-object exportReferencesGraph

This will help users debug their mistakes.
This commit is contained in:
John Ericson 2025-12-09 13:02:46 -05:00
parent b398c14045
commit 1c63cf4001
2 changed files with 18 additions and 1 deletions

View file

@ -50,3 +50,16 @@ expectStderr 0 nix-instantiate --expr "$hackyExpr" --eval --strict | grepQuiet "
# Check it works with the expected structured attrs
hacky=$(nix-instantiate --expr "$hackyExpr")
nix derivation show "$hacky" | jq --exit-status '.derivations."'"$(basename "$hacky")"'".structuredAttrs | . == {"a": 1}'
# Test warning for non-object exportReferencesGraph in structured attrs
# shellcheck disable=SC2016
expectStderr 0 nix-build --expr '
with import ./config.nix;
mkDerivation {
name = "export-graph-non-object";
__structuredAttrs = true;
exportReferencesGraph = [ "foo" "bar" ];
builder = "/bin/sh";
args = ["-c" "echo foo > ${builtins.placeholder "out"}"];
}
' | grepQuiet "warning:.*exportReferencesGraph.*not a JSON object"