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

cli: read "paths" from stdin for commands that take them #7437

Closed
nrdxp opened this issue Dec 9, 2022 · 1 comment · Fixed by #7594
Closed

cli: read "paths" from stdin for commands that take them #7437

nrdxp opened this issue Dec 9, 2022 · 1 comment · Fixed by #7594
Labels
feature Feature request or proposal

Comments

@nrdxp
Copy link

nrdxp commented Dec 9, 2022

Is your feature request related to a problem? Please describe.
If the user wants to pass a list of paths to say nix path-info or nix-build, they run the risk of recieving a "too many args" OS error.

Since passing derivations around can be very efficient when handled in batches it would be nice not to have a cap on this. The current workaround is xargs, which I guess is fine, but not exactly intuitive or necessarily efficient.

Describe the solution you'd like
I could see it two ways, if the command recieves a non-empty stdin, simply add it to whatever list of paths already exist in the cli, or we could make it explicit and require something like nix-build - to specify reading paths from stdin.

Describe alternatives you've considered
Basically just keep using xargs, but even if the arg limit is not an issue, shell pipelines are far more readable than nested process substititions, e.g:

$ which svn | nix-store -qR | nix-store --realize
# is nicer than
$ nix-build $(nix-store -qR $(which svn))

Additional context
Hit this a couple of times when trying to ensure the entire build closure is cached by parsing the results of a --dry-run: divnix/std-action/run/build.sh#14

@nrdxp nrdxp added the feature Feature request or proposal label Dec 9, 2022
@nrdxp
Copy link
Author

nrdxp commented Dec 15, 2022

Just found nix-store --export and it's probably the most important usecase for this, since using xargs wouldn't wok in this case to serialise a potentially large list of derivations at once to another store.

nrdxp added a commit to nrdxp/nix that referenced this issue Jan 12, 2023
Resolves NixOS#7437

If paths are also passed on the cli they will be combined with the ones
from standard input.
nrdxp added a commit to nrdxp/nix that referenced this issue Jan 12, 2023
Resolves NixOS#7437 for new `nix` commands only.

If paths are also passed on the cli they will be combined with the ones
from standard input.
nrdxp added a commit to nrdxp/nix that referenced this issue Jan 12, 2023
nrdxp added a commit to nrdxp/nix that referenced this issue Jan 12, 2023
Resolves NixOS#7437 for new `nix` commands only.

If paths are also passed on the cli they will be combined with the ones
from standard input.
nrdxp added a commit to nrdxp/nix that referenced this issue Jan 12, 2023
nrdxp added a commit to nrdxp/nix that referenced this issue Jan 12, 2023
Resolves NixOS#7437 for new `nix` commands only by adding a `--stdin` flag.

If paths are also passed on the cli they will be combined with the ones
from standard input.
nrdxp added a commit to nrdxp/nix that referenced this issue Jan 12, 2023
Resolves NixOS#7437 for new `nix-store` by adding a `--stdin` flag.
nrdxp added a commit to nrdxp/nix that referenced this issue Jan 12, 2023
Resolves NixOS#7437 for new `nix` commands only by adding a `--stdin` flag.

If paths are also passed on the cli they will be combined with the ones
from standard input.
nrdxp added a commit to nrdxp/nix that referenced this issue Jan 12, 2023
Resolves NixOS#7437 for new `nix-store` by adding a `--stdin` flag.
nrdxp added a commit to nrdxp/nix that referenced this issue Jan 13, 2023
Resolves NixOS#7437 for new `nix-store` by adding a `--stdin` flag.
nrdxp added a commit to nrdxp/nix that referenced this issue Feb 11, 2023
Resolves NixOS#7437 for new `nix` commands only by adding a `--stdin` flag.

If paths are also passed on the cli they will be combined with the ones
from standard input.
nrdxp added a commit to nrdxp/nix that referenced this issue Feb 11, 2023
Resolves NixOS#7437 for new `nix-store` by adding a `--stdin` flag.
nrdxp added a commit to nrdxp/nix that referenced this issue Feb 28, 2023
Resolves NixOS#7437 for new `nix` commands only by adding a `--stdin` flag.

If paths are also passed on the cli they will be combined with the ones
from standard input.
nrdxp added a commit to nrdxp/nix that referenced this issue Feb 28, 2023
Resolves NixOS#7437 for new `nix-store` by adding a `--stdin` flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant