1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 23:03:53 -04:00

Split mkOutputString in two

This well help us with some unit testing
This commit is contained in:
John Ericson 2023-05-10 19:07:33 -04:00
parent 9550c3862f
commit 0a9afce3b9

View file

@ -129,39 +129,56 @@ static SourcePath realisePath(EvalState & state, const PosIdx pos, Value & v, co
} }
} }
/* Add and attribute to the given attribute map from the output name to /**
the output path, or a placeholder. * Inverse of one of the `EvalState::coerceToDerivedPath()` cases.
*/
static void mkOutputString(
EvalState & state,
Value & value,
const StorePath & drvPath,
const std::string outputName,
std::optional<StorePath> optOutputPath)
{
value.mkString(
optOutputPath
? state.store->printStorePath(*std::move(optOutputPath))
/* Downstream we would substitute this for an actual path once
we build the floating CA derivation */
: downstreamPlaceholder(*state.store, drvPath, outputName),
NixStringContext {
NixStringContextElem::Built {
.drvPath = drvPath,
.output = outputName,
}
});
}
Where possible the path is used, but for floating CA derivations we /**
may not know it. For sake of determinism we always assume we don't * Add and attribute to the given attribute map from the output name to
and instead put in a place holder. In either case, however, the * the output path, or a placeholder.
string context will contain the drv path and output name, so *
downstream derivations will have the proper dependency, and in * Where possible the path is used, but for floating CA derivations we
addition, before building, the placeholder will be rewritten to be * may not know it. For sake of determinism we always assume we don't
the actual path. * and instead put in a place holder. In either case, however, the
* string context will contain the drv path and output name, so
The 'drv' and 'drvPath' outputs must correspond. */ * downstream derivations will have the proper dependency, and in
* addition, before building, the placeholder will be rewritten to be
* the actual path.
*
* The 'drv' and 'drvPath' outputs must correspond.
*/
static void mkOutputString( static void mkOutputString(
EvalState & state, EvalState & state,
BindingsBuilder & attrs, BindingsBuilder & attrs,
const StorePath & drvPath, const StorePath & drvPath,
const std::pair<std::string, DerivationOutput> & o) const std::pair<std::string, DerivationOutput> & o)
{ {
auto optOutputPath = o.second.path(*state.store, Derivation::nameFromPath(drvPath), o.first); mkOutputString(
attrs.alloc(o.first).mkString( state,
optOutputPath attrs.alloc(o.first),
? state.store->printStorePath(*optOutputPath) drvPath,
/* Downstream we would substitute this for an actual path once o.first,
we build the floating CA derivation */ o.second.path(*state.store, Derivation::nameFromPath(drvPath), o.first));
/* FIXME: we need to depend on the basic derivation, not
derivation */
: downstreamPlaceholder(*state.store, drvPath, o.first),
NixStringContext {
NixStringContextElem::Built {
.drvPath = drvPath,
.output = o.first,
}
});
} }
/* Load and evaluate an expression from path specified by the /* Load and evaluate an expression from path specified by the