aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2019-06-21 15:29:05 +0200
committerEelco Dolstra <edolstra@gmail.com>2019-06-21 15:29:05 +0200
commitd132d057a85aa1812c4133feed6c9b34ca70671d (patch)
tree69183af3a8c0ea2469d1e2908cffb67177f32b9f /src/nix
parent4f6a7c86218c748df2a8700eca8ba9edbedd9ca5 (diff)
Handle store symlinks in flake directories
E.g. 'nix path-info ./result' inside a flake directory now works again.
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/installables.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/nix/installables.cc b/src/nix/installables.cc
index feaf57f0c..d43f86c0c 100644
--- a/src/nix/installables.cc
+++ b/src/nix/installables.cc
@@ -394,9 +394,18 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
} else {
+ auto follow = [&](const std::string & s) -> std::optional<Path> {
+ try {
+ return store->followLinksToStorePath(s);
+ } catch (NotInStore &) {
+ return {};
+ }
+ };
+
for (auto & s : ss) {
size_t colon;
+ std::optional<Path> storePath;
if (s.compare(0, 1, "(") == 0)
result.push_back(std::make_shared<InstallableExpr>(*this, s));
@@ -422,17 +431,8 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
getDefaultFlakeAttrPathPrefixes()));
}
- else if (s.find('/') != std::string::npos || s == ".") {
- Path storePath;
- try {
- storePath = store->toStorePath(store->followLinksToStore(s));
- } catch (Error) { }
- if (storePath != "")
- result.push_back(std::make_shared<InstallableStorePath>(storePath));
- else
- result.push_back(std::make_shared<InstallableFlake>(*this, FlakeRef(s, true),
- getDefaultFlakeAttrPaths()));
- }
+ else if (s.find('/') != std::string::npos && (storePath = follow(s)))
+ result.push_back(std::make_shared<InstallableStorePath>(*storePath));
else
throw Error("unsupported argument '%s'", s);