mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
config: add included files into parsedContents before applying
Fixes #8719
This commit is contained in:
parent
3ca0dade5b
commit
1d28d613b1
2 changed files with 14 additions and 5 deletions
|
@ -88,10 +88,9 @@ void Config::getSettings(std::map<std::string, SettingInfo> & res, bool overridd
|
||||||
res.emplace(opt.first, SettingInfo{opt.second.setting->to_string(), opt.second.setting->description});
|
res.emplace(opt.first, SettingInfo{opt.second.setting->to_string(), opt.second.setting->description});
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractConfig::applyConfig(const std::string & contents, const std::string & path) {
|
|
||||||
unsigned int pos = 0;
|
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> parsedContents;
|
static void applyConfigInner(const std::string & contents, const std::string & path, std::vector<std::pair<std::string, std::string>> & parsedContents) {
|
||||||
|
unsigned int pos = 0;
|
||||||
|
|
||||||
while (pos < contents.size()) {
|
while (pos < contents.size()) {
|
||||||
std::string line;
|
std::string line;
|
||||||
|
@ -123,7 +122,10 @@ void AbstractConfig::applyConfig(const std::string & contents, const std::string
|
||||||
throw UsageError("illegal configuration line '%1%' in '%2%'", line, path);
|
throw UsageError("illegal configuration line '%1%' in '%2%'", line, path);
|
||||||
auto p = absPath(tokens[1], dirOf(path));
|
auto p = absPath(tokens[1], dirOf(path));
|
||||||
if (pathExists(p)) {
|
if (pathExists(p)) {
|
||||||
applyConfigFile(p);
|
try {
|
||||||
|
std::string includedContents = readFile(path);
|
||||||
|
applyConfigInner(includedContents, p, parsedContents);
|
||||||
|
} catch (SysError &) { }
|
||||||
} else if (!ignoreMissing) {
|
} else if (!ignoreMissing) {
|
||||||
throw Error("file '%1%' included from '%2%' not found", p, path);
|
throw Error("file '%1%' included from '%2%' not found", p, path);
|
||||||
}
|
}
|
||||||
|
@ -143,6 +145,12 @@ void AbstractConfig::applyConfig(const std::string & contents, const std::string
|
||||||
concatStringsSep(" ", Strings(i, tokens.end())),
|
concatStringsSep(" ", Strings(i, tokens.end())),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void AbstractConfig::applyConfig(const std::string & contents, const std::string & path) {
|
||||||
|
std::vector<std::pair<std::string, std::string>> parsedContents;
|
||||||
|
|
||||||
|
applyConfigInner(contents, path, parsedContents);
|
||||||
|
|
||||||
// First apply experimental-feature related settings
|
// First apply experimental-feature related settings
|
||||||
for (auto & [name, value] : parsedContents)
|
for (auto & [name, value] : parsedContents)
|
||||||
|
|
|
@ -20,7 +20,7 @@ cat > "$NIX_CONF_DIR"/nix.conf <<EOF
|
||||||
build-users-group =
|
build-users-group =
|
||||||
keep-derivations = false
|
keep-derivations = false
|
||||||
sandbox = false
|
sandbox = false
|
||||||
experimental-features = nix-command flakes
|
experimental-features = nix-command
|
||||||
gc-reserved-space = 0
|
gc-reserved-space = 0
|
||||||
substituters =
|
substituters =
|
||||||
flake-registry = $TEST_ROOT/registry.json
|
flake-registry = $TEST_ROOT/registry.json
|
||||||
|
@ -31,6 +31,7 @@ EOF
|
||||||
|
|
||||||
cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF
|
cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF
|
||||||
fsync-metadata = false
|
fsync-metadata = false
|
||||||
|
extra-experimental-features = flakes
|
||||||
!include nix.conf.extra.not-there
|
!include nix.conf.extra.not-there
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue