forked from lix-project/lix
String .drv suffix to create derivation name
This commit is contained in:
parent
5d0b75e5b6
commit
18152406ce
|
@ -113,7 +113,7 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
|
||||||
};
|
};
|
||||||
if (auto optStorePath = isValidDerivationInStore()) {
|
if (auto optStorePath = isValidDerivationInStore()) {
|
||||||
auto storePath = *optStorePath;
|
auto storePath = *optStorePath;
|
||||||
Derivation drv = readDerivation(*state.store, realPath, std::string(storePath.name()));
|
Derivation drv = readDerivation(*state.store, realPath, Derivation::nameFromPath(storePath));
|
||||||
Value & w = *state.allocValue();
|
Value & w = *state.allocValue();
|
||||||
state.mkAttrs(w, 3 + drv.outputs.size());
|
state.mkAttrs(w, 3 + drv.outputs.size());
|
||||||
Value * v2 = state.allocAttr(w, state.sDrvPath);
|
Value * v2 = state.allocAttr(w, state.sDrvPath);
|
||||||
|
|
|
@ -474,7 +474,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
case wopBuildDerivation: {
|
case wopBuildDerivation: {
|
||||||
auto drvPath = store->parseStorePath(readString(from));
|
auto drvPath = store->parseStorePath(readString(from));
|
||||||
BasicDerivation drv;
|
BasicDerivation drv;
|
||||||
readDerivation(from, *store, drv, std::string(drvPath.name()));
|
readDerivation(from, *store, drv, Derivation::nameFromPath(drvPath));
|
||||||
BuildMode buildMode = (BuildMode) readInt(from);
|
BuildMode buildMode = (BuildMode) readInt(from);
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
if (!trusted)
|
if (!trusted)
|
||||||
|
|
|
@ -218,7 +218,7 @@ Derivation Store::readDerivation(const StorePath & drvPath)
|
||||||
{
|
{
|
||||||
auto accessor = getFSAccessor();
|
auto accessor = getFSAccessor();
|
||||||
try {
|
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) {
|
} catch (FormatError & e) {
|
||||||
throw Error("error parsing derivation '%s': %s", printStorePath(drvPath), e.msg());
|
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)
|
Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv, std::string_view name)
|
||||||
{
|
{
|
||||||
drv.name = name;
|
drv.name = name;
|
||||||
|
|
|
@ -64,6 +64,8 @@ struct BasicDerivation
|
||||||
|
|
||||||
/* Return the output names of a derivation. */
|
/* Return the output names of a derivation. */
|
||||||
StringSet outputNames() const;
|
StringSet outputNames() const;
|
||||||
|
|
||||||
|
static std::string_view nameFromPath(const StorePath & storePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Derivation : BasicDerivation
|
struct Derivation : BasicDerivation
|
||||||
|
|
|
@ -916,7 +916,7 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
auto drvPath = store->parseStorePath(readString(in));
|
auto drvPath = store->parseStorePath(readString(in));
|
||||||
BasicDerivation drv;
|
BasicDerivation drv;
|
||||||
readDerivation(in, *store, drv, std::string(drvPath.name()));
|
readDerivation(in, *store, drv, Derivation::nameFromPath(drvPath));
|
||||||
|
|
||||||
getBuildSettings();
|
getBuildSettings();
|
||||||
|
|
||||||
|
|
|
@ -483,7 +483,7 @@ bool NixRepl::processLine(string line)
|
||||||
but doing it in a child makes it easier to recover from
|
but doing it in a child makes it easier to recover from
|
||||||
problems / SIGINT. */
|
problems / SIGINT. */
|
||||||
if (runProgram(settings.nixBinDir + "/nix", Strings{"build", "--no-link", drvPath}) == 0) {
|
if (runProgram(settings.nixBinDir + "/nix", Strings{"build", "--no-link", drvPath}) == 0) {
|
||||||
auto drv = readDerivation(*state->store, drvPath, std::string(state->store->parseStorePath(drvPath).name()));
|
auto drv = readDerivation(*state->store, drvPath, Derivation::nameFromPath(state->store->parseStorePath(drvPath)));
|
||||||
std::cout << std::endl << "this derivation produced the following outputs:" << std::endl;
|
std::cout << std::endl << "this derivation produced the following outputs:" << std::endl;
|
||||||
for (auto & i : drv.outputs)
|
for (auto & i : drv.outputs)
|
||||||
std::cout << fmt(" %s -> %s\n", i.first, state->store->printStorePath(i.second.path(*state->store, drv.name)));
|
std::cout << fmt(" %s -> %s\n", i.first, state->store->printStorePath(i.second.path(*state->store, drv.name)));
|
||||||
|
|
Loading…
Reference in a new issue