-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Use a union source accessor to put chroot stores in the logical location #12512
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e5e0ce2
Remove redundant call to canonPath()
edolstra 774b924
Add a storeFS accessor for paths resulting from IFD
edolstra 641733f
Add test
edolstra c3d8799
MountedSourceAccessor: Remove redundant pathExists() method
edolstra 5b7c240
Add a UnionSourceAccessor
edolstra 99e78c3
Use UnionSourceAccessor to mount the chroot store on top of the real …
edolstra 584ddd1
UnionSourceAccessor: Don't filter out underlying files of the wrong type
edolstra 4206d95
Remove sourcePathToStorePath()
edolstra 8dc2b27
In pure eval mode, restrict rootFS to just the Nix store
edolstra ec7dc56
Remove unused variable
edolstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| #include "source-accessor.hh" | ||
|
|
||
| namespace nix { | ||
|
|
||
| struct UnionSourceAccessor : SourceAccessor | ||
edolstra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| std::vector<ref<SourceAccessor>> accessors; | ||
|
|
||
| UnionSourceAccessor(std::vector<ref<SourceAccessor>> _accessors) | ||
| : accessors(std::move(_accessors)) | ||
| { | ||
| displayPrefix.clear(); | ||
| } | ||
|
|
||
| std::string readFile(const CanonPath & path) override | ||
| { | ||
| for (auto & accessor : accessors) { | ||
| auto st = accessor->maybeLstat(path); | ||
| if (st) | ||
| return accessor->readFile(path); | ||
| } | ||
| throw FileNotFound("path '%s' does not exist", showPath(path)); | ||
| } | ||
|
|
||
| std::optional<Stat> maybeLstat(const CanonPath & path) override | ||
| { | ||
| for (auto & accessor : accessors) { | ||
| auto st = accessor->maybeLstat(path); | ||
| if (st) | ||
| return st; | ||
| } | ||
| return std::nullopt; | ||
| } | ||
|
|
||
| DirEntries readDirectory(const CanonPath & path) override | ||
| { | ||
| DirEntries result; | ||
| for (auto & accessor : accessors) { | ||
| auto st = accessor->maybeLstat(path); | ||
| if (!st) | ||
| continue; | ||
| for (auto & entry : accessor->readDirectory(path)) | ||
| // Don't override entries from previous accessors. | ||
| result.insert(entry); | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| std::string readLink(const CanonPath & path) override | ||
| { | ||
| for (auto & accessor : accessors) { | ||
| auto st = accessor->maybeLstat(path); | ||
| if (st) | ||
| return accessor->readLink(path); | ||
| } | ||
| throw FileNotFound("path '%s' does not exist", showPath(path)); | ||
| } | ||
|
|
||
| std::string showPath(const CanonPath & path) override | ||
| { | ||
| for (auto & accessor : accessors) | ||
| return accessor->showPath(path); | ||
| return SourceAccessor::showPath(path); | ||
| } | ||
|
|
||
| std::optional<std::filesystem::path> getPhysicalPath(const CanonPath & path) override | ||
| { | ||
| for (auto & accessor : accessors) { | ||
| auto p = accessor->getPhysicalPath(path); | ||
| if (p) | ||
| return p; | ||
| } | ||
| return std::nullopt; | ||
| } | ||
| }; | ||
|
|
||
| ref<SourceAccessor> makeUnionSourceAccessor(std::vector<ref<SourceAccessor>> && accessors) | ||
| { | ||
| return make_ref<UnionSourceAccessor>(std::move(accessors)); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the idea that
refsis unused? If so, let's also delete the variable above? If not... what's going on?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a regression in....ea38605?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this appears to be dead code. I think the idea was to propagate the references, but that "feature" was never really well thought out. Maybe we should warn/fail if the path has references...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can investigate what happened here later. IIRC there was some regressions with this too.