Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix eval doesn't quote reserved keys #7656

Open
aameen-tulip opened this issue Jan 22, 2023 · 3 comments
Open

nix eval doesn't quote reserved keys #7656

aameen-tulip opened this issue Jan 22, 2023 · 3 comments
Labels

Comments

@aameen-tulip
Copy link
Contributor

aameen-tulip commented Jan 22, 2023

Describe the bug

Reserved keywords aren't quoted when printing attrsets with nix eval.

Steps To Reproduce

nix eval -f <( nix eval --expr '{ "assert" = 1; }'; );

Expected behavior

Effectively

nix eval ... \
  |sed 's/ \(assert\|with\|let\|in\(herit\)\?\|import\|or\|rec\) =/ "\1" =/';

nix-env --version output

This effects all releases through 2.13.0.

Additional context

I plan to fix and PR this issue.

@edolstra
Copy link
Member

While this would be nice, it's important to note that the output of nix eval is not guaranteed to be a valid Nix expression. For unambiguous machine-readable output, it's better to use --json.

@balsoft
Copy link
Member

balsoft commented Mar 22, 2023

While this would be nice, it's important to note that the output of nix eval is not guaranteed to be a valid Nix expression.

Is this documented somewhere?

The manpage says:

· By default, the evaluation result is printed as a Nix expression.

I would expect "a Nix expression" to mean "a valid Nix expression".

@aameen-tulip
Copy link
Contributor Author

aameen-tulip commented Mar 26, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants