nix build: print built derivation paths (cachix support/nix-build compatibility)#2622
nix build: print built derivation paths (cachix support/nix-build compatibility)#2622Mic92 wants to merge 1 commit intoNixOS:masterfrom
Conversation
Getting the build path name after a build is a common use case not supported by nix build yet. This is for example used in shell scripts like this: $(nix-build)/foo Cachix even built a business model around it: nix-build | cachix
makefu
left a comment
There was a problem hiding this comment.
Tested the patch, looks like exactly what i am missing right now with nix build:
$ nix build nixUnstable nix -f '<nixpkgs>' --no-link
/nix/store/8ag4fs10ph11y1m9lar3y0spwjwbd9dp-nix-2.2pre6526_9f99d624
/nix/store/6kf0zrv27k47z47d315p51p1q8s7bdvj-nix-2.1.3|
Ping! Any chance this will be merged at some point? |
|
I try to remind @edolstra next Thursday. |
|
ping @edolstra |
|
I think it would be better to add a |
|
I think a |
|
Would be really nice to get this one in. I think getting output of what one wanted to build is useful and it's already consumable as it's newline separated. A somewhat different approach with similar goal is at #2423 |
|
Oh there's three PRs, also #1647 |
|
I don't think the new CLI should copy every ad hoc misfeature of the old user interface. |
|
How is getting the result of a build a misfeature? Edit: I found this incredibly ugly workaround: |
|
@edolstra it would be interesting to hear why it's a misfeature. I feel I'm guessing that it's because it prints store paths by default? Maybe there would be a flag to print final store paths (newline delimited) with something like |
|
Quite sad to see this closed. |
|
Indeed. It would have been nice to have this to build flakes with cachix. |
|
May I ask what was the reason for closing this? |
|
It was reject by upstream. |
|
Right, but what was the reason behind the rejection? Is there an alternative proposal? Thanks! |
|
Apparently json output. Which does not solve my use case so. I cannot do |
|
That’s a shame. |
|
@edolstra is there any reason not to add this under a flag? This would be complimentary to the build hook, except that people can work with outputs via shell piping instead of the complicated setup. |
|
Throwing this here from #1930 as a stop-gap although also disappointed to see the option of having the OUTPUT printed is gone. |
|
It looks like $ nix build nixos#hello --json | jq -r 'map(.outputs.out) | first'
/nix/store/jmmw0d3nmklwafcwylvrjb9v69wrbcxf-hello-2.10I think cachix or other tools that commonly use this feature should handle json output automatically or with a flag, which would make it simpler to handle multiple-output derivations as well, although currently not all outputs are printed in --json? This looks like separate bug to me. $ nix build nixos#jq --json | jq
[
{
"drvPath": "/nix/store/v8yam49crkivirdr3na81p8zr8mv27p9-jq-1.6.drv",
"outputs": {
"bin": "/nix/store/w6n9d6wvkhr68xi47n7i2dw1hkhfwhx0-jq-1.6-bin"
}
}
]This produces the links "result result-bin result-dev result-doc result-lib result-man" but none are printed in the output. |
|
Bummed to not see this being implemented, and not get to understand the reasoning behind the rejection. Here's my workaround: |
Getting the build path name after a build is a common use case
not supported by nix build yet.
This is for example used in shell scripts like this: $(nix-build)/foo
Cachix even built a business model around it: nix-build | cachix
I have tested that locally and run the tests.
Some tests seem to fail without a sandbox but not due to my change as far as I can tell.