nix icon indicating copy to clipboard operation
nix copied to clipboard

How to check if a binary cache contains substitutes? [multi-user edition]

Open copumpkin opened this issue 8 years ago • 15 comments

I've been using the wonderful nix-build --dry-run invocation to figure out if a binary cache has substitutes for expressions of my choice, but now that macOS has a multi-user installer I'm now running into issues because my binary caches aren't necessarily going to be in nix.conf for the daemon.

At the same time, because this is --dry-run, it doesn't feel like the whole trusted-binary-caches logic should really apply, but it does, so I'm wondering what other options I have.

I've been experimenting with 1.12 and the flexible store URIs to try to work around it, but haven't yet found the right way to make that work. And with 1.11 I'm not sure what other options I have.

@edolstra @shlevy any suggestions? It might be nice to make this first-class functionality in the new UI.

copumpkin avatar Oct 16 '17 19:10 copumpkin

All the nix.conf options are overridable on command-line via --option, aren't they?

vcunat avatar Oct 16 '17 19:10 vcunat

Apparently not if NIX_REMOTE=daemon, since (without --dry-run) it would be a security vulnerability?

copumpkin avatar Oct 16 '17 20:10 copumpkin

I guess just setting NIX_REMOTE= is sufficient.

copumpkin avatar Oct 16 '17 20:10 copumpkin

And you want to avoid sudo? EDIT: ah, I missed the last comment.

vcunat avatar Oct 16 '17 20:10 vcunat

Yeah. Doesn't seem like it should be necessary to be superuser to test if a remote binary cache contains some hashes 😄 it's also a PITA to be superuser in one of my test suites where I use this.

copumpkin avatar Oct 16 '17 20:10 copumpkin

Well, yes, but why does one want to test existence of packages that (s)he won't be able to substitute?

vcunat avatar Oct 16 '17 21:10 vcunat

I'm testing some code whose job is to manage a binary cache 😄 so I'm trying to check on what's in it and don't particularly care about using that stuff.

copumpkin avatar Oct 17 '17 12:10 copumpkin

There's also some annoyance with even nix-build --dry-run considering the state of the local store when showing me what to download, so it's not so much a "what's in the binary cache" as much as a "what's in the binary cache that I don't already have", which in some cases can be quite annoying.

copumpkin avatar Oct 17 '17 14:10 copumpkin

I've mostly worked around the issue above by using a custom throwaway store in 1.12.

One thing that's sort of annoying about this --dry-run approach vs. a more first-class "does binary cache contain this stuff" tool is that if the binary cache doesn't contain X, we might well end up downloading more than before from it because now we need to download build-time deps of X in order to build X locally. It'd be nice to be able to determine that stuff in isolation.

copumpkin avatar Oct 17 '17 18:10 copumpkin

I imagine nix-env -qas -A attribute might do that, but it's certainly not a good API for that.

vcunat avatar Oct 17 '17 19:10 vcunat

I have been using nix-build -A mypkg --option substituters 's3://REDACTED?region=eu-central-1&profile=nix-daemon' --option narinfo-cache-negative-ttl 0 --option narinfo-cache-positive-ttl 0. Is that correct ? --dry-run returns no output so not effective and increasing verbosity can be too hard to parse (I mean, I would rather read a yes/no answer) .

teto avatar Aug 27 '20 13:08 teto

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

stale[bot] avatar Feb 23 '21 22:02 stale[bot]

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/check-if-package-is-available-in-cache/13831/1

nixos-discourse avatar Jun 28 '21 10:06 nixos-discourse

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

stale[bot] avatar Jan 03 '22 20:01 stale[bot]

I cannot believe how hard it is to get some simple info from Nix. Maaan... seems like nobody cares about cache or pinning specific versions (by the semver)

svallory avatar Aug 24 '24 00:08 svallory