aboutsummaryrefslogtreecommitdiff
path: root/src/nix-instantiate
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2023-04-06 13:15:50 +0200
committerEelco Dolstra <edolstra@gmail.com>2023-04-06 13:15:50 +0200
commit94812cca98fbb157e5f64a15a85a2b852d289feb (patch)
tree2f02c31fc42c7286f3c35dfd3ff1a88f235ab65b /src/nix-instantiate
parent5256ba6d87403f2b58ec4586c26d8fb14027252f (diff)
Backport SourcePath from the lazy-trees branch
This introduces the SourcePath type from lazy-trees as an abstraction for accessing files from inputs that may not be materialized in the real filesystem (e.g. Git repositories). Currently, however, it's just a wrapper around CanonPath, so it shouldn't change any behaviour. (On lazy-trees, SourcePath is a <InputAccessor, CanonPath> tuple.)
Diffstat (limited to 'src/nix-instantiate')
-rw-r--r--src/nix-instantiate/nix-instantiate.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/nix-instantiate/nix-instantiate.cc b/src/nix-instantiate/nix-instantiate.cc
index 6b5ba595d..2b381288a 100644
--- a/src/nix-instantiate/nix-instantiate.cc
+++ b/src/nix-instantiate/nix-instantiate.cc
@@ -168,9 +168,11 @@ static int main_nix_instantiate(int argc, char * * argv)
if (findFile) {
for (auto & i : files) {
- Path p = state->findFile(i);
- if (p == "") throw Error("unable to find '%1%'", i);
- std::cout << p << std::endl;
+ auto p = state->findFile(i);
+ if (auto fn = p.getPhysicalPath())
+ std::cout << fn->abs() << std::endl;
+ else
+ throw Error("'%s' has no physical path", p);
}
return 0;
}
@@ -184,7 +186,7 @@ static int main_nix_instantiate(int argc, char * * argv)
for (auto & i : files) {
Expr * e = fromArgs
- ? state->parseExprFromString(i, absPath("."))
+ ? state->parseExprFromString(i, state->rootPath(CanonPath::fromCwd()))
: state->parseExprFromFile(resolveExprPath(state->checkSourcePath(lookupFileArg(*state, i))));
processExpr(*state, attrPaths, parseOnly, strict, autoArgs,
evalOnly, outputKind, xmlOutputSourceLocation, e);