mirror of
https://github.com/NixOS/nix
synced 2025-06-28 17:51:15 +02:00
Derivations can output "text-hashed" data
In particular, this means that derivations can output derivations. But that ramification isn't (yet!) useful as we would want, since there is no way to have a dependent derivation that is itself a dependent derivation.
This commit is contained in:
parent
a0f369aa3f
commit
a4e5de1b9d
15 changed files with 322 additions and 137 deletions
|
@ -380,20 +380,23 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
|||
logger->startWork();
|
||||
auto pathInfo = [&]() {
|
||||
// NB: FramedSource must be out of scope before logger->stopWork();
|
||||
ContentAddressMethod contentAddressMethod = parseContentAddressMethod(camStr);
|
||||
auto [contentAddressMethod, hashType] = parseContentAddressMethod(camStr);
|
||||
FramedSource source(from);
|
||||
// TODO this is essentially RemoteStore::addCAToStore. Move it up to Store.
|
||||
return std::visit(overloaded {
|
||||
[&](TextHashMethod &_) {
|
||||
[&](TextHashMethod _) {
|
||||
if (hashType != htSHA256)
|
||||
throw UnimplementedError("Only SHA-256 is supported for adding text-hashed data, but '%1' was given",
|
||||
printHashType(hashType));
|
||||
// We could stream this by changing Store
|
||||
std::string contents = source.drain();
|
||||
auto path = store->addTextToStore(name, contents, refs, repair);
|
||||
return store->queryPathInfo(path);
|
||||
},
|
||||
[&](FixedOutputHashMethod &fohm) {
|
||||
[&](FileIngestionMethod fim) {
|
||||
if (!refs.empty())
|
||||
throw UnimplementedError("cannot yet have refs with flat or nar-hashed data");
|
||||
auto path = store->addToStoreFromDump(source, name, fohm.fileIngestionMethod, fohm.hashType, repair);
|
||||
auto path = store->addToStoreFromDump(source, name, fim, hashType, repair);
|
||||
return store->queryPathInfo(path);
|
||||
},
|
||||
}, contentAddressMethod);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue