1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 01:51:47 +02:00

* Allow the size of the GC reserved file to be specified in nix.conf

through the new `gc-reserved-space' option.
This commit is contained in:
Eelco Dolstra 2006-02-16 13:58:10 +00:00
parent 651ab439cf
commit 345a95afe9
5 changed files with 62 additions and 14 deletions

View file

@ -75,17 +75,22 @@ Strings querySetting(const string & name, const Strings & def)
}
bool queryBoolSetting(const string & name, bool def)
string querySetting(const string & name, const string & def)
{
Strings defs;
if (def) defs.push_back("true"); else defs.push_back("false");
defs.push_back(def);
Strings value = querySetting(name, defs);
if (value.size() != 1)
throw Error(format("configuration option `%1%' should be either `true' or `false', not a list")
% name);
string v = value.front();
throw Error(format("configuration option `%1%' should not be a list") % name);
return value.front();
}
bool queryBoolSetting(const string & name, bool def)
{
string v = querySetting(name, def ? "true" : "false");
if (v == "true") return true;
else if (v == "false") return false;
else throw Error(format("configuration option `%1%' should be either `true' or `false', not `%2%'")

View file

@ -56,6 +56,8 @@ extern bool readOnlyMode;
Strings querySetting(const string & name, const Strings & def);
string querySetting(const string & name, const string & def);
bool queryBoolSetting(const string & name, bool def);

View file

@ -82,12 +82,14 @@ void openDB(bool reserveSpace)
try {
Path reservedPath = nixDBPath + "/reserved";
off_t reservedSize = 1024 * 1024;
string s = querySetting("gc-reserved-space", "");
int reservedSize;
if (!string2Int(s, reservedSize)) reservedSize = 1024 * 1024;
if (reserveSpace) {
struct stat st;
if (stat(reservedPath.c_str(), &st) == -1 ||
st.st_size != reservedSize)
writeFile(reservedPath, string(1024 * 1024, 'X'));
writeFile(reservedPath, string(reservedSize, 'X'));
}
else
deletePath(reservedPath);