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: ddc6aaa8b242
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0a10854f857e
Choose a head ref
  • 14 commits
  • 45 files changed
  • 1 contributor

Commits on Mar 24, 2020

  1. EvalState::allocAttr(): Add convenience method

    (cherry picked from commit c02da99)
    edolstra committed Mar 24, 2020
    Copy the full SHA
    c34a20e View commit details
  2. Use std::string_view

    (cherry picked from commit 6529490)
    edolstra committed Mar 24, 2020
    Copy the full SHA
    5a7e7fc View commit details
  3. Add function for quoting strings

    (cherry picked from commit 7dcf5b0)
    edolstra committed Mar 24, 2020
    Copy the full SHA
    edc34cc View commit details
  4. findAlongAttrPath(): Throw AttrPathNotFound

    (cherry picked from commit 6b0ca8e)
    edolstra committed Mar 24, 2020
    Copy the full SHA
    1eb952d View commit details
  5. findAlongAttrPath(): Return position

    (cherry picked from commit 0b013a5)
    edolstra committed Mar 24, 2020
    Copy the full SHA
    c1ca4f0 View commit details
  6. nix edit: Support non-derivation attributes

    E.g.
    
      $ nix edit .#nixosConfigurations.bla
    
    now works.
    
    (cherry picked from commit d2032ed)
    edolstra committed Mar 24, 2020
    Copy the full SHA
    231a8aa View commit details
  7. Fix coverage build

    edolstra committed Mar 24, 2020
    Copy the full SHA
    76e7d95 View commit details
  8. buildenv: Eliminate global variables, other cleanup

    (cherry picked from commit b82f754)
    edolstra committed Mar 24, 2020
    Copy the full SHA
    f9611c7 View commit details
  9. absPath(): Use std::optional

    (cherry picked from commit 1bf9eb2)
    edolstra committed Mar 24, 2020
    Copy the full SHA
    4260a22 View commit details
  10. Copy the full SHA
    7a8de57 View commit details
  11. nix path-info --json: Print hash in SRI format

    (cherry picked from commit 442e665)
    edolstra committed Mar 24, 2020
    Copy the full SHA
    777e21e View commit details
  12. nix: Add --refresh as an alias for --tarball-ttl 0

    (cherry picked from commit e721f99)
    edolstra committed Mar 24, 2020
    Copy the full SHA
    6b824c7 View commit details
  13. Fix --refresh with --no-net

    edolstra committed Mar 24, 2020
    Copy the full SHA
    c85097d View commit details
  14. Copy the full SHA
    0a10854 View commit details
Showing with 319 additions and 216 deletions.
  1. +1 −1 .gitignore
  2. +1 −0 Makefile.config.in
  3. +9 −6 src/libexpr/attr-path.cc
  4. +4 −1 src/libexpr/attr-path.hh
  5. +6 −0 src/libexpr/attr-set.cc
  6. +2 −1 src/libexpr/eval.hh
  7. +1 −0 src/libexpr/function-trace.cc
  8. +10 −9 src/libstore/build.cc
  9. +0 −1 src/libstore/builtins.hh
  10. +55 −65 src/libstore/builtins/buildenv.cc
  11. +21 −0 src/libstore/builtins/buildenv.hh
  12. +3 −3 src/libstore/derivations.cc
  13. +1 −1 src/libstore/derivations.hh
  14. +3 −2 src/libstore/http-binary-cache-store.cc
  15. +3 −10 src/libstore/local-store.cc
  16. +1 −6 src/libstore/nar-info-disk-cache.cc
  17. +1 −1 src/libstore/nar-info-disk-cache.hh
  18. +5 −1 src/libstore/parsed-derivations.cc
  19. +6 −4 src/libstore/parsed-derivations.hh
  20. +18 −0 src/libstore/profiles.cc
  21. +4 −0 src/libstore/profiles.hh
  22. +23 −2 src/libstore/sqlite.cc
  23. +7 −3 src/libstore/sqlite.hh
  24. +5 −8 src/libstore/store-api.cc
  25. +6 −0 src/libstore/store-api.hh
  26. +12 −0 src/libutil/hash.hh
  27. +3 −25 src/libutil/util.cc
  28. +58 −5 src/libutil/util.hh
  29. +1 −1 src/nix-build/nix-build.cc
  30. +4 −17 src/nix-env/nix-env.cc
  31. +1 −1 src/nix-instantiate/nix-instantiate.cc
  32. +1 −1 src/nix-prefetch-url/nix-prefetch-url.cc
  33. +5 −10 src/nix-store/nix-store.cc
  34. +2 −7 src/nix/command.hh
  35. +8 −2 src/nix/edit.cc
  36. +1 −1 src/nix/eval.cc
  37. +6 −6 src/nix/installables.cc
  38. +9 −0 src/nix/main.cc
  39. +1 −1 src/nix/path-info.cc
  40. +1 −1 src/nix/upgrade-nix.cc
  41. +1 −6 src/nix/why-depends.cc
  42. +2 −2 tests/binary-cache.sh
  43. +1 −1 tests/config.nix.in
  44. +4 −4 tests/dependencies.sh
  45. +2 −0 tests/fetchGit.sh
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ perl/Makefile.config
/src/libexpr/nix.tbl

# /src/libstore/
/src/libstore/*.gen.hh
*.gen.*

/src/nix/nix

1 change: 1 addition & 0 deletions Makefile.config.in
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ prefix = @prefix@
sandbox_shell = @sandbox_shell@
storedir = @storedir@
sysconfdir = @sysconfdir@
system = @system@
doc_generate = @doc_generate@
xmllint = @xmllint@
xsltproc = @xsltproc@
15 changes: 9 additions & 6 deletions src/libexpr/attr-path.cc
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ static Strings parseAttrPath(const string & s)
}


Value * findAlongAttrPath(EvalState & state, const string & attrPath,
std::pair<Value *, Pos> findAlongAttrPath(EvalState & state, const string & attrPath,
Bindings & autoArgs, Value & vIn)
{
Strings tokens = parseAttrPath(attrPath);
@@ -41,6 +41,7 @@ Value * findAlongAttrPath(EvalState & state, const string & attrPath,
Error(format("attribute selection path '%1%' does not match expression") % attrPath);

Value * v = &vIn;
Pos pos = noPos;

for (auto & attr : tokens) {

@@ -70,8 +71,9 @@ Value * findAlongAttrPath(EvalState & state, const string & attrPath,

Bindings::iterator a = v->attrs->find(state.symbols.create(attr));
if (a == v->attrs->end())
throw Error(format("attribute '%1%' in selection path '%2%' not found") % attr % attrPath);
throw AttrPathNotFound("attribute '%1%' in selection path '%2%' not found", attr, attrPath);
v = &*a->value;
pos = *a->pos;
}

else if (apType == apIndex) {
@@ -82,14 +84,15 @@ Value * findAlongAttrPath(EvalState & state, const string & attrPath,
% attrPath % showType(*v));

if (attrIndex >= v->listSize())
throw Error(format("list index %1% in selection path '%2%' is out of range") % attrIndex % attrPath);
throw AttrPathNotFound("list index %1% in selection path '%2%' is out of range", attrIndex, attrPath);

v = v->listElems()[attrIndex];
pos = noPos;
}

}

return v;
return {v, pos};
}


@@ -98,9 +101,9 @@ Pos findDerivationFilename(EvalState & state, Value & v, std::string what)
Value * v2;
try {
auto dummyArgs = state.allocBindings(0);
v2 = findAlongAttrPath(state, "meta.position", *dummyArgs, v);
v2 = findAlongAttrPath(state, "meta.position", *dummyArgs, v).first;
} catch (Error &) {
throw Error("package '%s' has no source location information", what);
throw NoPositionInfo("package '%s' has no source location information", what);
}

// FIXME: is it possible to extract the Pos object instead of doing this
5 changes: 4 additions & 1 deletion src/libexpr/attr-path.hh
Original file line number Diff line number Diff line change
@@ -7,7 +7,10 @@

namespace nix {

Value * findAlongAttrPath(EvalState & state, const string & attrPath,
MakeError(AttrPathNotFound, Error);
MakeError(NoPositionInfo, Error);

std::pair<Value *, Pos> findAlongAttrPath(EvalState & state, const string & attrPath,
Bindings & autoArgs, Value & vIn);

/* Heuristic to find the filename and lineno or a nix value. */
6 changes: 6 additions & 0 deletions src/libexpr/attr-set.cc
Original file line number Diff line number Diff line change
@@ -43,6 +43,12 @@ Value * EvalState::allocAttr(Value & vAttrs, const Symbol & name)
}


Value * EvalState::allocAttr(Value & vAttrs, const std::string & name)
{
return allocAttr(vAttrs, symbols.create(name));
}


void Bindings::sort()
{
std::sort(begin(), end());
3 changes: 2 additions & 1 deletion src/libexpr/eval.hh
Original file line number Diff line number Diff line change
@@ -272,6 +272,7 @@ public:
Env & allocEnv(size_t size);

Value * allocAttr(Value & vAttrs, const Symbol & name);
Value * allocAttr(Value & vAttrs, const std::string & name);

Bindings * allocBindings(size_t capacity);

@@ -367,7 +368,7 @@ struct EvalSettings : Config
"Prefixes of URIs that builtin functions such as fetchurl and fetchGit are allowed to fetch."};

Setting<bool> traceFunctionCalls{this, false, "trace-function-calls",
"Emit log messages for each function entry and exit at the 'vomit' log level (-vvvv)"};
"Emit log messages for each function entry and exit at the 'vomit' log level (-vvvv)."};
};

extern EvalSettings evalSettings;
1 change: 1 addition & 0 deletions src/libexpr/function-trace.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "function-trace.hh"
#include "logging.hh"

namespace nix {

19 changes: 10 additions & 9 deletions src/libstore/build.cc
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
#include "archive.hh"
#include "affinity.hh"
#include "builtins.hh"
#include "builtins/buildenv.hh"
#include "download.hh"
#include "finally.hh"
#include "compression.hh"
@@ -1397,7 +1398,7 @@ void DerivationGoal::tryToBuild()
few seconds and then retry this goal. */
PathSet lockFiles;
for (auto & outPath : drv->outputPaths())
lockFiles.insert(worker.store.toRealPath(worker.store.printStorePath(outPath)));
lockFiles.insert(worker.store.Store::toRealPath(outPath));

if (!outputLocks.lockPaths(lockFiles, "", false)) {
worker.waitForAWhile(shared_from_this());
@@ -1428,7 +1429,7 @@ void DerivationGoal::tryToBuild()
for (auto & i : drv->outputs) {
if (worker.store.isValidPath(i.second.path)) continue;
debug("removing invalid path '%s'", worker.store.printStorePath(i.second.path));
deletePath(worker.store.toRealPath(worker.store.printStorePath(i.second.path)));
deletePath(worker.store.Store::toRealPath(i.second.path));
}

/* Don't do a remote build if the derivation has the attribute
@@ -1685,7 +1686,7 @@ void DerivationGoal::buildDone()

/* Delete unused redirected outputs (when doing hash rewriting). */
for (auto & i : redirectedOutputs)
deletePath(worker.store.toRealPath(worker.store.printStorePath(i.second)));
deletePath(worker.store.Store::toRealPath(i.second));

/* Delete the chroot (if we were using one). */
autoDelChroot.reset(); /* this runs the destructor */
@@ -1904,7 +1905,7 @@ void DerivationGoal::startBuilder()
concatStringsSep(", ", parsedDrv->getRequiredSystemFeatures()),
worker.store.printStorePath(drvPath),
settings.thisSystem,
concatStringsSep(", ", settings.systemFeatures));
concatStringsSep<StringSet>(", ", settings.systemFeatures));

if (drv->isBuiltin())
preloadNSS();
@@ -2071,7 +2072,7 @@ void DerivationGoal::startBuilder()
environment using bind-mounts. We put it in the Nix store
to ensure that we can create hard-links to non-directory
inputs in the fake Nix store in the chroot (see below). */
chrootRootDir = worker.store.toRealPath(worker.store.printStorePath(drvPath)) + ".chroot";
chrootRootDir = worker.store.Store::toRealPath(drvPath) + ".chroot";
deletePath(chrootRootDir);

/* Clean up the chroot directory automatically. */
@@ -2550,7 +2551,7 @@ static std::regex shVarName("[A-Za-z_][A-Za-z0-9_]*");

void DerivationGoal::writeStructuredAttrs()
{
auto & structuredAttrs = parsedDrv->getStructuredAttrs();
auto structuredAttrs = parsedDrv->getStructuredAttrs();
if (!structuredAttrs) return;

auto json = *structuredAttrs;
@@ -2916,7 +2917,7 @@ void DerivationGoal::addDependency(const StorePath & path)

#if __linux__

Path source = worker.store.toRealPath(worker.store.printStorePath(path));
Path source = worker.store.Store::toRealPath(path);
Path target = chrootRootDir + worker.store.printStorePath(path);
debug("bind-mounting %s -> %s", target, source);

@@ -3578,7 +3579,7 @@ void DerivationGoal::registerOutputs()
if (needsHashRewrite()) {
auto r = redirectedOutputs.find(i.second.path);
if (r != redirectedOutputs.end()) {
auto redirected = worker.store.toRealPath(worker.store.printStorePath(r->second));
auto redirected = worker.store.Store::toRealPath(r->second);
if (buildMode == bmRepair
&& redirectedBadOutputs.count(i.second.path)
&& pathExists(redirected))
@@ -3671,7 +3672,7 @@ void DerivationGoal::registerOutputs()
BuildError("hash mismatch in fixed-output derivation '%s':\n wanted: %s\n got: %s",
worker.store.printStorePath(dest), h.to_string(SRI), h2.to_string(SRI)));

Path actualDest = worker.store.toRealPath(worker.store.printStorePath(dest));
Path actualDest = worker.store.Store::toRealPath(dest);

if (worker.store.isValidPath(dest))
std::rethrow_exception(delayedException);
1 change: 0 additions & 1 deletion src/libstore/builtins.hh
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ namespace nix {

// TODO: make pluggable.
void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData);
void builtinBuildenv(const BasicDerivation & drv);
void builtinUnpackChannel(const BasicDerivation & drv);

}
Loading