diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-06-22 22:43:53 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-06-23 01:32:46 +0200 |
commit | d3176ce076407ef3e63667c0436bccf8be317ae4 (patch) | |
tree | 8dcaaab834d6afa14948239e6e6c864ba025e8e6 /src/libstore/build/hook-instance.cc | |
parent | 3c48c4b4f7a8d5a7b045b9dbee1310d20ca7750b (diff) |
Fix build-remote in nix-static
'build-remote' is now executed via /proc/self/exe so it always works.
Diffstat (limited to 'src/libstore/build/hook-instance.cc')
-rw-r--r-- | src/libstore/build/hook-instance.cc | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/libstore/build/hook-instance.cc b/src/libstore/build/hook-instance.cc index 0f6f580be..1f19ddccc 100644 --- a/src/libstore/build/hook-instance.cc +++ b/src/libstore/build/hook-instance.cc @@ -7,6 +7,22 @@ HookInstance::HookInstance() { debug("starting build hook '%s'", settings.buildHook); + auto buildHookArgs = tokenizeString<std::list<std::string>>(settings.buildHook.get()); + + if (buildHookArgs.empty()) + throw Error("'build-hook' setting is empty"); + + auto buildHook = buildHookArgs.front(); + buildHookArgs.pop_front(); + + Strings args; + + for (auto & arg : buildHookArgs) + args.push_back(arg); + + args.push_back(std::string(baseNameOf(settings.buildHook.get()))); + args.push_back(std::to_string(verbosity)); + /* Create a pipe to get the output of the child. */ fromHook.create(); @@ -36,14 +52,9 @@ HookInstance::HookInstance() if (dup2(builderOut.readSide.get(), 5) == -1) throw SysError("dupping builder's stdout/stderr"); - Strings args = { - std::string(baseNameOf(settings.buildHook.get())), - std::to_string(verbosity), - }; - - execv(settings.buildHook.get().c_str(), stringsToCharPtrs(args).data()); + execv(buildHook.c_str(), stringsToCharPtrs(args).data()); - throw SysError("executing '%s'", settings.buildHook); + throw SysError("executing '%s'", buildHook); }); pid.setSeparatePG(true); |