mirror of
https://github.com/NixOS/nix.git
synced 2025-11-21 01:39:36 +01:00
String .drv suffix to create derivation name
This commit is contained in:
parent
5d0b75e5b6
commit
18152406ce
6 changed files with 16 additions and 5 deletions
|
|
@ -474,7 +474,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
|||
case wopBuildDerivation: {
|
||||
auto drvPath = store->parseStorePath(readString(from));
|
||||
BasicDerivation drv;
|
||||
readDerivation(from, *store, drv, std::string(drvPath.name()));
|
||||
readDerivation(from, *store, drv, Derivation::nameFromPath(drvPath));
|
||||
BuildMode buildMode = (BuildMode) readInt(from);
|
||||
logger->startWork();
|
||||
if (!trusted)
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ Derivation Store::readDerivation(const StorePath & drvPath)
|
|||
{
|
||||
auto accessor = getFSAccessor();
|
||||
try {
|
||||
return parseDerivation(*this, accessor->readFile(printStorePath(drvPath)), std::string(drvPath.name()));
|
||||
return parseDerivation(*this, accessor->readFile(printStorePath(drvPath)), Derivation::nameFromPath(drvPath));
|
||||
} catch (FormatError & e) {
|
||||
throw Error("error parsing derivation '%s': %s", printStorePath(drvPath), e.msg());
|
||||
}
|
||||
|
|
@ -465,6 +465,15 @@ StringSet BasicDerivation::outputNames() const
|
|||
}
|
||||
|
||||
|
||||
std::string_view BasicDerivation::nameFromPath(const StorePath & drvPath) {
|
||||
auto nameWithSuffix = drvPath.name();
|
||||
constexpr std::string_view extension = ".drv";
|
||||
assert(hasSuffix(nameWithSuffix, extension));
|
||||
nameWithSuffix.remove_suffix(extension.size());
|
||||
return nameWithSuffix;
|
||||
}
|
||||
|
||||
|
||||
Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv, std::string_view name)
|
||||
{
|
||||
drv.name = name;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ struct BasicDerivation
|
|||
|
||||
/* Return the output names of a derivation. */
|
||||
StringSet outputNames() const;
|
||||
|
||||
static std::string_view nameFromPath(const StorePath & storePath);
|
||||
};
|
||||
|
||||
struct Derivation : BasicDerivation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue