aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/eval.cc2
-rw-r--r--src/nix/flake.cc4
-rw-r--r--src/nix/main.cc6
-rw-r--r--src/nix/prefetch.cc11
-rw-r--r--src/nix/upgrade-nix.cc2
5 files changed, 15 insertions, 10 deletions
diff --git a/src/nix/eval.cc b/src/nix/eval.cc
index 43db5150c..c7af9c92c 100644
--- a/src/nix/eval.cc
+++ b/src/nix/eval.cc
@@ -66,7 +66,7 @@ struct CmdEval : MixJSON, InstallableValueCommand, MixReadOnlyOption
if (apply) {
auto vApply = state->allocValue();
- state->eval(state->parseExprFromString(*apply, absPath(".")), *vApply);
+ state->eval(state->parseExprFromString(*apply, state->rootPath(CanonPath::fromCwd())), *vApply);
auto vRes = state->allocValue();
state->callFunction(*vApply, *v, *vRes, noPos);
v = vRes;
diff --git a/src/nix/flake.cc b/src/nix/flake.cc
index cd4ee5921..a6c6b947f 100644
--- a/src/nix/flake.cc
+++ b/src/nix/flake.cc
@@ -440,8 +440,8 @@ struct CmdFlakeCheck : FlakeCommand
if (attr->name == state->symbols.create("path")) {
PathSet context;
auto path = state->coerceToPath(attr->pos, *attr->value, context, "");
- if (!store->isInStore(path))
- throw Error("template '%s' has a bad 'path' attribute");
+ if (!path.pathExists())
+ throw Error("template '%s' refers to a non-existent path '%s'", attrPath, path);
// TODO: recursively check the flake in 'path'.
}
} else
diff --git a/src/nix/main.cc b/src/nix/main.cc
index 705061d25..ce0bed2a3 100644
--- a/src/nix/main.cc
+++ b/src/nix/main.cc
@@ -201,14 +201,14 @@ static void showHelp(std::vector<std::string> subcommand, NixArgs & toplevel)
auto vGenerateManpage = state.allocValue();
state.eval(state.parseExprFromString(
#include "generate-manpage.nix.gen.hh"
- , "/"), *vGenerateManpage);
+ , CanonPath::root), *vGenerateManpage);
auto vUtils = state.allocValue();
state.cacheFile(
- "/utils.nix", "/utils.nix",
+ CanonPath("/utils.nix"), CanonPath("/utils.nix"),
state.parseExprFromString(
#include "utils.nix.gen.hh"
- , "/"),
+ , CanonPath::root),
*vUtils);
auto vDump = state.allocValue();
diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc
index 51c8a3319..039608d48 100644
--- a/src/nix/prefetch.cc
+++ b/src/nix/prefetch.cc
@@ -27,7 +27,10 @@ std::string resolveMirrorUrl(EvalState & state, const std::string & url)
Value vMirrors;
// FIXME: use nixpkgs flake
- state.eval(state.parseExprFromString("import <nixpkgs/pkgs/build-support/fetchurl/mirrors.nix>", "."), vMirrors);
+ state.eval(state.parseExprFromString(
+ "import <nixpkgs/pkgs/build-support/fetchurl/mirrors.nix>",
+ state.rootPath(CanonPath::root)),
+ vMirrors);
state.forceAttrs(vMirrors, noPos, "while evaluating the set of all mirrors");
auto mirrorList = vMirrors.attrs->find(state.symbols.create(mirrorName));
@@ -192,9 +195,11 @@ static int main_nix_prefetch_url(int argc, char * * argv)
throw UsageError("you must specify a URL");
url = args[0];
} else {
- Path path = resolveExprPath(lookupFileArg(*state, args.empty() ? "." : args[0]));
Value vRoot;
- state->evalFile(path, vRoot);
+ state->evalFile(
+ resolveExprPath(
+ lookupFileArg(*state, args.empty() ? "." : args[0])),
+ vRoot);
Value & v(*findAlongAttrPath(*state, attrPath, autoArgs, vRoot).first);
state->forceAttrs(v, noPos, "while evaluating the source attribute to prefetch");
diff --git a/src/nix/upgrade-nix.cc b/src/nix/upgrade-nix.cc
index 2295d86d0..3997c98bf 100644
--- a/src/nix/upgrade-nix.cc
+++ b/src/nix/upgrade-nix.cc
@@ -148,7 +148,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
auto state = std::make_unique<EvalState>(Strings(), store);
auto v = state->allocValue();
- state->eval(state->parseExprFromString(res.data, "/no-such-path"), *v);
+ state->eval(state->parseExprFromString(res.data, state->rootPath(CanonPath("/no-such-path"))), *v);
Bindings & bindings(*state->allocBindings(0));
auto v2 = findAlongAttrPath(*state, settings.thisSystem, bindings, *v).first;