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

Copy ca derivation outputs #4487

Merged
merged 6 commits into from Feb 26, 2021
Merged

Copy ca derivation outputs #4487

merged 6 commits into from Feb 26, 2021

Conversation

thufschmitt
Copy link
Member

Yet another take on #4220

Depends on #4340 and #4372

(the diff includes the one of #4372 because I can only target the PR at one branch)

@thufschmitt thufschmitt added this to the ca-derivations-mvp milestone Jan 28, 2021
@thufschmitt thufschmitt added ca-derivations Derivations with content addressed outputs feature Feature request or proposal labels Jan 28, 2021
@thufschmitt thufschmitt force-pushed the ca/copy-drv-outputs branch 2 times, most recently from 159205a to f420043 Compare January 28, 2021 16:45
@dpulls
Copy link

dpulls bot commented Feb 19, 2021

🎉 All dependencies have been resolved !

Base automatically changed from ca/store-unresolved-outputs to master February 19, 2021 14:48
@thufschmitt thufschmitt force-pushed the ca/copy-drv-outputs branch 2 times, most recently from abf404b to 8ac4133 Compare February 19, 2021 14:50
@@ -783,6 +783,24 @@ void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
}


std::map<StorePath, StorePath> copyPaths(ref<Store> srcStore, ref<Store> dstStore, const RealisedPath::Set & paths,
RepairFlag repair, CheckSigsFlag checkSigs, SubstituteFlag substitute)
{
Copy link
Member

Choose a reason for hiding this comment

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

settings.isExperimentalFeatureEnabled("ca-derivations") somewhere in here?

Copy link
Member

Choose a reason for hiding this comment

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

For the local side. I guess don't even attempt to copy realizations in that case?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think in practice this always hold (because the RealisedPathsCommand only uses OpaquePaths if the flag isn't set. But I've added a check here too in 00a30ea just for security

}
auto pathsMap = copyPaths(srcStore, dstStore, storePaths, repair, checkSigs, substitute);
for (auto& realisation : realisations) {
dstStore->registerDrvOutput(realisation);
Copy link
Member

Choose a reason for hiding this comment

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

separately arrange for this to fail nicely if it isn't enabled remotely

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in e1c0bf9

(I made it just log the error because as we can't control the remote side, it might make sense to just copy the output paths without failing at the end)

@@ -672,7 +682,7 @@ public:
send a series of commands to modify various settings to stdout. The
currently recognized commands are:

- `extra-sandbox-paths`
- `extra-sandbox-paths`
Copy link
Member

Choose a reason for hiding this comment

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

IIRC this trailing whitespace is significant, it causes it to be rendered as a definition list.

Copy link
Member Author

Choose a reason for hiding this comment

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

Aaaaaargh thanks. Fixed in a21de51

Copy link
Member

@edolstra edolstra left a comment

Choose a reason for hiding this comment

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

LGTM apart from some comments.

I wonder though whether copyPaths should be overloaded like this. Maybe it makes more sense to separate copying paths from copying realisations. There might be cases where you just want to copy a store path closure without registering realisation mappings.

src/libstore/store-api.cc Outdated Show resolved Hide resolved
src/libstore/store-api.cc Outdated Show resolved Hide resolved
src/libstore/store-api.cc Outdated Show resolved Hide resolved
src/libstore/store-api.hh Outdated Show resolved Hide resolved
src/libstore/globals.hh Outdated Show resolved Hide resolved
@thufschmitt
Copy link
Member Author

I wonder though whether copyPaths should be overloaded like this. Maybe it makes more sense to separate copying paths from copying realisations. There might be cases where you just want to copy a store path closure without registering realisation mappings.

That's a fair point.

  • For copyPaths itself, it's an overload as you say, copyPaths(..., StorePathsSet) still exists (and is used in a number of places). Maybe we could rename the overload as copyRealisations or something like that.
  • For nix copy, currently the only way to only copy a store path is to run nix copy /nix/store/foobar (as all the other forms of installable will yield a Realisation). Maybe we could add a new OperateOn enum member to operate on realisations rather than just store paths (along with a flag similar to --derivations to change the OperateOn we want to use). If that sounds good I can do that in a follow-up PR

thufschmitt and others added 6 commits February 25, 2021 17:18
That way we can copy the realisations too (in addition to the store
paths themselves)
Rather throw a proper exception, and catch&log it on the client side
This should already hold, but better ensure it for future-proof-nees
Mostly removing useless comments and adding spaces before `&`

Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
The experimental feature was by mistake required for `nix copy` to work
at oll
@thufschmitt
Copy link
Member Author

Rebased on top of master

@edolstra edolstra merged commit d280340 into master Feb 26, 2021
@edolstra edolstra deleted the ca/copy-drv-outputs branch February 26, 2021 11:20
@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/tweag-nix-dev-update-8/11758/1

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

Successfully merging this pull request may close these issues.

None yet

4 participants