nix build: add --print-out-paths flag#6259
Conversation
b047df1 to
928c79f
Compare
d36e201 to
1cafd84
Compare
|
updated todo's |
1cafd84 to
29dc8a3
Compare
|
yeah, it'd be nice to not have to output json into jq 👍 |
|
From the CLI guidelines:
It was a conscious decision not to have ad-hoc, non-extensible, unstructured output on stdout in the new CLI. But I realize it's annoying to have to rely on a tool like jq... |
|
Yeah we probably shouldn't add flags for every output option under the sun, the json output is very useful. But since this was the previous behavior of Or maybe we could consider having jq style templating build in. Then you can do about anything without a 2nd tool: |
|
Github cli has a --jq option which doesn't seem to depend on jq being installed because jq isn't in the deps https://archlinux.org/packages/community/x86_64/github-cli/ |
|
I don't think adding JSON filtering to nix is necessary. |
|
I agree |
It uses a go library that re-implements jq github.com/itchyny/gojq |
0b8a9b4 to
e13cb0d
Compare
|
added a release note |
e13cb0d to
0757d76
Compare
|
any code reviews? 🙂 |
|
Not a code review (well, I looked at it but don't have anything to add), but the obligatory bikeshedding over naming: I'd prefer |
|
“ flag to print the resulting store paths”. I’m not sure what this means. What is the expectation people can rely on? (This question may also apply to the JSON output.) What will the output contain if combined with remote builders/ eval stores/substitution/symlink generated. What invariant is provided? Eg: Given identical starting stores where one does the build and the other only gets this stdout - what steps can be taken to reach the same Store state, or similar? Does (build + GC ~= substitute with stdout paths)? The common use case I presume is as a CLI ad-hoc variant of a post-build-hook. What are the semantics compared to this pseudo code: My intention is not to support or oppose, but to ensure there is consistency so we can apply it in more situations or to understand the distinctions. |
0757d76 to
5870143
Compare
> $HOME/nixgits/nix/result/bin/nix build --option builders 'ssh://eu.nixbuild.net' -j0 nixpkgsMaster#bash --print-output-paths
/nix/store/dndi916j6yxzfzzj2sma2llhrlwahq06-bash-5.1-p16
> $HOME/nixgits/nix/result/bin/nix build --option builders 'ssh://eu.nixbuild.net' -j0 /nix/store/dndi916j6yxzfzzj2sma2llhrlwahq06-bash-5.1-p16 --print-output-paths
/nix/store/dndi916j6yxzfzzj2sma2llhrlwahq06-bash-5.1-p16
> $HOME/nixgits/nix/result/bin/nix build --option builders 'ssh://eu.nixbuild.net' -j0 nixpkgsMaster#bash.dev --print-output-paths
/nix/store/lrrv3fzii19il2lsqdcb5d9mia2wxy5r-bash-5.1-p16-dev
> $HOME/nixgits/nix/result/bin/nix build nixpkgsMaster#bash --print-output-paths
/nix/store/dndi916j6yxzfzzj2sma2llhrlwahq06-bash-5.1-p16
> $HOME/nixgits/nix/result/bin/nix build /nix/store/dndi916j6yxzfzzj2sma2llhrlwahq06-bash-5.1-p16 --print-output-paths
/nix/store/dndi916j6yxzfzzj2sma2llhrlwahq06-bash-5.1-p16
> $HOME/nixgits/nix/result/bin/nix build nixpkgsMaster#bash.dev --print-output-paths
/nix/store/lrrv3fzii19il2lsqdcb5d9mia2wxy5r-bash-5.1-p16-dev |
|
there's a difference when the derivation is built for the first time / rebuilt nix-build -A bash --check
/nix/store/dndi916j6yxzfzzj2sma2llhrlwahq06-bash-5.1-p16$HOME/nixgits/nix/result/bin/nix build ".#bash" --print-output-paths --rebuild
/nix/store/lrrv3fzii19il2lsqdcb5d9mia2wxy5r-bash-5.1-p16-dev
/nix/store/s6bspl3x0s8h626vc4ikgv1h8sphlm17-bash-5.1-p16-doc
/nix/store/g0n1a3vdx64zkkprfl0y8643320bsb0a-bash-5.1-p16-info
/nix/store/ddgnym0a3nl1ggz50gg8q1cs0arzic87-bash-5.1-p16-man
/nix/store/dndi916j6yxzfzzj2sma2llhrlwahq06-bash-5.1-p16
|
|
with while with |
abab65f to
286f109
Compare
|
i rebuilt my system with (self: super: {
nixUnstable = super.nixUnstable.overrideAttrs (old: {
src = super.fetchFromGitHub {
owner = "nixos";
repo = "nix";
rev = "abab65f774169c4ebf58823af2a3c327a560deee";
sha256 = "sha256-kFsJ/WsopJIYKHBpnVGuyXlqdwcrezvvmbT2ycN89r0=";
};
});
})i then ran and both work Thank you @edolstra !! |
286f109 to
4c06e0e
Compare
|
I agree with @ncfavier that this should be renamed to |
1c1345e to
e5b49b6
Compare
|
Alternatively, maybe |
The variable inside builders is called |
|
print-out-paths sounds good to me |
tomberek
left a comment
There was a problem hiding this comment.
functions and runs as expected. Consistency makes me wonder if any other commands should respect this output format. nix copy? nix profile?
e5b49b6 to
bbbf8a0
Compare
|
resolved conflict |
has the same functionality as default nix-build $ nix-build . -A "bash" -A "bash.dev" -A "tinycc" /nix/store/4nmqxajzaf60yjribkgvj5j54x9yvr1r-bash-5.1-p12 /nix/store/c49i1ggnr5cc8gxmk9xm0cn961z104dn-bash-5.1-p12-dev /nix/store/dbapb08862ajgaax3621fz8hly9fdah3-tcc-0.9.27+date=2022-01-11 $ nix-build . -A "bash" /nix/store/4nmqxajzaf60yjribkgvj5j54x9yvr1r-bash-5.1-p12 $ $HOME/nixgits/nix/result/bin/nix build "nixpkgs#bash" "nixpkgs#bash.dev" "nixpkgs#tinycc" --print-out-paths /nix/store/4nmqxajzaf60yjribkgvj5j54x9yvr1r-bash-5.1-p12 /nix/store/c49i1ggnr5cc8gxmk9xm0cn961z104dn-bash-5.1-p12-dev /nix/store/dbapb08862ajgaax3621fz8hly9fdah3-tcc-0.9.27+date=2022-01-11 $ $HOME/nixgits/nix/result/bin/nix build "nixpkgs#bash" --print-out-paths /nix/store/4nmqxajzaf60yjribkgvj5j54x9yvr1r-bash-5.1-p12
bbbf8a0 to
51cfea8
Compare
|
conflict resolved. |
thufschmitt
left a comment
There was a problem hiding this comment.
Thanks, sorry for the long delay :)
I’ve resolved the small conflict. Waiting for #6437 to be merged so that we can have a green CI, and I’ll merge after that
|
Sorry, but can it be explained why is |
|
Because we don't want the new CLI to be spammy by default. Also, the CLI guideline is to use |
|
After years of quickly digging into just-built out paths, using in scripts, etc and seeing no problem with it. And the number of the built out paths is rarely > 5. |
|
Is there a way to do this via |
has the same functionality as default nix-build
$ nix-build . -A "bash" -A "bash.dev" -A "tinycc"
/nix/store/4nmqxajzaf60yjribkgvj5j54x9yvr1r-bash-5.1-p12
/nix/store/c49i1ggnr5cc8gxmk9xm0cn961z104dn-bash-5.1-p12-dev
/nix/store/dbapb08862ajgaax3621fz8hly9fdah3-tcc-0.9.27+date=2022-01-11
$ nix-build . -A "bash"
/nix/store/4nmqxajzaf60yjribkgvj5j54x9yvr1r-bash-5.1-p12
$ $HOME/nixgits/nix/result/bin/nix build "nixpkgs#bash" "nixpkgs#bash.dev" "nixpkgs#tinycc" --print-store-paths
/nix/store/4nmqxajzaf60yjribkgvj5j54x9yvr1r-bash-5.1-p12
/nix/store/c49i1ggnr5cc8gxmk9xm0cn961z104dn-bash-5.1-p12-dev
/nix/store/dbapb08862ajgaax3621fz8hly9fdah3-tcc-0.9.27+date=2022-01-11
$ $HOME/nixgits/nix/result/bin/nix build "nixpkgs#bash" --print-store-paths
/nix/store/4nmqxajzaf60yjribkgvj5j54x9yvr1r-bash-5.1-p12
Supersedes #2622
Closes #5601 #1930
view the first commit for code changes.
@Mic92 @makefu @mickours @domenkozar @fzakaria @tomberek @edolstra
this was a really useful feature of
nix-buildand may be the reason why scripts haven't switched over tonix buildit would be really really useful to have this feature in
nix buildone of my use cases
i wasn't sure where to put the test so i just put it in the remote build test