Skip to content

Comments

Printer followup#9755

Merged
roberth merged 2 commits intoNixOS:masterfrom
9999years:printer-followup
Jan 16, 2024
Merged

Printer followup#9755
roberth merged 2 commits intoNixOS:masterfrom
9999years:printer-followup

Conversation

@9999years
Copy link
Contributor

Follow-up PR to address post-merge comments in #9606.

> This option produces ambiguous output which is not suitable for machine
> consumption. For example, these two Nix expressions print the same result
> despite having different types:
> This option produces output which can be parsed as a Nix expression which
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> This option produces output which can be parsed as a Nix expression which
> This option may produce output which can be understood as a Nix expression which

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that the output includes valid Nix syntax that does not parse as the value it's standing in for. It's specifically about the parsing. Humans will be able to look at <CODE> and understand it's a placeholder through context clues, machines will not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it would be wrong to assume that you can obtain the value from the output somehow if you are not using --strict.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it doesn't output (general) expressions, no machine will be programmed to parse it as expressions.

The motivation for my suggestion is as follows:

  • Parsing by a human is better described as understanding.
  • may is only there because the output may also be unambiguous - such as when passing --strict.

I did make a mistake though. (also "to be" is a bit simpler)

Suggested change
> This option produces output which can be parsed as a Nix expression which
> This option may produce output which can be misunderstood to be a Nix expression which

Apart from this suggestion, it'd be helpful to mention --strict as a possible solution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it doesn't output (general) expressions, no machine will be programmed to parse it as expressions.

This fails to consider machines that are bad :)
Imagine for a minute that someone calls nix-instantiate, likes the output, then immediately integrates it without thinking whatsoever.

This is a reason we need to make this obviously not for machine consumption. Perhaps we should print a warning to stderr if stdout is a pipe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--strict still includes «repeated» and «potential infinite recursion».

Because it doesn't output (general) expressions, no machine will be programmed to parse it as expressions.

This is a currently undocumented assumption.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it doesn't output (general) expressions, no machine will be programmed to parse it as expressions.

This is a currently undocumented assumption.

It is a personal assumption of mine, and I don't think it's relevant enough to document.

Nonetheless, if you think the warning or any other docs are still insufficient, feel free to open another PR. (And/or discuss here, etc)

Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good change, and while could discuss more, that'd be at the cost of higher impact changes we wouldn't be making.

Thank you for following up!

@roberth roberth merged commit 51f524c into NixOS:master Jan 16, 2024
tebowy pushed a commit to tebowy/nix that referenced this pull request Jul 11, 2024
Printer followup

(cherry picked from commit 51f524c)
Change-Id: I29214cc86c5e846cbcfec382022293a70011b316
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants