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

Disallow CA paths from referring to non-CA paths #6301

Open
edolstra opened this issue Mar 22, 2022 · 1 comment
Open

Disallow CA paths from referring to non-CA paths #6301

edolstra opened this issue Mar 22, 2022 · 1 comment
Labels
bug ca-derivations Derivations with content addressed outputs stale

Comments

@edolstra
Copy link
Member

Currently CA paths can refer to non-CA paths:

$ nix path-info --json /nix/store/ap2nhrpfjin5ng881mgl4pmrzmsp6cj0-patchelf-0.13 | jq .[].ca
"fixed:r:sha256:1i4ygjm0jax3q3gcayv9g1mff0711xyfg87in8l4m0rbqyss5rcn"

$ nix path-info --json -r /nix/store/ap2nhrpfjin5ng881mgl4pmrzmsp6cj0-patchelf-0.13 | jq .[].ca
null
"fixed:r:sha256:1i4ygjm0jax3q3gcayv9g1mff0711xyfg87in8l4m0rbqyss5rcn"
null
null
null

This seems like an undesirable property, since it means that a top-level CA path does not "lock" its dependencies.

@thufschmitt What do you think?

@edolstra edolstra added bug ca-derivations Derivations with content addressed outputs labels Mar 22, 2022
edolstra added a commit to edolstra/nix that referenced this issue Mar 22, 2022
LocalStore::addToStore() since
79ae9e4 expects a regular NAR hash,
rather than a NAR hash modulo self-references. Fixes NixOS#6300.

Also, makeContentAddressed() now rewrites the entire closure (so 'nix
store make-content-addressable' no longer needs '-r'). See NixOS#6301.
@thufschmitt
Copy link
Member

Yes, that was intentional, for two reasons:

  1. Since the hash rewriting is only a heuristic, it seemed safer to provide a local escape hatch (saying that a specific derivation should be input-addressed while all the rest would be CA);
  2. Enforcing everything to be CA can make it hard to interact with external derivations − for example my system config is globally content-addressed, but I also include some packages from a few external flakes (and which are input-addressed).

Now, it seems that 1. was essentially a theoretical concern (there has been a couple of CA-related breakages in nixpkgs, but all easy to fix and due to #4764 and not the hash rewriting) so that’s not a really strong point anymore.

For 2, maybe we could expose makeContentAddressed as a builtin so that we can rewrite on-the-fly any input-addressed derivation output that we’d want to use?

edolstra added a commit to edolstra/nix that referenced this issue Mar 24, 2022
LocalStore::addToStore() since
79ae9e4 expects a regular NAR hash,
rather than a NAR hash modulo self-references. Fixes NixOS#6300.

Also, makeContentAddressed() now rewrites the entire closure (so 'nix
store make-content-addressable' no longer needs '-r'). See NixOS#6301.
@stale stale bot added the stale label Sep 21, 2022
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 stale
Projects
None yet
Development

No branches or pull requests

2 participants