mirror of
https://github.com/NixOS/nix
synced 2025-06-27 04:21:16 +02:00
No global eval settings in libnixexpr
Progress on #5638 There is still a global eval settings, but it pushed down into `libnixcmd`, which is a lot less bad a place for this sort of thing.
This commit is contained in:
parent
cb0c868da4
commit
52bfccf8d8
24 changed files with 102 additions and 71 deletions
|
@ -45,7 +45,8 @@ static Strings parseNixPath(const std::string & s)
|
|||
return res;
|
||||
}
|
||||
|
||||
EvalSettings::EvalSettings()
|
||||
EvalSettings::EvalSettings(bool & readOnlyMode)
|
||||
: readOnlyMode{readOnlyMode}
|
||||
{
|
||||
auto var = getEnv("NIX_PATH");
|
||||
if (var) nixPath = parseNixPath(*var);
|
||||
|
@ -55,7 +56,7 @@ EvalSettings::EvalSettings()
|
|||
builtinsAbortOnWarn = true;
|
||||
}
|
||||
|
||||
Strings EvalSettings::getDefaultNixPath()
|
||||
Strings EvalSettings::getDefaultNixPath() const
|
||||
{
|
||||
Strings res;
|
||||
auto add = [&](const Path & p, const std::string & s = std::string()) {
|
||||
|
@ -68,7 +69,7 @@ Strings EvalSettings::getDefaultNixPath()
|
|||
}
|
||||
};
|
||||
|
||||
if (!evalSettings.restrictEval && !evalSettings.pureEval) {
|
||||
if (!restrictEval && !pureEval) {
|
||||
add(getNixDefExpr() + "/channels");
|
||||
add(rootChannelsDir() + "/nixpkgs", "nixpkgs");
|
||||
add(rootChannelsDir());
|
||||
|
@ -94,16 +95,12 @@ std::string EvalSettings::resolvePseudoUrl(std::string_view url)
|
|||
return std::string(url);
|
||||
}
|
||||
|
||||
const std::string & EvalSettings::getCurrentSystem()
|
||||
const std::string & EvalSettings::getCurrentSystem() const
|
||||
{
|
||||
const auto & evalSystem = currentSystem.get();
|
||||
return evalSystem != "" ? evalSystem : settings.thisSystem.get();
|
||||
}
|
||||
|
||||
EvalSettings evalSettings;
|
||||
|
||||
static GlobalConfig::Register rEvalSettings(&evalSettings);
|
||||
|
||||
Path getNixDefExpr()
|
||||
{
|
||||
return settings.useXDGBaseDirectories
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue