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

Realisations don't get copied to binary caches #6623

Closed
dasJ opened this issue Jun 7, 2022 · 5 comments
Closed

Realisations don't get copied to binary caches #6623

dasJ opened this issue Jun 7, 2022 · 5 comments
Labels
bug ca-derivations Derivations with content addressed outputs

Comments

@dasJ
Copy link
Member

dasJ commented Jun 7, 2022

Describe the bug

Copying a CA derivation to a binary cache does not appear to create anything in realisations/

Steps To Reproduce

  1. nix-shell -p 'hello.overrideAttrs (_: { __contentAddressed = true; })'
  2. nix copy --to file:///tmp/binary-cache $buildInputs
  3. ls /tmp/binary-cache/realisations
  4. See there is nothing

Expected behavior

I would expect a realisation to be placed in the directory.

nix-env (Nix) 2.8.1

Additional context

experimental-features = nix-command flakes ca-derivations

@dasJ dasJ added the bug label Jun 7, 2022
@thufschmitt thufschmitt added the ca-derivations Derivations with content addressed outputs label Jun 8, 2022
@thufschmitt
Copy link
Member

Yes, that's somewhat normal: $buildInputs is a list of store paths, not of realisations, so nix will only copy the store paths. It's quite annoying for cases like this one, but unfortunately it seems that there's no reasonable alternative (even if we wanted to, Nix couldn't know in general which realisation to copy since it can have multiple realisers).

nix copy --impure --to file:///tmp/binary-cache --expr '(import <nixpkgs> {}).hello.overrideAttrs (_: { __contentAddressed = true; })' will copy the realisation otoh because it's acting at a level where Nix knows about the realisation

@dasJ
Copy link
Member Author

dasJ commented Jun 8, 2022

Thanks, that makes sense.

@dasJ dasJ closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2022
@pwaller
Copy link
Contributor

pwaller commented Jul 7, 2023

I ran headlong into this in #8622 and ask: why can't we copy realisations known about if it was built locally? I get that "it's impossible to do this in the general case", but I don't see why it couldn't work in the typical case of nix build <installable> && nix copy --to cache ./result since clearly the local machine has knowledge of the realisations used to construct ./result since it just built it, and this is a typical thing a user might do to populate a cache.

@pwaller
Copy link
Contributor

pwaller commented Jul 7, 2023

I suppose I'm asking if it's unreasonable to copy all of the realisations that are known about locally? (edit: for the output path)

@pwaller
Copy link
Contributor

pwaller commented Jul 7, 2023

Another UX issue here: it basically means nix copy --to cache $outputPath doesn't work at all for enabling the user to get a cache hit (for a CA derivation). If it can't work it should at least warn the user, otherwise this leads to a confused user, since it otherwise looks like this step in the process works/does something useful, when it actually won't give the user the cache hit they wanted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ca-derivations Derivations with content addressed outputs
Projects
None yet
Development

No branches or pull requests

3 participants