mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02:00
Merge pull request #1863 from shlevy/conf-includes
Allow includes from nix.conf
This commit is contained in:
commit
52c777a793
3 changed files with 36 additions and 2 deletions
|
@ -40,7 +40,12 @@
|
|||
|
||||
<para>The configuration files consist of
|
||||
<literal><replaceable>name</replaceable> =
|
||||
<replaceable>value</replaceable></literal> pairs, one per line.
|
||||
<replaceable>value</replaceable></literal> pairs, one per line. Other
|
||||
files can be included with a line like <literal>include
|
||||
<replaceable>path</replaceable></literal>, where
|
||||
<replaceable>path</replaceable> is interpreted relative to the current
|
||||
conf file and a missing file is an error unless
|
||||
<literal>!include</literal> is used instead.
|
||||
Comments start with a <literal>#</literal> character. Here is an
|
||||
example configuration file:</para>
|
||||
|
||||
|
|
|
@ -80,7 +80,31 @@ void Config::applyConfigFile(const Path & path, bool fatal)
|
|||
vector<string> tokens = tokenizeString<vector<string> >(line);
|
||||
if (tokens.empty()) continue;
|
||||
|
||||
if (tokens.size() < 2 || tokens[1] != "=")
|
||||
if (tokens.size() < 2)
|
||||
throw UsageError("illegal configuration line '%1%' in '%2%'", line, path);
|
||||
|
||||
auto include = false;
|
||||
auto ignoreMissing = false;
|
||||
if (tokens[0] == "include")
|
||||
include = true;
|
||||
else if (tokens[0] == "!include") {
|
||||
include = true;
|
||||
ignoreMissing = true;
|
||||
}
|
||||
|
||||
if (include) {
|
||||
if (tokens.size() != 2)
|
||||
throw UsageError("illegal configuration line '%1%' in '%2%'", line, path);
|
||||
auto p = absPath(tokens[1], dirOf(path));
|
||||
if (pathExists(p)) {
|
||||
applyConfigFile(p, fatal);
|
||||
} else if (!ignoreMissing) {
|
||||
throw Error("file '%1%' included from '%2%' not found", p, path);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tokens[1] != "=")
|
||||
throw UsageError("illegal configuration line '%1%' in '%2%'", line, path);
|
||||
|
||||
string name = tokens[0];
|
||||
|
|
|
@ -16,7 +16,12 @@ mkdir "$NIX_CONF_DIR"
|
|||
cat > "$NIX_CONF_DIR"/nix.conf <<EOF
|
||||
build-users-group =
|
||||
keep-derivations = false
|
||||
include nix.conf.extra
|
||||
EOF
|
||||
|
||||
cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF
|
||||
fsync-metadata = false
|
||||
!include nix.conf.extra.not-there
|
||||
EOF
|
||||
|
||||
# Initialise the database.
|
||||
|
|
Loading…
Reference in a new issue