[Nix#9730] nix-instantiate --eval output is ambiguous #70

Open
opened 2024-03-16 06:44:45 +00:00 by lix-bot · 0 comments
Member

Upstream-Issue: NixOS/nix#9730

Describe the bug

nix-instantiate --eval output is ambiguous and can be misleading. nix-instantiate uses angle brackets like <CODE> to represent placeholders; this is ambiguous because <CODE> is valid Nix path syntax.

This results in the unintuitive result that nix-instantiate --parse and nix-instantiate --eval do not mirror each other or compose together. This also makes nix-instantiate --eval output unsuitable for machine consumption.

Steps To Reproduce

$ nix-instantiate --eval --expr '{ a = {}; }'
{ a = <CODE>; }
$ nix-instantiate --eval --expr '{ a = <CODE>; }'
{ a = <CODE>; }

Expected behavior

Placeholders in nix-instantiate output should not be valid/parsable Nix expressions.

If nix-instantiate's output used chevrons in the style of nix repl (e.g., «code» instead of <CODE>), then attempting to parse them as Nix expressions would fail instead of producing an unrelated expression. @edolstra cited this reasoning when changing <REPEAT> to «repeated» in nix-instantiate output in 732296ddc0.

nix-env --version output

nix-env (Nix) 2.18.1

Additional context

#8671, #8672, #9606, "Is <CODE> in nix-instantiate part of the stable API?" on NixOS discourse

Priorities

Add 👍 to issues you find important.

Upstream-Issue: https://git.lix.systems/NixOS/nix/issues/9730 **Describe the bug** `nix-instantiate --eval` output is ambiguous and can be misleading. `nix-instantiate` uses angle brackets like `<CODE>` to represent placeholders; this is ambiguous because `<CODE>` is valid Nix path syntax. This results in the unintuitive result that `nix-instantiate --parse` and `nix-instantiate --eval` do not mirror each other or compose together. This also makes `nix-instantiate --eval` output unsuitable for machine consumption. **Steps To Reproduce** ``` $ nix-instantiate --eval --expr '{ a = {}; }' { a = <CODE>; } $ nix-instantiate --eval --expr '{ a = <CODE>; }' { a = <CODE>; } ``` **Expected behavior** Placeholders in `nix-instantiate` output should not be valid/parsable Nix expressions. If `nix-instantiate`'s output used chevrons in the style of `nix repl` (e.g., `«code»` instead of `<CODE>`), then attempting to parse them as Nix expressions would fail instead of producing an unrelated expression. @edolstra cited this reasoning when changing `<REPEAT>` to `«repeated»` in `nix-instantiate` output in https://github.com/NixOS/nix/commit/732296ddc078f9cce8ffeb3131fef8898330b6ae. **`nix-env --version` output** `nix-env (Nix) 2.18.1` **Additional context** #8671, #8672, #9606, ["Is `<CODE>` in `nix-instantiate` part of the stable API?" on NixOS discourse](https://discourse.nixos.org/t/whats-nixs-stable-api-is-code-in-nix-instantiate-part-of-it/37986) **Priorities** Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
lix-bot added the
bug
imported
labels 2024-03-16 06:44:45 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#70
No description provided.