mirror of
https://github.com/NixOS/nix.git
synced 2025-11-27 04:30:59 +01:00
Merged trunk R9751 back in.
This commit is contained in:
parent
4e11da960c
commit
55b07d65b1
16 changed files with 294 additions and 20 deletions
|
|
@ -223,6 +223,8 @@ static void initAndRun(int argc, char * * argv)
|
|||
readOnlyMode = true;
|
||||
else if (arg == "--max-silent-time")
|
||||
maxSilentTime = getIntArg(arg, i, args.end());
|
||||
else if (arg == "--no-build-hook")
|
||||
useBuildHook = false;
|
||||
else remaining.push_back(arg);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1282,6 +1282,7 @@ static string makeValidityRegistration(const PathSet & paths,
|
|||
|
||||
DerivationGoal::HookReply DerivationGoal::tryBuildHook()
|
||||
{
|
||||
if (!useBuildHook) return rpDecline;
|
||||
Path buildHook = getEnv("NIX_BUILD_HOOK");
|
||||
if (buildHook == "") return rpDecline;
|
||||
buildHook = absPath(buildHook);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ static string gcLockName = "gc.lock";
|
|||
static string tempRootsDir = "temproots";
|
||||
static string gcRootsDir = "gcroots";
|
||||
|
||||
const unsigned int defaultGcLevel = 1000;
|
||||
|
||||
|
||||
/* Acquire the global GC lock. This is used to prevent new Nix
|
||||
processes from starting after the temporary root files have been
|
||||
|
|
@ -448,6 +450,8 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
queryBoolSetting("gc-keep-outputs", false);
|
||||
bool gcKeepDerivations =
|
||||
queryBoolSetting("gc-keep-derivations", true);
|
||||
unsigned int gcKeepOutputsThreshold =
|
||||
queryIntSetting ("gc-keep-outputs-threshold", defaultGcLevel);
|
||||
|
||||
//printMsg(lvlError, format("gcKeepOutputs %1% gcKeepDerivations: %2%") % gcKeepOutputs % gcKeepDerivations);
|
||||
|
||||
|
|
@ -521,13 +525,31 @@ void LocalStore::collectGarbage(GCAction action, const PathSet & pathsToDelete,
|
|||
for (PathSet::iterator i = livePaths.begin(); i != livePaths.end(); ++i)
|
||||
if (isDerivation(*i)) {
|
||||
Derivation drv = derivationFromPathTxn(noTxn, *i);
|
||||
|
||||
/*
|
||||
* TODO REMOVE
|
||||
<<<<<<< .working
|
||||
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
||||
j != drv.outputs.end(); ++j)
|
||||
if (store->isValidPath(j->second.path))
|
||||
computeFSClosure(j->second.path, livePaths, true, true, 0);
|
||||
else if (store->isValidStatePath(j->second.path))
|
||||
computeFSClosure(j->second.path, livePaths, true, true, 0);
|
||||
}
|
||||
=======
|
||||
*/
|
||||
|
||||
string gcLevelStr = drv.env["__gcLevel"];
|
||||
int gcLevel;
|
||||
if (!string2Int(gcLevelStr,gcLevel)) {
|
||||
gcLevel = defaultGcLevel;
|
||||
}
|
||||
|
||||
if (gcLevel >= gcKeepOutputsThreshold)
|
||||
for (DerivationOutputs::iterator j = drv.outputs.begin();
|
||||
j != drv.outputs.end(); ++j)
|
||||
if (store->isValidPath(j->second.path) || store->isValidStatePath(j->second.path))
|
||||
computeFSClosure(j->second.path, livePaths, true, true, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (action == gcReturnLive) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ bool readOnlyMode = false;
|
|||
string thisSystem = "unset";
|
||||
unsigned int maxSilentTime = 0;
|
||||
Paths substituters;
|
||||
bool useBuildHook = true;
|
||||
|
||||
|
||||
static bool settingsRead = false;
|
||||
|
|
|
|||
|
|
@ -80,6 +80,10 @@ extern unsigned int maxSilentTime;
|
|||
from a CD. */
|
||||
extern Paths substituters;
|
||||
|
||||
/* Whether to use build hooks (for distributed builds). Sometimes
|
||||
users want to disable this from the command-line. */
|
||||
extern bool useBuildHook;
|
||||
|
||||
Strings querySetting(const string & name, const Strings & def);
|
||||
|
||||
string querySetting(const string & name, const string & def);
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ RemoteStore::RemoteStore()
|
|||
unsigned int magic = readInt(from);
|
||||
if (magic != WORKER_MAGIC_2) throw Error("protocol mismatch");
|
||||
|
||||
unsigned int daemonVersion = readInt(from);
|
||||
daemonVersion = readInt(from);
|
||||
if (GET_PROTOCOL_MAJOR(daemonVersion) != GET_PROTOCOL_MAJOR(PROTOCOL_VERSION))
|
||||
throw Error("Nix daemon protocol version not supported");
|
||||
writeInt(PROTOCOL_VERSION, to);
|
||||
|
|
@ -203,6 +203,8 @@ void RemoteStore::setOptions()
|
|||
writeInt(verbosity, to);
|
||||
writeInt(maxBuildJobs, to);
|
||||
writeInt(maxSilentTime, to);
|
||||
if (GET_PROTOCOL_MINOR(daemonVersion) >= 2)
|
||||
writeInt(useBuildHook, to);
|
||||
processStderr();
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +314,9 @@ Path RemoteStore::queryDeriver(const Path & path)
|
|||
writeInt(wopQueryDeriver, to);
|
||||
writeString(path, to);
|
||||
processStderr();
|
||||
return readStorePath(from);
|
||||
Path drvPath = readString(from);
|
||||
if (drvPath != "") assertStorePath(drvPath);
|
||||
return drvPath;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ private:
|
|||
FdSink to;
|
||||
FdSource from;
|
||||
Pid child;
|
||||
unsigned int daemonVersion;
|
||||
|
||||
void processStderr(Sink * sink = 0, Source * source = 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ namespace nix {
|
|||
#define WORKER_MAGIC_1 0x6e697863
|
||||
#define WORKER_MAGIC_2 0x6478696f
|
||||
|
||||
#define PROTOCOL_VERSION 0x101
|
||||
#define PROTOCOL_VERSION 0x102
|
||||
#define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
|
||||
#define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)
|
||||
|
||||
|
||||
typedef enum {
|
||||
|
|
|
|||
|
|
@ -588,12 +588,17 @@ static void opExport(Strings opFlags, Strings opArgs)
|
|||
|
||||
static void opImport(Strings opFlags, Strings opArgs)
|
||||
{
|
||||
if (!opFlags.empty()) throw UsageError("unknown flag");
|
||||
bool requireSignature = false;
|
||||
for (Strings::iterator i = opFlags.begin();
|
||||
i != opFlags.end(); ++i)
|
||||
if (*i == "--require-signature") requireSignature = true;
|
||||
else throw UsageError(format("unknown flag `%1%'") % *i);
|
||||
|
||||
if (!opArgs.empty()) throw UsageError("no arguments expected");
|
||||
|
||||
FdSource source(STDIN_FILENO);
|
||||
while (readInt(source) == 1)
|
||||
cout << format("%1%\n") % store->importPath(false, source) << std::flush;
|
||||
cout << format("%1%\n") % store->importPath(requireSignature, source) << std::flush;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,8 @@ struct TunnelSource : Source
|
|||
};
|
||||
|
||||
|
||||
static void performOp(Source & from, Sink & to, unsigned int op)
|
||||
static void performOp(unsigned int clientVersion,
|
||||
Source & from, Sink & to, unsigned int op)
|
||||
{
|
||||
switch (op) {
|
||||
|
||||
|
|
@ -666,6 +667,8 @@ static void performOp(Source & from, Sink & to, unsigned int op)
|
|||
verbosity = (Verbosity) readInt(from);
|
||||
maxBuildJobs = readInt(from);
|
||||
maxSilentTime = readInt(from);
|
||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 2)
|
||||
useBuildHook = readInt(from) != 0;
|
||||
startWork();
|
||||
stopWork();
|
||||
break;
|
||||
|
|
@ -755,7 +758,7 @@ static void processConnection()
|
|||
|
||||
try {
|
||||
printMsg(lvlInfo, format("Processing op '%1%' with pid '%2%'") % op % myPid);
|
||||
performOp(from, to, op);
|
||||
performOp(clientVersion, from, to, op);
|
||||
printMsg(lvlInfo, format("Processed op '%1%'") % op);
|
||||
} catch (Error & e) {
|
||||
stopWork(false, e.msg());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue