[WIP] +RFC fixing arguments parsing and documentation for nix-build and nix-shell #2346
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
nix-build
andnix-shell
are both implemented in the same multi-call binary.The current implementation for arguments parsing makes them share arguments. This can lead to surprising behaviour (or lack thereof) when accidentally using a non-shared parameter.
Abridged list of nonsensical invocations:
nix-build --command "foo" ./release.nix
nix-build --impure ./release.nix -A build.x86_64-linux
nix-shell --out-link "foo" ./shell.nix
There are a couple more that could be added.
This PR intends to fix the behaviour by segregating the arguments parsing using an
if
conditional. That is, unless a better method is suggested.Additionally, this PR adds the missing documentation for a couple of options, since while checking for the "owner" of the parameters, I realized that a couple options weren't documented.
Expectations
I am expecting a bit of push-back from "simply removing" the options. That is, it technically breaks backwards-compatibility with (wrong) usage of the 2.x series for nix-build and nix-shell. This has to be kept in mind.
If it is judged better to keep the non-sensical options, it may be preferred to keep them segregated in their respective binaries, turned into no-ops in the other and documented as such.
RFC stdin
I find the
-
(stdin) behaviour surprising with regards tonix-shell
.nix-shell ./shell.nix
!=echo 'import ./shell.nix' | nix-shell -
As for
nix-build
it seems the behaviour is fine.I am probably overlooking something with the semantics of it. Though, the way it's implemented it may be better to drop this flag in
nix-shell
? The only documentation for-
as standard input is for nix-instantiate, and there are no mention of it in neither thenix-build
nor thenix-shell
manuals. (They mentionnix-instantiate.
only for--arg | --attr | -A
.I may split this PR into a documentation-only one that can be fast-tracked. I may also split this PR furthermore while it's WIP.
Furthermore, this will (still a WIP) try to address #1982 and #2208 by actually implementing the flag.