mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Clean up SearchPath
- Better types - Own header / C++ file pair - Test factored out methods - Pass parsed thing around more than strings Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit is contained in:
parent
87dcd09047
commit
be518e73ae
12 changed files with 300 additions and 64 deletions
|
@ -1656,9 +1656,9 @@ static void prim_findFile(EvalState & state, const PosIdx pos, Value * * args, V
|
|||
}));
|
||||
}
|
||||
|
||||
searchPath.emplace_back(SearchPathElem {
|
||||
.prefix = prefix,
|
||||
.path = path,
|
||||
searchPath.elements.emplace_back(SearchPath::Elem {
|
||||
.prefix = SearchPath::Prefix { .s = prefix },
|
||||
.path = SearchPath::Path { .s = path },
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4319,12 +4319,12 @@ void EvalState::createBaseEnv()
|
|||
});
|
||||
|
||||
/* Add a value containing the current Nix expression search path. */
|
||||
mkList(v, searchPath.size());
|
||||
mkList(v, searchPath.elements.size());
|
||||
int n = 0;
|
||||
for (auto & i : searchPath) {
|
||||
for (auto & i : searchPath.elements) {
|
||||
auto attrs = buildBindings(2);
|
||||
attrs.alloc("path").mkString(i.path);
|
||||
attrs.alloc("prefix").mkString(i.prefix);
|
||||
attrs.alloc("path").mkString(i.path.s);
|
||||
attrs.alloc("prefix").mkString(i.prefix.s);
|
||||
(v.listElems()[n++] = allocValue())->mkAttrs(attrs);
|
||||
}
|
||||
addConstant("__nixPath", v, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue