aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/derived-path.cc
diff options
context:
space:
mode:
authorRaphael Robatsch <raphael-git@tapesoftware.net>2023-04-13 16:22:45 +0200
committerRaphael Robatsch <raphael-git@tapesoftware.net>2023-04-14 10:32:03 +0200
commit9e8f2090365a509656dead69bc91fb6615cf9d05 (patch)
tree08c6f9a17689f6166a76e0fe82c0d52e48391195 /src/libstore/derived-path.cc
parentef0b48377d0fc79d70455c402ed4df4b18cb93dd (diff)
Display valid installable in InstallableDerivedPath::parse warning
The warning message should produce an installable name that can be passed to `nix build`, `nix path-info`, etc. again. Since the CLI expects that the .drv path and the output names are separated by a caret, the warning message must also separate the .drv path and output names with a caret. However, `DerivedPath::Built.to_string()` uses an exclamation point as the separator instead. This commit adds a `separator` argument to the to_string method. This changes the warning message from: If this command is now failing try again with '/nix/store/foo.drv!*' to: If this command is now failing try again with '/nix/store/foo.drv^*'
Diffstat (limited to 'src/libstore/derived-path.cc')
-rw-r--r--src/libstore/derived-path.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libstore/derived-path.cc b/src/libstore/derived-path.cc
index e5f0f1b33..6baca70a3 100644
--- a/src/libstore/derived-path.cc
+++ b/src/libstore/derived-path.cc
@@ -59,18 +59,19 @@ std::string DerivedPath::Opaque::to_string(const Store & store) const
return store.printStorePath(path);
}
-std::string DerivedPath::Built::to_string(const Store & store) const
+std::string DerivedPath::Built::to_string(const Store & store, char separator) const
{
return store.printStorePath(drvPath)
- + "!"
+ + separator
+ outputs.to_string();
}
-std::string DerivedPath::to_string(const Store & store) const
+std::string DerivedPath::to_string(const Store & store, char separator) const
{
- return std::visit(
- [&](const auto & req) { return req.to_string(store); },
- this->raw());
+ return std::visit(overloaded {
+ [&](const DerivedPath::Built & req) { return req.to_string(store, separator); },
+ [&](const DerivedPath::Opaque & req) { return req.to_string(store); },
+ }, this->raw());
}