-
-
Couldn't load subscription status.
- Fork 1.8k
Source path error improvements #12915
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
Changes from all commits
5d7cee3
092f222
f63dc71
addec3c
6de45c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| #include "nix/expr/print.hh" | ||
| #include "nix/fetchers/filtering-source-accessor.hh" | ||
| #include "nix/util/memory-source-accessor.hh" | ||
| #include "nix/util/mounted-source-accessor.hh" | ||
| #include "nix/expr/gc-small-vector.hh" | ||
| #include "nix/util/url.hh" | ||
| #include "nix/fetchers/fetch-to-store.hh" | ||
|
|
@@ -287,7 +288,7 @@ EvalState::EvalState( | |
| auto realStoreDir = dirOf(store->toRealPath(StorePath::dummy)); | ||
| if (settings.pureEval || store->storeDir != realStoreDir) { | ||
| accessor = settings.pureEval | ||
| ? storeFS | ||
| ? storeFS.cast<SourceAccessor>() | ||
| : makeUnionSourceAccessor({accessor, storeFS}); | ||
| } | ||
|
|
||
|
|
@@ -3090,6 +3091,11 @@ SourcePath EvalState::findFile(const LookupPath & lookupPath, const std::string_ | |
|
|
||
| auto res = (r / CanonPath(suffix)).resolveSymlinks(); | ||
| if (res.pathExists()) return res; | ||
|
|
||
| // Backward compatibility hack: throw an exception if access | ||
| // to this path is not allowed. | ||
|
Comment on lines
+3095
to
+3096
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this a hack? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah where is |
||
| if (auto accessor = res.accessor.dynamic_pointer_cast<FilteringSourceAccessor>()) | ||
| accessor->checkAccess(res.path); | ||
| } | ||
|
|
||
| if (hasPrefix(path, "nix/")) | ||
|
|
@@ -3160,6 +3166,11 @@ std::optional<SourcePath> EvalState::resolveLookupPathPath(const LookupPath::Pat | |
| if (path.resolveSymlinks().pathExists()) | ||
| return finish(std::move(path)); | ||
| else { | ||
| // Backward compatibility hack: throw an exception if access | ||
| // to this path is not allowed. | ||
|
Comment on lines
+3169
to
+3170
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this a hack? |
||
| if (auto accessor = path.accessor.dynamic_pointer_cast<FilteringSourceAccessor>()) | ||
| accessor->checkAccess(path.path); | ||
|
|
||
| logWarning({ | ||
| .msg = HintFmt("Nix search path entry '%1%' does not exist, ignoring", value) | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |||||
| #include "nix/store/local-fs-store.hh" | ||||||
| #include "nix/fetchers/fetch-to-store.hh" | ||||||
| #include "nix/util/memory-source-accessor.hh" | ||||||
| #include "nix/util/mounted-source-accessor.hh" | ||||||
| #include "nix/fetchers/input-cache.hh" | ||||||
|
|
||||||
| #include <nlohmann/json.hpp> | ||||||
|
|
@@ -32,7 +33,9 @@ static StorePath copyInputToStore( | |||||
| { | ||||||
| auto storePath = fetchToStore(*state.store, accessor, FetchMode::Copy, input.getName()); | ||||||
|
|
||||||
| state.allowPath(storePath); | ||||||
| state.allowPath(storePath); // FIXME: should just whitelist the entire virtual store | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a bug:
Suggested change
|
||||||
|
|
||||||
| state.storeFS->mount(CanonPath(state.store->printStorePath(storePath)), accessor); | ||||||
|
|
||||||
| auto narHash = state.store->queryPathInfo(storePath)->narHash; | ||||||
| input.attrs.insert_or_assign("narHash", narHash.to_string(HashFormat::SRI, true)); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #pragma once | ||
|
|
||
| #include "source-accessor.hh" | ||
|
|
||
| namespace nix { | ||
|
|
||
| struct MountedSourceAccessor : SourceAccessor | ||
| { | ||
| virtual void mount(CanonPath mountPoint, ref<SourceAccessor> accessor) = 0; | ||
| }; | ||
|
|
||
| ref<MountedSourceAccessor> makeMountedSourceAccessor(std::map<CanonPath, ref<SourceAccessor>> mounts); | ||
|
|
||
| } |
Uh oh!
There was an error while loading. Please reload this page.