Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 415fc233e3f0
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d6c4fe55db57
Choose a head ref
  • 17 commits
  • 7 files changed
  • 5 contributors

Commits on Mar 27, 2019

  1. install-multi-user: reduce max-jobs from 32 to 1

    Having max-jobs = 32 ($NIX_USER_COUNT is hardcoded to that value) may
    severely overload the machine. The nix.conf(5) manual page says max-jobs
    defaults to 1, so let's use that value.
    
    NOTE: Both max-jobs and cores are now being set to their default value,
    so they can be removed alltogether.
    bjornfor committed Mar 27, 2019
    Copy the full SHA
    dbe4c04 View commit details
  2. install-multi-user: remove unneeded settings from nix.conf

    Hardcoding the "max-jobs" and "cores" settings in nix.conf at install
    time, to the same value as Nix' built-in default, makes little sense to
    me.
    bjornfor committed Mar 27, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    pjanotti Paulo Janotti
    Copy the full SHA
    07d9981 View commit details

Commits on Jun 4, 2019

  1. Minor typo

    JorisE authored Jun 4, 2019

    Partially verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    4b0d613 View commit details
  2. Merge pull request #2918 from JorisE/patch-1

    Minor typo
    edolstra authored Jun 4, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    magneticstain Josh Carlson
    Copy the full SHA
    fb0ad89 View commit details

Commits on Jun 15, 2019

  1. Daemon: warn when an untrusted user cannot override a setting

    In a daemon-based Nix setup, some options cannot be overridden by a
    client unless the client's user is considered trusted.
    
    Currently, if an untrusted user tries to override one of those
    options, we are silently ignoring it.
    
    This can be pretty confusing in certain situations.
    
    e.g. a user thinks he disabled the sandbox when in reality he did not.
    
    We are now sending a warning message letting know the user some options
    have been ignored.
    
    Related to #1761.
    picnoir authored and grahamc committed Jun 15, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    magneticstain Josh Carlson
    Copy the full SHA
    9e0f5f8 View commit details
  2. Merge pull request #2931 from NinjaTrappeur/nin-add-warning-setting-u…

    …ntrusted
    
    Daemon: warn when an untrusted user cannot override a setting
    grahamc authored Jun 15, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7ce60a8 View commit details
  3. nix: Support -j flag

    edolstra committed Jun 15, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    34fa8ce View commit details
  4. Fix test failures when $TMPDIR changes

    (cherry picked from commit c38c726)
    edolstra committed Jun 15, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5064971 View commit details
  5. Copy the full SHA
    26bc876 View commit details

Commits on Jun 16, 2019

  1. Style fix

    edolstra committed Jun 16, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b693029 View commit details
  2. Run builds in a pseudo-terminal

    This allows many programs (e.g. gcc, clang, cmake) to print colorized
    log output (assuming $TERM is set to a value like "xterm").
    
    There are other ways to get colors, in particular setting
    CLICOLOR_FORCE, but they're less widely supported and can break
    programs that parse tool output.
    edolstra committed Jun 16, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    magneticstain Josh Carlson
    Copy the full SHA
    e84c265 View commit details
  3. Set $TERM

    edolstra committed Jun 16, 2019
    Copy the full SHA
    82ca6ef View commit details
  4. Hopefully fix macOS tests

    edolstra committed Jun 16, 2019
    Copy the full SHA
    2743bf0 View commit details

Commits on Jun 17, 2019

  1. Copy the full SHA
    3cc1125 View commit details
  2. Merge pull request #2746 from bjornfor/install-multi-user-defaults

    install-multi-user: reduce max-jobs from 32 to 1
    edolstra authored Jun 17, 2019
    Copy the full SHA
    38a4d38 View commit details
  3. Merge pull request #2878 from NixOS/run-in-pts

    Run builds in a pseudo-terminal
    edolstra authored Jun 17, 2019
    Copy the full SHA
    4b214e6 View commit details
  4. Copy the full SHA
    d6c4fe5 View commit details
Showing with 66 additions and 17 deletions.
  1. +1 −1 doc/manual/expressions/language-constructs.xml
  2. +0 −3 scripts/install-multi-user.sh
  3. +9 −0 src/libmain/common-args.cc
  4. +0 −4 src/libmain/shared.cc
  5. +54 −8 src/libstore/build.cc
  6. +1 −1 src/nix-daemon/nix-daemon.cc
  7. +1 −0 src/nix/main.cc
2 changes: 1 addition & 1 deletion doc/manual/expressions/language-constructs.xml
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ encountered</quote>).</para></footnote>.</para>

<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,

<programlisting>
3 changes: 0 additions & 3 deletions scripts/install-multi-user.sh
Original file line number Diff line number Diff line change
@@ -749,9 +749,6 @@ setup_default_profile() {
place_nix_configuration() {
cat <<EOF > "$SCRATCH/nix.conf"
build-users-group = $NIX_BUILD_GROUP_NAME
max-jobs = $NIX_USER_COUNT
cores = 1
EOF
_sudo "to place the default nix daemon configuration (part 2)" \
install -m 0664 "$SCRATCH/nix.conf" /etc/nix/nix.conf
9 changes: 9 additions & 0 deletions src/libmain/common-args.cc
Original file line number Diff line number Diff line change
@@ -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";
globalConfig.convertToArgs(*this, cat);

4 changes: 0 additions & 4 deletions src/libmain/shared.cc
Original file line number Diff line number Diff line change
@@ -175,10 +175,6 @@ LegacyArgs::LegacyArgs(const std::string & programName,
.description("build from source if substitution fails")
.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,
const std::string & description, const std::string & dest) {
mkFlag<unsigned int>(shortName, longName, description, [=](unsigned int n) {
62 changes: 54 additions & 8 deletions src/libstore/build.cc
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@
#include <unistd.h>
#include <errno.h>
#include <cstring>
#include <termios.h>

#include <pwd.h>
#include <grp.h>
@@ -1558,8 +1559,8 @@ void DerivationGoal::buildDone()
if (hook) {
hook->builderOut.readSide = -1;
hook->fromHook.readSide = -1;
}
else builderOut.readSide = -1;
} else
builderOut.readSide = -1;

/* Close the log file. */
closeLogFile();
@@ -2181,7 +2182,48 @@ void DerivationGoal::startBuilder()
Path logFile = openLogFile();

/* 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);

@@ -2406,6 +2448,9 @@ void DerivationGoal::initEnv()
may change that in the future. So tell the builder which file
descriptor to use for that. */
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) {
if (FD_ISSET(k, &fds)) {
ssize_t rd = read(k, buffer.data(), buffer.size());
if (rd == -1) {
if (errno != EINTR)
throw SysError(format("reading from %1%")
% goal->getName());
} else if (rd == 0) {
// FIXME: is there a cleaner way to handle pt close
// than EIO? Is this even standard?
if (rd == 0 || (rd == -1 && errno == EIO)) {
debug(format("%1%: got EOF") % goal->getName());
goal->handleEOF(k);
j->fds.erase(k);
} else if (rd == -1) {
if (errno != EINTR)
throw SysError("%s: read failed", goal->getName());
} else {
printMsg(lvlVomit, format("%1%: read %2% bytes")
% goal->getName() % rd);
2 changes: 1 addition & 1 deletion src/nix-daemon/nix-daemon.cc
Original file line number Diff line number Diff line change
@@ -574,7 +574,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
else if (setSubstituters(settings.extraSubstituters))
;
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) {
warn(e.what());
}
1 change: 1 addition & 0 deletions src/nix/main.cc
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ struct NixArgs : virtual MultiCommand, virtual MixCommonArgs

mkFlag()
.longName("print-build-logs")
.shortName('L')
.description("print full build logs on stderr")
.set(&printBuildLogs, true);