Allow $NIX_BUILD_HOOK to be relative to Nix libexec directory

This commit is contained in:
Eelco Dolstra 2014-07-11 13:55:06 +02:00
parent d0eb970fb4
commit e196eecbe6
2 changed files with 5 additions and 3 deletions

View File

@ -590,7 +590,9 @@ HookInstance::HookInstance()
{ {
debug("starting build hook"); debug("starting build hook");
Path buildHook = absPath(getEnv("NIX_BUILD_HOOK")); Path buildHook = getEnv("NIX_BUILD_HOOK");
if (string(buildHook, 0, 1) != "/") buildHook = settings.nixLibexecDir + "/nix/" + buildHook;
buildHook = canonPath(buildHook);
/* Create a pipe to get the output of the child. */ /* Create a pipe to get the output of the child. */
fromHook.create(); fromHook.create();
@ -1503,7 +1505,7 @@ void DerivationGoal::buildDone()
HookReply DerivationGoal::tryBuildHook() HookReply DerivationGoal::tryBuildHook()
{ {
if (!settings.useBuildHook || getEnv("NIX_BUILD_HOOK") == "") return rpDecline; if (!settings.useBuildHook) return rpDecline;
if (!worker.hook) if (!worker.hook)
worker.hook = std::shared_ptr<HookInstance>(new HookInstance); worker.hook = std::shared_ptr<HookInstance>(new HookInstance);

View File

@ -38,7 +38,7 @@ Settings::Settings()
thisSystem = SYSTEM; thisSystem = SYSTEM;
maxSilentTime = 0; maxSilentTime = 0;
buildTimeout = 0; buildTimeout = 0;
useBuildHook = true; useBuildHook = getEnv("NIX_BUILD_HOOK") != "";
printBuildTrace = false; printBuildTrace = false;
reservedSize = 1024 * 1024; reservedSize = 1024 * 1024;
fsyncMetadata = true; fsyncMetadata = true;