Merge remote-tracking branch 'origin/master' into flakes

This commit is contained in:
Eelco Dolstra 2019-06-17 14:45:12 +02:00
commit d6c4fe55db
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
7 changed files with 66 additions and 17 deletions

View file

@ -43,7 +43,7 @@ encountered</quote>).</para></footnote>.</para>
<simplesect xml:id="sect-let-expressions"><title>Let-expressions</title> <simplesect xml:id="sect-let-expressions"><title>Let-expressions</title>
<para>A let-expression allows you define local variables for an <para>A let-expression allows you to define local variables for an
expression. For instance, expression. For instance,
<programlisting> <programlisting>

View file

@ -749,9 +749,6 @@ setup_default_profile() {
place_nix_configuration() { place_nix_configuration() {
cat <<EOF > "$SCRATCH/nix.conf" cat <<EOF > "$SCRATCH/nix.conf"
build-users-group = $NIX_BUILD_GROUP_NAME build-users-group = $NIX_BUILD_GROUP_NAME
max-jobs = $NIX_USER_COUNT
cores = 1
EOF EOF
_sudo "to place the default nix daemon configuration (part 2)" \ _sudo "to place the default nix daemon configuration (part 2)" \
install -m 0664 "$SCRATCH/nix.conf" /etc/nix/nix.conf install -m 0664 "$SCRATCH/nix.conf" /etc/nix/nix.conf

View file

@ -35,6 +35,15 @@ MixCommonArgs::MixCommonArgs(const string & programName)
} }
}); });
mkFlag()
.longName("max-jobs")
.shortName('j')
.label("jobs")
.description("maximum number of parallel builds")
.handler([=](std::string s) {
settings.set("max-jobs", s);
});
std::string cat = "config"; std::string cat = "config";
globalConfig.convertToArgs(*this, cat); globalConfig.convertToArgs(*this, cat);

View file

@ -175,10 +175,6 @@ LegacyArgs::LegacyArgs(const std::string & programName,
.description("build from source if substitution fails") .description("build from source if substitution fails")
.set(&(bool&) settings.tryFallback, true); .set(&(bool&) settings.tryFallback, true);
mkFlag1('j', "max-jobs", "jobs", "maximum number of parallel builds", [=](std::string s) {
settings.set("max-jobs", s);
});
auto intSettingAlias = [&](char shortName, const std::string & longName, auto intSettingAlias = [&](char shortName, const std::string & longName,
const std::string & description, const std::string & dest) { const std::string & description, const std::string & dest) {
mkFlag<unsigned int>(shortName, longName, description, [=](unsigned int n) { mkFlag<unsigned int>(shortName, longName, description, [=](unsigned int n) {

View file

@ -38,6 +38,7 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <cstring> #include <cstring>
#include <termios.h>
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
@ -1558,8 +1559,8 @@ void DerivationGoal::buildDone()
if (hook) { if (hook) {
hook->builderOut.readSide = -1; hook->builderOut.readSide = -1;
hook->fromHook.readSide = -1; hook->fromHook.readSide = -1;
} } else
else builderOut.readSide = -1; builderOut.readSide = -1;
/* Close the log file. */ /* Close the log file. */
closeLogFile(); closeLogFile();
@ -2181,7 +2182,48 @@ void DerivationGoal::startBuilder()
Path logFile = openLogFile(); Path logFile = openLogFile();
/* Create a pipe to get the output of the builder. */ /* Create a pipe to get the output of the builder. */
builderOut.create(); //builderOut.create();
builderOut.readSide = posix_openpt(O_RDWR | O_NOCTTY);
if (!builderOut.readSide)
throw SysError("opening pseudoterminal master");
std::string slaveName(ptsname(builderOut.readSide.get()));
if (buildUser) {
if (chmod(slaveName.c_str(), 0600))
throw SysError("changing mode of pseudoterminal slave");
if (chown(slaveName.c_str(), buildUser->getUID(), 0))
throw SysError("changing owner of pseudoterminal slave");
} else {
if (grantpt(builderOut.readSide.get()))
throw SysError("granting access to pseudoterminal slave");
}
#if 0
// Mount the pt in the sandbox so that the "tty" command works.
// FIXME: this doesn't work with the new devpts in the sandbox.
if (useChroot)
dirsInChroot[slaveName] = {slaveName, false};
#endif
if (unlockpt(builderOut.readSide.get()))
throw SysError("unlocking pseudoterminal");
builderOut.writeSide = open(slaveName.c_str(), O_RDWR | O_NOCTTY);
if (!builderOut.writeSide)
throw SysError("opening pseudoterminal slave");
// Put the pt into raw mode to prevent \n -> \r\n translation.
struct termios term;
if (tcgetattr(builderOut.writeSide.get(), &term))
throw SysError("getting pseudoterminal attributes");
cfmakeraw(&term);
if (tcsetattr(builderOut.writeSide.get(), TCSANOW, &term))
throw SysError("putting pseudoterminal into raw mode");
result.startTime = time(0); result.startTime = time(0);
@ -2406,6 +2448,9 @@ void DerivationGoal::initEnv()
may change that in the future. So tell the builder which file may change that in the future. So tell the builder which file
descriptor to use for that. */ descriptor to use for that. */
env["NIX_LOG_FD"] = "2"; env["NIX_LOG_FD"] = "2";
/* Trigger colored output in various tools. */
env["TERM"] = "xterm-256color";
} }
@ -4361,14 +4406,15 @@ void Worker::waitForInput()
for (auto & k : fds2) { for (auto & k : fds2) {
if (FD_ISSET(k, &fds)) { if (FD_ISSET(k, &fds)) {
ssize_t rd = read(k, buffer.data(), buffer.size()); ssize_t rd = read(k, buffer.data(), buffer.size());
if (rd == -1) { // FIXME: is there a cleaner way to handle pt close
if (errno != EINTR) // than EIO? Is this even standard?
throw SysError(format("reading from %1%") if (rd == 0 || (rd == -1 && errno == EIO)) {
% goal->getName());
} else if (rd == 0) {
debug(format("%1%: got EOF") % goal->getName()); debug(format("%1%: got EOF") % goal->getName());
goal->handleEOF(k); goal->handleEOF(k);
j->fds.erase(k); j->fds.erase(k);
} else if (rd == -1) {
if (errno != EINTR)
throw SysError("%s: read failed", goal->getName());
} else { } else {
printMsg(lvlVomit, format("%1%: read %2% bytes") printMsg(lvlVomit, format("%1%: read %2% bytes")
% goal->getName() % rd); % goal->getName() % rd);

View file

@ -574,7 +574,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
else if (setSubstituters(settings.extraSubstituters)) else if (setSubstituters(settings.extraSubstituters))
; ;
else else
debug("ignoring untrusted setting '%s'", name); warn("ignoring the user-specified setting '%s', because it is a restricted setting and you are not a trusted user", name);
} catch (UsageError & e) { } catch (UsageError & e) {
warn(e.what()); warn(e.what());
} }

View file

@ -45,6 +45,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs
mkFlag() mkFlag()
.longName("print-build-logs") .longName("print-build-logs")
.shortName('L')
.description("print full build logs on stderr") .description("print full build logs on stderr")
.set(&printBuildLogs, true); .set(&printBuildLogs, true);