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

nix 2 cli alternative to nix-store --query [drv] ? #5895

Open
colemickens opened this issue Jan 10, 2022 · 3 comments
Open

nix 2 cli alternative to nix-store --query [drv] ? #5895

colemickens opened this issue Jan 10, 2022 · 3 comments

Comments

@colemickens
Copy link
Member

Describe the bug
How do I get the equivalent of this, with the new nix cli?

❯ nix-store --query /nix/store/svy43xnw42hpfygqk4r1wfzwsrx145kj-aarch64-linux-toplevel-bundle.drv
warning: unknown experimental feature 'ca-references'
/nix/store/z6cp88d6ww21n65vf5vviyfphq868nzy-aarch64-linux-toplevel-bundle

What I'm doing now is nix path-info --json [drv] but that queries all of the paths in the closure and is very non-trivial compared ot the nix-store --query:

drv="$(nix eval --raw "${thing}.drvPath" "${@}")"
out="$(nix path-info --json ${drv} | jq -r '.[0].path')" # very slow ...
❯ nix --version
nix (Nix) 2.6.0pre20211217_6e6e998
@balsoft
Copy link
Member

balsoft commented Jan 10, 2022

What I ended up doing for this is to nix show-derivation | jq -r '.[].outputs.out.path'

But I do agree that replacements for nix-store --query are needed, especially --referrers and --tree.

@thufschmitt
Copy link
Member

What I'm doing now is nix path-info --json [drv] but that queries all of the paths in the closure and is very non-trivial compared ot the nix-store --query:

Duh, it shouldn’t do a recursive query unless you pass --recursive:

$ nix path-info --json nixpkgs\#firefox
[{"path":"/nix/store/64nhgp9hyqkfi8i2ky5pk5csjcpl459f-firefox-94.0.2","valid":false}]

Also note that you can directly run it on an arbitrary installable, so your workaround could just be:

out="$(nix path-info --json ${thing} "${@} | jq -r '.[0].path')"

(That being said, I’ll put my “ca-derivations implementer” hat on and remark that this won’t work anymore with ca-derivations because the only way to know the output paths of a ca derivation is to build it).

@stale
Copy link

stale bot commented Jul 11, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants