1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

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^*'
This commit is contained in:
Raphael Robatsch 2023-04-13 16:22:45 +02:00
parent ef0b48377d
commit 9e8f209036
3 changed files with 10 additions and 9 deletions

View file

@ -48,7 +48,7 @@ struct DerivedPathBuilt {
StorePath drvPath;
OutputsSpec outputs;
std::string to_string(const Store & store) const;
std::string to_string(const Store & store, char separator = '!') const;
static DerivedPathBuilt parse(const Store & store, std::string_view, std::string_view);
nlohmann::json toJSON(ref<Store> store) const;
@ -81,7 +81,7 @@ struct DerivedPath : _DerivedPathRaw {
return static_cast<const Raw &>(*this);
}
std::string to_string(const Store & store) const;
std::string to_string(const Store & store, char separator = '!') const;
static DerivedPath parse(const Store & store, std::string_view);
};