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");
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. */
fromHook.create();
@ -1503,7 +1505,7 @@ void DerivationGoal::buildDone()
HookReply DerivationGoal::tryBuildHook()
{
if (!settings.useBuildHook || getEnv("NIX_BUILD_HOOK") == "") return rpDecline;
if (!settings.useBuildHook) return rpDecline;
if (!worker.hook)
worker.hook = std::shared_ptr<HookInstance>(new HookInstance);

View file

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