-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 2.0: Print out path to stdout with nix build #1930
Comments
Trying to script around this doesn't seem viable because of GC roots. You can't isolate what the outputs of |
Technically speaking I think the pattern It's not a problem if you can be sure a GC isn't running concurrently or something, but just a thought. Couldn't the "moving them where the user wanted" be done with |
@dtzWill This would still leave dangling symlinks in your gc roots (EDIT: from the symlinks in the isolated temp directory). Again, not technically a problem, but definitely undesirable to have a command be guaranteed to leave behind unwanted symlinks. |
I'm with @ElvishJerricco; I used the stdout a lot. Even "nix build --no-link" does not output anything, so no reference at all to the outcome. If someone wants to make the $(nix-build ) thing GC-safe, that can use a mktemp as symlink and then delete it. Annoying to impose this, though. |
@viric I did figure out how to make such a thing, but it uses https://gist.github.com/ElvishJerricco/e8193a5b4734877bc492e870625bc92f |
Re GC-safety: #1938 |
@shlevy Thanks for that. To be clear though, I don't think a wrapper script is a good solution to this issue. It'd be far easier if Maybe paths should only be output if |
@ElvishJerricco This doesn't address the output path issue, just the GC safety issue that you have even with |
sry if that's a bit but offtrack but what to do with multiple outputs ? I wished for nix-build to display all the built output paths but it only displays the first |
@ElvishJerricco try building "foo.all" instead of "foo"! I use this often :). |
Printing a link to stdout is very useful for simple (and maybe even single-use) interactive scripts where it is assumed that the user knows there is no GC running… By the way, |
Related: #1647 |
What about |
Of course, it'd be good to be able to do both... |
This also prevents |
@michaelpj you could place out links in a tmp directory and readlink them. |
If you only care about getting stuff on stdout, and not the out links, nbuild() {
nix build --no-link "$@"
nix path-info "$@"
} Of course this evaluates expressions twice as many times.... |
It seems a bit weird to link it to the out-link flag - they seem orthogonal to me. |
Theoretically orthogonal, but they are two possible answers to «how do you want to get the result», so wanting a single one (either of the two) is way more typical than both or neither |
See #2622 |
Add --json option to nix build to allow machine readable output on stdout with all built derivations Fixes NixOS#1930
Add --json option to nix build to allow machine readable output on stdout with all built derivations Fixes NixOS#1930
Add --json option to nix build to allow machine readable output on stdout with all built derivations Fixes NixOS#1930
Add --json option to nix build to allow machine readable output on stdout with all built derivations Fixes NixOS#1930
This served as an extremely useful tool with
nix-build
in conjunction with--no-out-link
. Two extremely common use cases:$(nix-build ...)/bin/foo
nix-store -qR $(nix-build ...)
It's just nice to interpolate the path without having to copy paste it, and to make sure that the command you're running definitely has the latest version of the nix build output. It would be nice to have this back with
nix build
.The text was updated successfully, but these errors were encountered: