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: 62f712c8aedc
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6fadb3fc03a1
Choose a head ref

Commits on Jan 5, 2020

  1. build: fix sandboxing on darwin

    Starting ba87b08 getEnv now returns an
    std::optional which means these getEnv() != "" conditions no longer happen
    if the variables are not defined.
    LnL7 committed Jan 5, 2020

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    66fccd5 View commit details

Commits on Jan 6, 2020

  1. Merge pull request #3303 from LnL7/darwin-sandbox

    build: fix sandboxing on darwin
    edolstra authored Jan 6, 2020

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    Ma27 Maximilian Bosch
    Copy the full SHA
    e2988f4 View commit details
  2. Fix use of uninitialized store path

    Fixes 'building of '/nix/store/00000000000000000000000000000000-': ...'.
    edolstra committed Jan 6, 2020
    Copy the full SHA
    bc22a7e View commit details
  3. Copy the full SHA
    cb2d348 View commit details
  4. Add support for \u escape in fromJSON

    As fromTOML supports \u and \U escapes, bring fromJSON on par. As JSON defaults
    to UTF-8 encoding (every JSON parser must support UTF-8), this change parses the
    `\u hex hex hex hex` sequence (\u followed by 4 hexadecimal digits) into an
    UTF-8 representation.
    
    Add a test to verify correct parsing, using all escape sequences from json.org.
    knl committed Jan 6, 2020
    Copy the full SHA
    52a8f92 View commit details

Commits on Jan 7, 2020

  1. Merge pull request #3305 from knl/interpret-u-escapes-in-JSON-strings

    Add support for unicode escape sequences in fromJSON
    edolstra authored Jan 7, 2020
    Copy the full SHA
    04bbfa6 View commit details

Commits on Jan 9, 2020

  1. Copy the full SHA
    f1fac0b View commit details
  2. Copy the full SHA
    a350d0b View commit details
  3. Copy the full SHA
    7ccfa7c View commit details
  4. Copy the full SHA
    3895e78 View commit details

Commits on Jan 10, 2020

  1. Merge pull request #3307 from yorickvP/yorickvp/nlohmann-fromJSON

    builtins.fromJSON: use nlohmann/json parser instead of custom parser
    edolstra authored Jan 10, 2020
    Copy the full SHA
    72a5075 View commit details
  2. Merge pull request #3308 from trusktr/patch-1

    Add a link to official channels in the docs.
    edolstra authored Jan 10, 2020
    Copy the full SHA
    6f046fa View commit details

Commits on Jan 11, 2020

  1. libexpr: show expression in assertion errors

    Includes the expression of the condition in the assertion message if
    the assertion failed, making assertions much easier to debug. eg.
    
        error: assertion (withPython -> (python2Packages != null)) failed at pkgs/tools/security/nmap/default.nix:11:1
    LnL7 committed Jan 11, 2020
    Copy the full SHA
    307bcb9 View commit details

Commits on Jan 13, 2020

  1. Fix Nixpkgs dependency

    edolstra committed Jan 13, 2020
    5
    Copy the full SHA
    30c9ca3 View commit details
  2. Copy the full SHA
    835e541 View commit details
  3. Test PRECOMPILE_HEADERS=0

    edolstra committed Jan 13, 2020
    Copy the full SHA
    c86c71c View commit details
  4. unbreak build without pch

    Ericson2314 authored and edolstra committed Jan 13, 2020
    Copy the full SHA
    d64ab51 View commit details
  5. Copy the full SHA
    bfaa4db View commit details
  6. Tweak error message

    edolstra committed Jan 13, 2020
    Copy the full SHA
    c3181e2 View commit details
  7. build: remove warning when in sandboxing test mode

    Introduced in 66fccd5, but somehow
    breaks the secure-drv-outputs test.
    LnL7 committed Jan 13, 2020
    Copy the full SHA
    8b3217f View commit details

Commits on Jan 14, 2020

  1. doc: touchup release notes for 2.3

    - At the top of the release notes, we announce sandboxing is now enabled by default,
    then at the bottom it says it's now disabled when missing kernel support. These
    can be merged into one point for clarity.
    
    - The point about `max-jobs` defaulting to 1 appears unrelated to sandboxing.
    bhipple committed Jan 14, 2020
    Copy the full SHA
    5d24e18 View commit details
  2. Merge pull request #3318 from bhipple/doc/relnotes-2.3

    doc: touchup release notes for 2.3
    edolstra authored Jan 14, 2020
    Copy the full SHA
    e74b221 View commit details
  3. Merge pull request #3316 from LnL7/fix-secure-drv-outputs

    build: remove warning when in sandboxing test mode
    edolstra authored Jan 14, 2020
    Copy the full SHA
    8b09105 View commit details

Commits on Jan 21, 2020

  1. Fix derivation computation with __structuredAttrs and multiple outputs

    Fixes
    
      error: derivation '/nix/store/klivma7r7h5lndb99f7xxmlh5whyayvg-zlib-1.2.11.drv' has incorrect output '/nix/store/fv98nnx5ykgbq8sqabilkgkbc4169q05-zlib-1.2.11-dev', should be '/nix/store/adm7pilzlj3z5k249s8b4wv3scprhzi1-zlib-1.2.11-dev'
    edolstra committed Jan 21, 2020
    Copy the full SHA
    aef635d View commit details
  2. Copy the full SHA
    6fadb3f View commit details
3 changes: 3 additions & 0 deletions doc/manual/command-ref/nix-channel.xml
Original file line number Diff line number Diff line change
@@ -36,6 +36,9 @@ stay up-to-date with a set of pre-built Nix expressions. A Nix
channel is just a URL that points to a place containing a set of Nix
expressions. <phrase condition="manual">See also <xref
linkend="sec-channels" />.</phrase></para>

<para>To see the list of official NixOS channels, visit <link
xlink:href="https://nixos.org/channels" />.</para>

<para>This command has the following operations:

3 changes: 3 additions & 0 deletions doc/manual/packages/channels.xml
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@ a set of Nix expressions and a manifest. Using the command <link
linkend="sec-nix-channel"><command>nix-channel</command></link> you
can automatically stay up to date with whatever is available at that
URL.</para>

<para>To see the list of official NixOS channels, visit <link
xlink:href="https://nixos.org/channels" />.</para>

<para>You can “subscribe” to a channel using
<command>nix-channel --add</command>, e.g.,
15 changes: 7 additions & 8 deletions doc/manual/release-notes/rl-2.3.xml
Original file line number Diff line number Diff line change
@@ -33,9 +33,13 @@ incompatible changes:</para>
</listitem>

<listitem>
<para>The installer now enables sandboxing by default on
Linux. The <literal>max-jobs</literal> setting now defaults to
1.</para>
<para>The installer now enables sandboxing by default on Linux when the
system has the necessary kernel support.
</para>
</listitem>

<listitem>
<para>The <literal>max-jobs</literal> setting now defaults to 1.</para>
</listitem>

<listitem>
@@ -82,11 +86,6 @@ incompatible changes:</para>
the duration of Nix function calls to stderr.</para>
</listitem>

<listitem>
<para>On Linux, sandboxing is now disabled by default on systems
that don’t have the necessary kernel support.</para>
</listitem>

</itemizedlist>

</section>
5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -354,6 +354,8 @@
name = "nix-build";
src = self.hydraJobs.tarball;

enableParallelBuilding = true;

buildInputs = buildDeps;

dontInstall = false;
@@ -366,6 +368,9 @@
# syntax-check generated dot files, it still requires some
# fonts. So provide those.
FONTCONFIG_FILE = texFunctions.fontsConf;

# To test building without precompiled headers.
makeFlagsArray = [ "PRECOMPILE_HEADERS=0" ];
};

# System tests.
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ useClang ? false }:

with import (builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/bb1013511e1e5edcf314df8321acf2f3c536df0d.tar.gz) {};
with import (builtins.fetchTarball https://github.com/NixOS/nixpkgs/archive/nixos-19.09.tar.gz) {};

with import ./release-common.nix { inherit pkgs; };

11 changes: 7 additions & 4 deletions src/libexpr/eval.cc
Original file line number Diff line number Diff line change
@@ -566,9 +566,9 @@ LocalNoInlineNoReturn(void throwTypeError(const char * s, const ExprLambda & fun
throw TypeError(format(s) % fun.showNamePos() % s2 % pos);
}

LocalNoInlineNoReturn(void throwAssertionError(const char * s, const Pos & pos))
LocalNoInlineNoReturn(void throwAssertionError(const char * s, const string & s1, const Pos & pos))
{
throw AssertionError(format(s) % pos);
throw AssertionError(format(s) % s1 % pos);
}

LocalNoInlineNoReturn(void throwUndefinedVarError(const char * s, const string & s1, const Pos & pos))
@@ -1302,8 +1302,11 @@ void ExprIf::eval(EvalState & state, Env & env, Value & v)

void ExprAssert::eval(EvalState & state, Env & env, Value & v)
{
if (!state.evalBool(env, cond, pos))
throwAssertionError("assertion failed at %1%", pos);
if (!state.evalBool(env, cond, pos)) {
std::ostringstream out;
cond->show(out);
throwAssertionError("assertion '%1%' failed at %2%", out.str(), pos);
}
body->eval(state, env, v);
}

244 changes: 128 additions & 116 deletions src/libexpr/json-to-value.cc
Original file line number Diff line number Diff line change
@@ -1,149 +1,161 @@
#include "json-to-value.hh"

#include <cstring>
#include <variant>
#include <nlohmann/json.hpp>

namespace nix {
using json = nlohmann::json;
using std::unique_ptr;

namespace nix {

static void skipWhitespace(const char * & s)
{
while (*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r') s++;
}
// for more information, refer to
// https://github.com/nlohmann/json/blob/master/include/nlohmann/detail/input/json_sax.hpp
class JSONSax : nlohmann::json_sax<json> {
class JSONState {
protected:
unique_ptr<JSONState> parent;
Value * v;
public:
virtual unique_ptr<JSONState> resolve(EvalState &)
{
throw std::logic_error("tried to close toplevel json parser state");
};
explicit JSONState(unique_ptr<JSONState>&& p) : parent(std::move(p)), v(nullptr) {};
explicit JSONState(Value* v) : v(v) {};
JSONState(JSONState& p) = delete;
Value& value(EvalState & state)
{
if (v == nullptr)
v = state.allocValue();
return *v;
};
virtual ~JSONState() {};
virtual void add() {};
};

class JSONObjectState : public JSONState {
using JSONState::JSONState;
ValueMap attrs = ValueMap();
virtual unique_ptr<JSONState> resolve(EvalState & state) override
{
Value& v = parent->value(state);
state.mkAttrs(v, attrs.size());
for (auto & i : attrs)
v.attrs->push_back(Attr(i.first, i.second));
return std::move(parent);
}
virtual void add() override { v = nullptr; };
public:
void key(string_t& name, EvalState & state)
{
attrs[state.symbols.create(name)] = &value(state);
}
};

class JSONListState : public JSONState {
ValueVector values = ValueVector();
virtual unique_ptr<JSONState> resolve(EvalState & state) override
{
Value& v = parent->value(state);
state.mkList(v, values.size());
for (size_t n = 0; n < values.size(); ++n) {
v.listElems()[n] = values[n];
}
return std::move(parent);
}
virtual void add() override {
values.push_back(v);
v = nullptr;
};
public:
JSONListState(unique_ptr<JSONState>&& p, std::size_t reserve) : JSONState(std::move(p))
{
values.reserve(reserve);
}
};

EvalState & state;
unique_ptr<JSONState> rs;

static string parseJSONString(const char * & s)
{
string res;
if (*s++ != '"') throw JSONParseError("expected JSON string");
while (*s != '"') {
if (!*s) throw JSONParseError("got end-of-string in JSON string");
if (*s == '\\') {
s++;
if (*s == '"') res += '"';
else if (*s == '\\') res += '\\';
else if (*s == '/') res += '/';
else if (*s == '/') res += '/';
else if (*s == 'b') res += '\b';
else if (*s == 'f') res += '\f';
else if (*s == 'n') res += '\n';
else if (*s == 'r') res += '\r';
else if (*s == 't') res += '\t';
else if (*s == 'u') throw JSONParseError("\\u characters in JSON strings are currently not supported");
else throw JSONParseError("invalid escaped character in JSON string");
s++;
} else
res += *s++;
template<typename T, typename... Args> inline bool handle_value(T f, Args... args)
{
f(rs->value(state), args...);
rs->add();
return true;
}
s++;
return res;
}

public:
JSONSax(EvalState & state, Value & v) : state(state), rs(new JSONState(&v)) {};

static void parseJSON(EvalState & state, const char * & s, Value & v)
{
skipWhitespace(s);

if (!*s) throw JSONParseError("expected JSON value");

if (*s == '[') {
s++;
ValueVector values;
values.reserve(128);
skipWhitespace(s);
while (1) {
if (values.empty() && *s == ']') break;
Value * v2 = state.allocValue();
parseJSON(state, s, *v2);
values.push_back(v2);
skipWhitespace(s);
if (*s == ']') break;
if (*s != ',') throw JSONParseError("expected ',' or ']' after JSON array element");
s++;
}
s++;
state.mkList(v, values.size());
for (size_t n = 0; n < values.size(); ++n)
v.listElems()[n] = values[n];
bool null()
{
return handle_value(mkNull);
}

else if (*s == '{') {
s++;
ValueMap attrs;
while (1) {
skipWhitespace(s);
if (attrs.empty() && *s == '}') break;
string name = parseJSONString(s);
skipWhitespace(s);
if (*s != ':') throw JSONParseError("expected ':' in JSON object");
s++;
Value * v2 = state.allocValue();
parseJSON(state, s, *v2);
attrs[state.symbols.create(name)] = v2;
skipWhitespace(s);
if (*s == '}') break;
if (*s != ',') throw JSONParseError("expected ',' or '}' after JSON member");
s++;
}
state.mkAttrs(v, attrs.size());
for (auto & i : attrs)
v.attrs->push_back(Attr(i.first, i.second));
v.attrs->sort();
s++;
bool boolean(bool val)
{
return handle_value(mkBool, val);
}

else if (*s == '"') {
mkString(v, parseJSONString(s));
bool number_integer(number_integer_t val)
{
return handle_value(mkInt, val);
}

else if (isdigit(*s) || *s == '-' || *s == '.' ) {
// Buffer into a string first, then use built-in C++ conversions
std::string tmp_number;
ValueType number_type = tInt;
bool number_unsigned(number_unsigned_t val)
{
return handle_value(mkInt, val);
}

while (isdigit(*s) || *s == '-' || *s == '.' || *s == 'e' || *s == 'E') {
if (*s == '.' || *s == 'e' || *s == 'E')
number_type = tFloat;
tmp_number += *s++;
}
bool number_float(number_float_t val, const string_t& s)
{
return handle_value(mkFloat, val);
}

try {
if (number_type == tFloat)
mkFloat(v, stod(tmp_number));
else
mkInt(v, stol(tmp_number));
} catch (std::invalid_argument & e) {
throw JSONParseError("invalid JSON number");
} catch (std::out_of_range & e) {
throw JSONParseError("out-of-range JSON number");
}
bool string(string_t& val)
{
return handle_value<void(Value&, const char*)>(mkString, val.c_str());
}

else if (strncmp(s, "true", 4) == 0) {
s += 4;
mkBool(v, true);
bool start_object(std::size_t len)
{
rs = std::make_unique<JSONObjectState>(std::move(rs));
return true;
}

else if (strncmp(s, "false", 5) == 0) {
s += 5;
mkBool(v, false);
bool key(string_t& name)
{
dynamic_cast<JSONObjectState*>(rs.get())->key(name, state);
return true;
}

else if (strncmp(s, "null", 4) == 0) {
s += 4;
mkNull(v);
bool end_object() {
rs = rs->resolve(state);
rs->add();
return true;
}

else throw JSONParseError("unrecognised JSON value");
}
bool end_array() {
return end_object();
}

bool start_array(size_t len) {
rs = std::make_unique<JSONListState>(std::move(rs),
len != std::numeric_limits<size_t>::max() ? len : 128);
return true;
}

bool parse_error(std::size_t, const std::string&, const nlohmann::detail::exception& ex) {
throw JSONParseError(ex.what());
}
};

void parseJSON(EvalState & state, const string & s_, Value & v)
{
const char * s = s_.c_str();
parseJSON(state, s, v);
skipWhitespace(s);
if (*s) throw JSONParseError(format("expected end-of-string while parsing JSON value: %1%") % s);
JSONSax parser(state, v);
bool res = json::sax_parse(s_, &parser);
if (!res)
throw JSONParseError("Invalid JSON Value");
}


}
2 changes: 2 additions & 0 deletions src/libexpr/primops.cc
Original file line number Diff line number Diff line change
@@ -732,6 +732,8 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
the hash. */
for (auto & i : outputs) {
if (!jsonObject) drv.env[i] = "";
drv.outputs.insert_or_assign(i,
DerivationOutput(StorePath::dummy.clone(), "", ""));
}

Hash h = hashDerivationModulo(*state.store, Derivation(drv), true);
Loading