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

fetchClosure: input addressed and pure #8370

Merged
merged 16 commits into from
Jul 10, 2023

Conversation

roberth
Copy link
Member

@roberth roberth commented May 19, 2023

Motivation

Input addressed binary dependencies are not impure, so requiring --impure for them would open users up to actual impurities, which is counterproductive. Instead, we accept the fact that a trusted key may be required, but we do remind expression authors that CA does not require this.

Context

Follow-up to #8090 (comment)

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • documentation in the internal API docs
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

Priorities

Add 👍 to pull requests you find important.

@roberth roberth requested a review from edolstra as a code owner May 19, 2023 09:34
@roberth roberth added the idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. label May 19, 2023
@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label May 19, 2023
@roberth roberth changed the title Fetch closure input addressed fetchClosure: input addressed and pure May 19, 2023
@roberth roberth force-pushed the fetchClosure-input-addressed branch from 6542be8 to 3e3ad34 Compare May 22, 2023 09:37
@Ericson2314
Copy link
Member

Last commit I think warrants additional tests.

src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
@Ericson2314
Copy link
Member

After this PR, I think it would be good to break up the implementation function into multiple functions. We could use a std::variant perhaps to represent multiple cases, and avoid degrees of freedom (e.g. std::optionals) that are only needed during argument processing before all the fields are parsed.

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/2023-05-19-nix-team-meeting-minutes-56/28446/1

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/2023-05-22-nix-team-meeting-minutes-57/28447/1

If `fromPath` is already content-addressed, or if you are
allowing impure evaluation (`--impure`), then `toPath` may be
omitted.
By rewriting the store paths, you can add the contents to any store without requiring that you or perhaps your users configure any extra trust.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation of trust not entirely in scope for this piece of documentation. New section TBD:

@Ericson2314
Copy link
Member

Code looks great now, but do we need more tests and release notes?

@roberth roberth force-pushed the fetchClosure-input-addressed branch from 3bb5c6c to e7053b9 Compare June 6, 2023 23:50
@roberth
Copy link
Member Author

roberth commented Jun 6, 2023

Code looks great now, but do we need [...] and release notes?

I did add a little release note

Does that look ok to you? All I could think of adding is instructions, but I think the linked reference docs should cover that, as well as the error messages.

more tests

The basics are covered, but I'll have another look at it.

Copy link
Contributor

@fricklerhandwerk fricklerhandwerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error mechanism is really good, as it's largely self-explanatory! Lots of suggestions to make the wording as clear and concise as possible, I hope they're straightforward to commit if not contentious.

doc/manual/src/release-notes/rl-next.md Outdated Show resolved Hide resolved
src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
Comment on lines 238 to 256
**Rewriting a store path**

This first example fetches `/nix/store/r2jd...` from the specified binary cache,
and rewrites it into the content-addressed store path
`/nix/store/ldbh...`.

If `fromPath` is already content-addressed, or if you are
allowing impure evaluation (`--impure`), then `toPath` may be
omitted.
By rewriting the store paths, you can add the contents to any store without requiring that you or perhaps your users configure any extra trust.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd omit all this. The first example is explained by the line introducing it. Let's not go into recommendations here until we explain trust and that stuff somewhere first. Let's focus on providing the mechanism and showing how it's used.

src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
@Ericson2314
Copy link
Member

Sorry I missed the release note: I was reviewing too tired :/. For the tests I might be underestimating how good they were before, but it seems now are more systematic about error checking and thus there are a number of failure modes to test?

@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/2023-06-05-nix-team-meeting-minutes-60/28933/1

@roberth roberth force-pushed the fetchClosure-input-addressed branch 2 times, most recently from e3b22c3 to 1224fbd Compare June 19, 2023 21:25
@roberth roberth requested a review from Ericson2314 June 22, 2023 15:04
@Ericson2314 Ericson2314 marked this pull request as draft June 22, 2023 17:14
@Ericson2314
Copy link
Member

I'll make this draft and then @roberth can undraft it when I should review it again.

@roberth roberth marked this pull request as ready for review June 30, 2023 12:35
roberth and others added 13 commits June 30, 2023 18:19
When explicitly requested by the caller, as suggested in the meeting
(NixOS#8090 (comment))

> @edolstra: { toPath } vs { fromPath } is too implicit

I've opted for the `inputAddressed = true` requirement, because it
we did not agree on renaming the path attributes.

> @roberth: more explicit
> @edolstra: except for the direction; not immediately clear in which direction the rewriting happens

This is in fact the most explicit syntax and a bit redundant, which is
good, because that redundancy lets us deliver an error message that
reminds expression authors that CA provides a better experience to
their users.
A single variable is nice and self-contained.
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
We should check error messages, so that we know the command fails for
the right reason.
Alternatively, a mere typo can run the test undetected.
@roberth roberth force-pushed the fetchClosure-input-addressed branch from 1224fbd to fefb947 Compare June 30, 2023 16:32
@github-actions github-actions bot added the tests label Jun 30, 2023
Copy link
Contributor

@fricklerhandwerk fricklerhandwerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other comments about moving the example explanations into the examples still apply.

src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
src/libexpr/primops/fetchClosure.cc Outdated Show resolved Hide resolved
roberth and others added 2 commits July 7, 2023 11:00
@roberth
Copy link
Member Author

roberth commented Jul 7, 2023

moving the example explanations into the examples

Done. They are now interleaved with the docs that describe those invocations; no more "overview" means less switching between the three "use cases" and less repetition. You can still get the overview by looking at just the headers and/or just the examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. tests with-tests Issues related to testing. PRs with tests have some priority
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants