mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Revert "Add the pre-build hook."
Going to reimplement differently.
This reverts commit 1e4a4a2e9f
.
This commit is contained in:
parent
9b1866b721
commit
fd6774e285
4 changed files with 0 additions and 145 deletions
|
@ -562,39 +562,6 @@ flag, e.g. <literal>--option gc-keep-outputs false</literal>.</para>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
<varlistentry xml:id="conf-pre-build-hook"><term><literal>pre-build-hook</literal></term>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
|
|
||||||
<para>If set, the path to a program that can set extra
|
|
||||||
derivation-specific settings for this system. This is used for settings
|
|
||||||
that can't be captured by the derivation model itself and are too
|
|
||||||
variable between different versions of the same system to be hard-coded
|
|
||||||
into nix.</para>
|
|
||||||
|
|
||||||
<para>The hook listens on <literal>stdin</literal> for a derivation path.
|
|
||||||
It can then send a series of commands to modify various settings, followed
|
|
||||||
by an empty line to indicate completion. The currently recognized commands
|
|
||||||
are:</para>
|
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry xml:id="extra-chroot-dirs"><term><literal>extra-chroot-dirs</literal></term>
|
|
||||||
|
|
||||||
<listitem>
|
|
||||||
|
|
||||||
<para>Pass a list of files and directories to be included in the
|
|
||||||
chroot for this build. One entry per line, terminated by an empty
|
|
||||||
line.</para>
|
|
||||||
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
</listitem>
|
|
||||||
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
|
@ -89,7 +89,6 @@ static string pathNullDevice = "/dev/null";
|
||||||
/* Forward definition. */
|
/* Forward definition. */
|
||||||
class Worker;
|
class Worker;
|
||||||
struct HookInstance;
|
struct HookInstance;
|
||||||
struct PreBuildHookInstance;
|
|
||||||
|
|
||||||
|
|
||||||
/* A pointer to a goal. */
|
/* A pointer to a goal. */
|
||||||
|
@ -270,8 +269,6 @@ public:
|
||||||
|
|
||||||
std::shared_ptr<HookInstance> hook;
|
std::shared_ptr<HookInstance> hook;
|
||||||
|
|
||||||
std::shared_ptr<PreBuildHookInstance> preBuildHook;
|
|
||||||
|
|
||||||
Worker(LocalStore & store);
|
Worker(LocalStore & store);
|
||||||
~Worker();
|
~Worker();
|
||||||
|
|
||||||
|
@ -652,72 +649,6 @@ HookInstance::~HookInstance()
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
struct PreBuildHookInstance
|
|
||||||
{
|
|
||||||
/* Pipes for talking to the build hook. */
|
|
||||||
Pipe toHook;
|
|
||||||
|
|
||||||
/* Pipe for the hook's standard output/error. */
|
|
||||||
Pipe fromHook;
|
|
||||||
|
|
||||||
/* The process ID of the hook. */
|
|
||||||
Pid pid;
|
|
||||||
|
|
||||||
PreBuildHookInstance();
|
|
||||||
|
|
||||||
~PreBuildHookInstance();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
PreBuildHookInstance::PreBuildHookInstance()
|
|
||||||
{
|
|
||||||
debug("starting pre-build hook");
|
|
||||||
|
|
||||||
/* Create a pipe to get the output of the child. */
|
|
||||||
fromHook.create();
|
|
||||||
|
|
||||||
/* Create the communication pipes. */
|
|
||||||
toHook.create();
|
|
||||||
|
|
||||||
/* Fork the hook. */
|
|
||||||
pid = startProcess([&]() {
|
|
||||||
|
|
||||||
commonChildInit(fromHook);
|
|
||||||
|
|
||||||
if (chdir("/") == -1) throw SysError("changing into /");
|
|
||||||
|
|
||||||
/* Dup the communication pipes. */
|
|
||||||
if (dup2(toHook.readSide, STDIN_FILENO) == -1)
|
|
||||||
throw SysError("dupping to-hook read side");
|
|
||||||
|
|
||||||
setenv("_NIX_OPTIONS", settings.pack().c_str(), 1);
|
|
||||||
|
|
||||||
execl(settings.preBuildHook.c_str(), settings.preBuildHook.c_str(),
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
throw SysError(format("executing ‘%1%’") % settings.preBuildHook);
|
|
||||||
});
|
|
||||||
|
|
||||||
pid.setSeparatePG(true);
|
|
||||||
fromHook.writeSide.close();
|
|
||||||
toHook.readSide.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PreBuildHookInstance::~PreBuildHookInstance()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
toHook.writeSide.close();
|
|
||||||
pid.kill(true);
|
|
||||||
} catch (...) {
|
|
||||||
ignoreException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
typedef map<string, string> HashRewrites;
|
typedef map<string, string> HashRewrites;
|
||||||
|
|
||||||
|
|
||||||
|
@ -882,13 +813,6 @@ private:
|
||||||
/* Is the build hook willing to perform the build? */
|
/* Is the build hook willing to perform the build? */
|
||||||
HookReply tryBuildHook();
|
HookReply tryBuildHook();
|
||||||
|
|
||||||
/* Run the pre-build hook, which can set system-specific
|
|
||||||
per-derivation settings too complex/volatile to hard-code
|
|
||||||
in nix itself */
|
|
||||||
void runPreBuildHook();
|
|
||||||
|
|
||||||
PathSet extraChrootDirs;
|
|
||||||
|
|
||||||
/* Start building a derivation. */
|
/* Start building a derivation. */
|
||||||
void startBuilder();
|
void startBuilder();
|
||||||
|
|
||||||
|
@ -1254,9 +1178,6 @@ void DerivationGoal::inputsRealised()
|
||||||
foreach (DerivationOutputs::iterator, i, drv.outputs)
|
foreach (DerivationOutputs::iterator, i, drv.outputs)
|
||||||
if (i->second.hash == "") fixedOutput = false;
|
if (i->second.hash == "") fixedOutput = false;
|
||||||
|
|
||||||
/* Ask the pre-build hook for any required settings */
|
|
||||||
runPreBuildHook();
|
|
||||||
|
|
||||||
/* Okay, try to build. Note that here we don't wait for a build
|
/* Okay, try to build. Note that here we don't wait for a build
|
||||||
slot to become available, since we don't need one if there is a
|
slot to become available, since we don't need one if there is a
|
||||||
build hook. */
|
build hook. */
|
||||||
|
@ -1873,7 +1794,6 @@ void DerivationGoal::startBuilder()
|
||||||
PathSet dirs = tokenizeString<StringSet>(settings.get("build-chroot-dirs", defaultChrootDirs));
|
PathSet dirs = tokenizeString<StringSet>(settings.get("build-chroot-dirs", defaultChrootDirs));
|
||||||
PathSet dirs2 = tokenizeString<StringSet>(settings.get("build-extra-chroot-dirs", string("")));
|
PathSet dirs2 = tokenizeString<StringSet>(settings.get("build-extra-chroot-dirs", string("")));
|
||||||
dirs.insert(dirs2.begin(), dirs2.end());
|
dirs.insert(dirs2.begin(), dirs2.end());
|
||||||
dirs.insert(extraChrootDirs.begin(), extraChrootDirs.end());
|
|
||||||
|
|
||||||
for (auto & i : dirs) {
|
for (auto & i : dirs) {
|
||||||
size_t p = i.find('=');
|
size_t p = i.find('=');
|
||||||
|
@ -2874,33 +2794,6 @@ Path DerivationGoal::addHashRewrite(const Path & path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DerivationGoal::runPreBuildHook()
|
|
||||||
{
|
|
||||||
if (settings.preBuildHook == "")
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!worker.preBuildHook)
|
|
||||||
worker.preBuildHook = std::make_shared<PreBuildHookInstance>();
|
|
||||||
|
|
||||||
writeLine(worker.preBuildHook->toHook.writeSide, drvPath);
|
|
||||||
while (true) {
|
|
||||||
string s = readLine(worker.preBuildHook->fromHook.readSide);
|
|
||||||
if (s == "extra-chroot-dirs") {
|
|
||||||
while (true) {
|
|
||||||
string s = readLine(worker.preBuildHook->fromHook.readSide);
|
|
||||||
if (s == "")
|
|
||||||
break;
|
|
||||||
extraChrootDirs.emplace(std::move(s));
|
|
||||||
}
|
|
||||||
} else if (s == "") {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
throw Error(format("unknown pre-build hook command ‘%1%’") % s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,6 @@ void Settings::update()
|
||||||
_get(logServers, "log-servers");
|
_get(logServers, "log-servers");
|
||||||
_get(enableImportNative, "allow-unsafe-native-code-during-evaluation");
|
_get(enableImportNative, "allow-unsafe-native-code-during-evaluation");
|
||||||
_get(useCaseHack, "use-case-hack");
|
_get(useCaseHack, "use-case-hack");
|
||||||
_get(preBuildHook, "pre-build-hook");
|
|
||||||
|
|
||||||
string subs = getEnv("NIX_SUBSTITUTERS", "default");
|
string subs = getEnv("NIX_SUBSTITUTERS", "default");
|
||||||
if (subs == "default") {
|
if (subs == "default") {
|
||||||
|
|
|
@ -206,10 +206,6 @@ struct Settings {
|
||||||
/* Whether the importNative primop should be enabled */
|
/* Whether the importNative primop should be enabled */
|
||||||
bool enableImportNative;
|
bool enableImportNative;
|
||||||
|
|
||||||
/* The hook to run just before a build to set derivation-specific
|
|
||||||
build settings */
|
|
||||||
Path preBuildHook;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SettingsMap settings, overrides;
|
SettingsMap settings, overrides;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue