mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 09:36:15 +02:00
Merge branch 'drv-outputs-map-allow-missing-namespace' of github.com:obsidiansystems/nix into templated-daemon-protocol
This commit is contained in:
commit
f795f0fabc
8 changed files with 112 additions and 89 deletions
|
@ -1864,11 +1864,11 @@ HookReply DerivationGoal::tryBuildHook()
|
||||||
|
|
||||||
/* Tell the hook all the inputs that have to be copied to the
|
/* Tell the hook all the inputs that have to be copied to the
|
||||||
remote system. */
|
remote system. */
|
||||||
write(worker.store, hook->sink, inputPaths);
|
nix::worker_proto::write(worker.store, hook->sink, inputPaths);
|
||||||
|
|
||||||
/* Tell the hooks the missing outputs that have to be copied back
|
/* Tell the hooks the missing outputs that have to be copied back
|
||||||
from the remote system. */
|
from the remote system. */
|
||||||
write(worker.store, hook->sink, missingPaths);
|
nix::worker_proto::write(worker.store, hook->sink, missingPaths);
|
||||||
|
|
||||||
hook->sink = FdSink();
|
hook->sink = FdSink();
|
||||||
hook->toHook.writeSide = -1;
|
hook->toHook.writeSide = -1;
|
||||||
|
|
|
@ -256,11 +256,11 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
}
|
}
|
||||||
|
|
||||||
case wopQueryValidPaths: {
|
case wopQueryValidPaths: {
|
||||||
auto paths = read(*store, from, Proxy<StorePathSet> {});
|
auto paths = nix::worker_proto::read(*store, from, Phantom<StorePathSet> {});
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
auto res = store->queryValidPaths(paths);
|
auto res = store->queryValidPaths(paths);
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
write(*store, to, res);
|
nix::worker_proto::write(*store, to, res);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,11 +276,11 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
}
|
}
|
||||||
|
|
||||||
case wopQuerySubstitutablePaths: {
|
case wopQuerySubstitutablePaths: {
|
||||||
auto paths = read(*store, from, Proxy<StorePathSet> {});
|
auto paths = nix::worker_proto::read(*store, from, Phantom<StorePathSet> {});
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
auto res = store->querySubstitutablePaths(paths);
|
auto res = store->querySubstitutablePaths(paths);
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
write(*store, to, res);
|
nix::worker_proto::write(*store, to, res);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
paths = store->queryValidDerivers(path);
|
paths = store->queryValidDerivers(path);
|
||||||
else paths = store->queryDerivationOutputs(path);
|
else paths = store->queryDerivationOutputs(path);
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
write(*store, to, paths);
|
nix::worker_proto::write(*store, to, paths);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
auto outputs = store->queryDerivationOutputMap(path);
|
auto outputs = store->queryDerivationOutputMap(path);
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
write(*store, to, outputs);
|
nix::worker_proto::write(*store, to, outputs);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
case wopAddTextToStore: {
|
case wopAddTextToStore: {
|
||||||
string suffix = readString(from);
|
string suffix = readString(from);
|
||||||
string s = readString(from);
|
string s = readString(from);
|
||||||
auto refs = read(*store, from, Proxy<StorePathSet> {});
|
auto refs = nix::worker_proto::read(*store, from, Phantom<StorePathSet> {});
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
auto path = store->addTextToStore(suffix, s, refs, NoRepair);
|
auto path = store->addTextToStore(suffix, s, refs, NoRepair);
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
|
@ -518,7 +518,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
case wopCollectGarbage: {
|
case wopCollectGarbage: {
|
||||||
GCOptions options;
|
GCOptions options;
|
||||||
options.action = (GCOptions::GCAction) readInt(from);
|
options.action = (GCOptions::GCAction) readInt(from);
|
||||||
options.pathsToDelete = read(*store, from, Proxy<StorePathSet> {});
|
options.pathsToDelete = nix::worker_proto::read(*store, from, Phantom<StorePathSet> {});
|
||||||
from >> options.ignoreLiveness >> options.maxFreed;
|
from >> options.ignoreLiveness >> options.maxFreed;
|
||||||
// obsolete fields
|
// obsolete fields
|
||||||
readInt(from);
|
readInt(from);
|
||||||
|
@ -587,7 +587,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
else {
|
else {
|
||||||
to << 1
|
to << 1
|
||||||
<< (i->second.deriver ? store->printStorePath(*i->second.deriver) : "");
|
<< (i->second.deriver ? store->printStorePath(*i->second.deriver) : "");
|
||||||
write(*store, to, i->second.references);
|
nix::worker_proto::write(*store, to, i->second.references);
|
||||||
to << i->second.downloadSize
|
to << i->second.downloadSize
|
||||||
<< i->second.narSize;
|
<< i->second.narSize;
|
||||||
}
|
}
|
||||||
|
@ -598,11 +598,11 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
SubstitutablePathInfos infos;
|
SubstitutablePathInfos infos;
|
||||||
StorePathCAMap pathsMap = {};
|
StorePathCAMap pathsMap = {};
|
||||||
if (GET_PROTOCOL_MINOR(clientVersion) < 22) {
|
if (GET_PROTOCOL_MINOR(clientVersion) < 22) {
|
||||||
auto paths = read(*store, from, Proxy<StorePathSet> {});
|
auto paths = nix::worker_proto::read(*store, from, Phantom<StorePathSet> {});
|
||||||
for (auto & path : paths)
|
for (auto & path : paths)
|
||||||
pathsMap.emplace(path, std::nullopt);
|
pathsMap.emplace(path, std::nullopt);
|
||||||
} else
|
} else
|
||||||
pathsMap = read(*store, from, Proxy<StorePathCAMap> {});
|
pathsMap = nix::worker_proto::read(*store, from, Phantom<StorePathCAMap> {});
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
store->querySubstitutablePathInfos(pathsMap, infos);
|
store->querySubstitutablePathInfos(pathsMap, infos);
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
|
@ -610,7 +610,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
for (auto & i : infos) {
|
for (auto & i : infos) {
|
||||||
to << store->printStorePath(i.first)
|
to << store->printStorePath(i.first)
|
||||||
<< (i.second.deriver ? store->printStorePath(*i.second.deriver) : "");
|
<< (i.second.deriver ? store->printStorePath(*i.second.deriver) : "");
|
||||||
write(*store, to, i.second.references);
|
nix::worker_proto::write(*store, to, i.second.references);
|
||||||
to << i.second.downloadSize << i.second.narSize;
|
to << i.second.downloadSize << i.second.narSize;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -620,7 +620,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
logger->startWork();
|
logger->startWork();
|
||||||
auto paths = store->queryAllValidPaths();
|
auto paths = store->queryAllValidPaths();
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
write(*store, to, paths);
|
nix::worker_proto::write(*store, to, paths);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
to << 1;
|
to << 1;
|
||||||
to << (info->deriver ? store->printStorePath(*info->deriver) : "")
|
to << (info->deriver ? store->printStorePath(*info->deriver) : "")
|
||||||
<< info->narHash->to_string(Base16, false);
|
<< info->narHash->to_string(Base16, false);
|
||||||
write(*store, to, info->references);
|
nix::worker_proto::write(*store, to, info->references);
|
||||||
to << info->registrationTime << info->narSize;
|
to << info->registrationTime << info->narSize;
|
||||||
if (GET_PROTOCOL_MINOR(clientVersion) >= 16) {
|
if (GET_PROTOCOL_MINOR(clientVersion) >= 16) {
|
||||||
to << info->ultimate
|
to << info->ultimate
|
||||||
|
@ -699,7 +699,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
if (deriver != "")
|
if (deriver != "")
|
||||||
info.deriver = store->parseStorePath(deriver);
|
info.deriver = store->parseStorePath(deriver);
|
||||||
info.narHash = Hash::parseAny(readString(from), htSHA256);
|
info.narHash = Hash::parseAny(readString(from), htSHA256);
|
||||||
info.references = read(*store, from, Proxy<StorePathSet> {});
|
info.references = nix::worker_proto::read(*store, from, Phantom<StorePathSet> {});
|
||||||
from >> info.registrationTime >> info.narSize >> info.ultimate;
|
from >> info.registrationTime >> info.narSize >> info.ultimate;
|
||||||
info.sigs = readStrings<StringSet>(from);
|
info.sigs = readStrings<StringSet>(from);
|
||||||
info.ca = parseContentAddressOpt(readString(from));
|
info.ca = parseContentAddressOpt(readString(from));
|
||||||
|
@ -799,9 +799,9 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
|
||||||
uint64_t downloadSize, narSize;
|
uint64_t downloadSize, narSize;
|
||||||
store->queryMissing(targets, willBuild, willSubstitute, unknown, downloadSize, narSize);
|
store->queryMissing(targets, willBuild, willSubstitute, unknown, downloadSize, narSize);
|
||||||
logger->stopWork();
|
logger->stopWork();
|
||||||
write(*store, to, willBuild);
|
nix::worker_proto::write(*store, to, willBuild);
|
||||||
write(*store, to, willSubstitute);
|
nix::worker_proto::write(*store, to, willSubstitute);
|
||||||
write(*store, to, unknown);
|
nix::worker_proto::write(*store, to, unknown);
|
||||||
to << downloadSize << narSize;
|
to << downloadSize << narSize;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -605,7 +605,7 @@ Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv,
|
||||||
drv.outputs.emplace(std::move(name), std::move(output));
|
drv.outputs.emplace(std::move(name), std::move(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
drv.inputSrcs = read(store, in, Proxy<StorePathSet> {});
|
drv.inputSrcs = nix::worker_proto::read(store, in, Phantom<StorePathSet> {});
|
||||||
in >> drv.platform >> drv.builder;
|
in >> drv.platform >> drv.builder;
|
||||||
drv.args = readStrings<Strings>(in);
|
drv.args = readStrings<Strings>(in);
|
||||||
|
|
||||||
|
@ -640,7 +640,7 @@ void writeDerivation(Sink & out, const Store & store, const BasicDerivation & dr
|
||||||
},
|
},
|
||||||
}, i.second.output);
|
}, i.second.output);
|
||||||
}
|
}
|
||||||
write(store, out, drv.inputSrcs);
|
nix::worker_proto::write(store, out, drv.inputSrcs);
|
||||||
out << drv.platform << drv.builder << drv.args;
|
out << drv.platform << drv.builder << drv.args;
|
||||||
out << drv.env.size();
|
out << drv.env.size();
|
||||||
for (auto & i : drv.env)
|
for (auto & i : drv.env)
|
||||||
|
|
|
@ -45,7 +45,7 @@ void Store::exportPath(const StorePath & path, Sink & sink)
|
||||||
teeSink
|
teeSink
|
||||||
<< exportMagic
|
<< exportMagic
|
||||||
<< printStorePath(path);
|
<< printStorePath(path);
|
||||||
write(*this, teeSink, info->references);
|
nix::worker_proto::write(*this, teeSink, info->references);
|
||||||
teeSink
|
teeSink
|
||||||
<< (info->deriver ? printStorePath(*info->deriver) : "")
|
<< (info->deriver ? printStorePath(*info->deriver) : "")
|
||||||
<< 0;
|
<< 0;
|
||||||
|
@ -73,7 +73,7 @@ StorePaths Store::importPaths(Source & source, CheckSigsFlag checkSigs)
|
||||||
|
|
||||||
//Activity act(*logger, lvlInfo, format("importing path '%s'") % info.path);
|
//Activity act(*logger, lvlInfo, format("importing path '%s'") % info.path);
|
||||||
|
|
||||||
info.references = read(*this, source, Proxy<StorePathSet> {});
|
info.references = nix::worker_proto::read(*this, source, Phantom<StorePathSet> {});
|
||||||
|
|
||||||
auto deriver = readString(source);
|
auto deriver = readString(source);
|
||||||
if (deriver != "")
|
if (deriver != "")
|
||||||
|
|
|
@ -107,7 +107,7 @@ struct LegacySSHStore : public Store
|
||||||
auto deriver = readString(conn->from);
|
auto deriver = readString(conn->from);
|
||||||
if (deriver != "")
|
if (deriver != "")
|
||||||
info->deriver = parseStorePath(deriver);
|
info->deriver = parseStorePath(deriver);
|
||||||
info->references = read(*this, conn->from, Proxy<StorePathSet> {});
|
info->references = nix::worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
readLongLong(conn->from); // download size
|
readLongLong(conn->from); // download size
|
||||||
info->narSize = readLongLong(conn->from);
|
info->narSize = readLongLong(conn->from);
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ struct LegacySSHStore : public Store
|
||||||
<< printStorePath(info.path)
|
<< printStorePath(info.path)
|
||||||
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
||||||
<< info.narHash->to_string(Base16, false);
|
<< info.narHash->to_string(Base16, false);
|
||||||
write(*this, conn->to, info.references);
|
nix::worker_proto::write(*this, conn->to, info.references);
|
||||||
conn->to
|
conn->to
|
||||||
<< info.registrationTime
|
<< info.registrationTime
|
||||||
<< info.narSize
|
<< info.narSize
|
||||||
|
@ -168,7 +168,7 @@ struct LegacySSHStore : public Store
|
||||||
conn->to
|
conn->to
|
||||||
<< exportMagic
|
<< exportMagic
|
||||||
<< printStorePath(info.path);
|
<< printStorePath(info.path);
|
||||||
write(*this, conn->to, info.references);
|
nix::worker_proto::write(*this, conn->to, info.references);
|
||||||
conn->to
|
conn->to
|
||||||
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
||||||
<< 0
|
<< 0
|
||||||
|
@ -251,10 +251,10 @@ struct LegacySSHStore : public Store
|
||||||
conn->to
|
conn->to
|
||||||
<< cmdQueryClosure
|
<< cmdQueryClosure
|
||||||
<< includeOutputs;
|
<< includeOutputs;
|
||||||
write(*this, conn->to, paths);
|
nix::worker_proto::write(*this, conn->to, paths);
|
||||||
conn->to.flush();
|
conn->to.flush();
|
||||||
|
|
||||||
for (auto & i : read(*this, conn->from, Proxy<StorePathSet> {}))
|
for (auto & i : nix::worker_proto::read(*this, conn->from, Phantom<StorePathSet> {}))
|
||||||
out.insert(i);
|
out.insert(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,10 +267,10 @@ struct LegacySSHStore : public Store
|
||||||
<< cmdQueryValidPaths
|
<< cmdQueryValidPaths
|
||||||
<< false // lock
|
<< false // lock
|
||||||
<< maybeSubstitute;
|
<< maybeSubstitute;
|
||||||
write(*this, conn->to, paths);
|
nix::worker_proto::write(*this, conn->to, paths);
|
||||||
conn->to.flush();
|
conn->to.flush();
|
||||||
|
|
||||||
return read(*this, conn->from, Proxy<StorePathSet> {});
|
return nix::worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void connect() override
|
void connect() override
|
||||||
|
|
|
@ -22,8 +22,9 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
namespace worker_proto {
|
||||||
|
|
||||||
std::string read(const Store & store, Source & from, Proxy<std::string> _)
|
std::string read(const Store & store, Source & from, Phantom<std::string> _)
|
||||||
{
|
{
|
||||||
return readString(from);
|
return readString(from);
|
||||||
}
|
}
|
||||||
|
@ -33,8 +34,7 @@ void write(const Store & store, Sink & out, const std::string & str)
|
||||||
out << str;
|
out << str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StorePath read(const Store & store, Source & from, Phantom<StorePath> _)
|
||||||
StorePath read(const Store & store, Source & from, Proxy<StorePath> _)
|
|
||||||
{
|
{
|
||||||
return store.parseStorePath(readString(from));
|
return store.parseStorePath(readString(from));
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,7 @@ void write(const Store & store, Sink & out, const StorePath & storePath)
|
||||||
out << store.printStorePath(storePath);
|
out << store.printStorePath(storePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContentAddress read(const Store & store, Source & from, Phantom<ContentAddress> _)
|
||||||
ContentAddress read(const Store & store, Source & from, Proxy<ContentAddress> _)
|
|
||||||
{
|
{
|
||||||
return parseContentAddress(readString(from));
|
return parseContentAddress(readString(from));
|
||||||
}
|
}
|
||||||
|
@ -55,6 +54,8 @@ void write(const Store & store, Sink & out, const ContentAddress & ca)
|
||||||
out << renderContentAddress(ca);
|
out << renderContentAddress(ca);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TODO: Separate these store impls into different files, give them better names */
|
/* TODO: Separate these store impls into different files, give them better names */
|
||||||
RemoteStore::RemoteStore(const Params & params)
|
RemoteStore::RemoteStore(const Params & params)
|
||||||
|
@ -289,9 +290,9 @@ StorePathSet RemoteStore::queryValidPaths(const StorePathSet & paths, Substitute
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
conn->to << wopQueryValidPaths;
|
conn->to << wopQueryValidPaths;
|
||||||
write(*this, conn->to, paths);
|
nix::worker_proto::write(*this, conn->to, paths);
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
return read(*this, conn->from, Proxy<StorePathSet> {});
|
return worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +302,7 @@ StorePathSet RemoteStore::queryAllValidPaths()
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
conn->to << wopQueryAllValidPaths;
|
conn->to << wopQueryAllValidPaths;
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
return read(*this, conn->from, Proxy<StorePathSet> {});
|
return nix::worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -318,9 +319,9 @@ StorePathSet RemoteStore::querySubstitutablePaths(const StorePathSet & paths)
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
conn->to << wopQuerySubstitutablePaths;
|
conn->to << wopQuerySubstitutablePaths;
|
||||||
write(*this, conn->to, paths);
|
nix::worker_proto::write(*this, conn->to, paths);
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
return read(*this, conn->from, Proxy<StorePathSet> {});
|
return worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +343,7 @@ void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, S
|
||||||
auto deriver = readString(conn->from);
|
auto deriver = readString(conn->from);
|
||||||
if (deriver != "")
|
if (deriver != "")
|
||||||
info.deriver = parseStorePath(deriver);
|
info.deriver = parseStorePath(deriver);
|
||||||
info.references = read(*this, conn->from, Proxy<StorePathSet> {});
|
info.references = worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
info.downloadSize = readLongLong(conn->from);
|
info.downloadSize = readLongLong(conn->from);
|
||||||
info.narSize = readLongLong(conn->from);
|
info.narSize = readLongLong(conn->from);
|
||||||
infos.insert_or_assign(i.first, std::move(info));
|
infos.insert_or_assign(i.first, std::move(info));
|
||||||
|
@ -355,9 +356,9 @@ void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, S
|
||||||
StorePathSet paths;
|
StorePathSet paths;
|
||||||
for (auto & path : pathsMap)
|
for (auto & path : pathsMap)
|
||||||
paths.insert(path.first);
|
paths.insert(path.first);
|
||||||
write(*this, conn->to, paths);
|
worker_proto::write(*this, conn->to, paths);
|
||||||
} else
|
} else
|
||||||
write(*this, conn->to, pathsMap);
|
worker_proto::write(*this, conn->to, pathsMap);
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
size_t count = readNum<size_t>(conn->from);
|
size_t count = readNum<size_t>(conn->from);
|
||||||
for (size_t n = 0; n < count; n++) {
|
for (size_t n = 0; n < count; n++) {
|
||||||
|
@ -365,7 +366,7 @@ void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, S
|
||||||
auto deriver = readString(conn->from);
|
auto deriver = readString(conn->from);
|
||||||
if (deriver != "")
|
if (deriver != "")
|
||||||
info.deriver = parseStorePath(deriver);
|
info.deriver = parseStorePath(deriver);
|
||||||
info.references = read(*this, conn->from, Proxy<StorePathSet> {});
|
info.references = worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
info.downloadSize = readLongLong(conn->from);
|
info.downloadSize = readLongLong(conn->from);
|
||||||
info.narSize = readLongLong(conn->from);
|
info.narSize = readLongLong(conn->from);
|
||||||
}
|
}
|
||||||
|
@ -398,7 +399,7 @@ void RemoteStore::queryPathInfoUncached(const StorePath & path,
|
||||||
auto deriver = readString(conn->from);
|
auto deriver = readString(conn->from);
|
||||||
if (deriver != "") info->deriver = parseStorePath(deriver);
|
if (deriver != "") info->deriver = parseStorePath(deriver);
|
||||||
info->narHash = Hash::parseAny(readString(conn->from), htSHA256);
|
info->narHash = Hash::parseAny(readString(conn->from), htSHA256);
|
||||||
info->references = read(*this, conn->from, Proxy<StorePathSet> {});
|
info->references = worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
conn->from >> info->registrationTime >> info->narSize;
|
conn->from >> info->registrationTime >> info->narSize;
|
||||||
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 16) {
|
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 16) {
|
||||||
conn->from >> info->ultimate;
|
conn->from >> info->ultimate;
|
||||||
|
@ -417,7 +418,7 @@ void RemoteStore::queryReferrers(const StorePath & path,
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
conn->to << wopQueryReferrers << printStorePath(path);
|
conn->to << wopQueryReferrers << printStorePath(path);
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
for (auto & i : read(*this, conn->from, Proxy<StorePathSet> {}))
|
for (auto & i : worker_proto::read(*this, conn->from, Phantom<StorePathSet> {}))
|
||||||
referrers.insert(i);
|
referrers.insert(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +428,7 @@ StorePathSet RemoteStore::queryValidDerivers(const StorePath & path)
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
conn->to << wopQueryValidDerivers << printStorePath(path);
|
conn->to << wopQueryValidDerivers << printStorePath(path);
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
return read(*this, conn->from, Proxy<StorePathSet> {});
|
return worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -439,7 +440,7 @@ StorePathSet RemoteStore::queryDerivationOutputs(const StorePath & path)
|
||||||
}
|
}
|
||||||
conn->to << wopQueryDerivationOutputs << printStorePath(path);
|
conn->to << wopQueryDerivationOutputs << printStorePath(path);
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
return read(*this, conn->from, Proxy<StorePathSet> {});
|
return worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -448,7 +449,7 @@ std::map<std::string, std::optional<StorePath>> RemoteStore::queryDerivationOutp
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
conn->to << wopQueryDerivationOutputMap << printStorePath(path);
|
conn->to << wopQueryDerivationOutputMap << printStorePath(path);
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
return read(*this, conn->from, Proxy<std::map<std::string, std::optional<StorePath>>> {});
|
return worker_proto::read(*this, conn->from, Phantom<std::map<std::string, std::optional<StorePath>>> {});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,7 +479,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
|
||||||
sink
|
sink
|
||||||
<< exportMagic
|
<< exportMagic
|
||||||
<< printStorePath(info.path);
|
<< printStorePath(info.path);
|
||||||
write(*this, sink, info.references);
|
worker_proto::write(*this, sink, info.references);
|
||||||
sink
|
sink
|
||||||
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
||||||
<< 0 // == no legacy signature
|
<< 0 // == no legacy signature
|
||||||
|
@ -488,7 +489,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
|
||||||
|
|
||||||
conn.processStderr(0, source2.get());
|
conn.processStderr(0, source2.get());
|
||||||
|
|
||||||
auto importedPaths = read(*this, conn->from, Proxy<StorePathSet> {});
|
auto importedPaths = worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
assert(importedPaths.size() <= 1);
|
assert(importedPaths.size() <= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +498,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
|
||||||
<< printStorePath(info.path)
|
<< printStorePath(info.path)
|
||||||
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
<< (info.deriver ? printStorePath(*info.deriver) : "")
|
||||||
<< info.narHash->to_string(Base16, false);
|
<< info.narHash->to_string(Base16, false);
|
||||||
write(*this, conn->to, info.references);
|
worker_proto::write(*this, conn->to, info.references);
|
||||||
conn->to << info.registrationTime << info.narSize
|
conn->to << info.registrationTime << info.narSize
|
||||||
<< info.ultimate << info.sigs << renderContentAddress(info.ca)
|
<< info.ultimate << info.sigs << renderContentAddress(info.ca)
|
||||||
<< repair << !checkSigs;
|
<< repair << !checkSigs;
|
||||||
|
@ -630,7 +631,7 @@ StorePath RemoteStore::addTextToStore(const string & name, const string & s,
|
||||||
|
|
||||||
auto conn(getConnection());
|
auto conn(getConnection());
|
||||||
conn->to << wopAddTextToStore << name << s;
|
conn->to << wopAddTextToStore << name << s;
|
||||||
write(*this, conn->to, references);
|
worker_proto::write(*this, conn->to, references);
|
||||||
|
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
return parseStorePath(readString(conn->from));
|
return parseStorePath(readString(conn->from));
|
||||||
|
@ -732,7 +733,7 @@ void RemoteStore::collectGarbage(const GCOptions & options, GCResults & results)
|
||||||
|
|
||||||
conn->to
|
conn->to
|
||||||
<< wopCollectGarbage << options.action;
|
<< wopCollectGarbage << options.action;
|
||||||
write(*this, conn->to, options.pathsToDelete);
|
worker_proto::write(*this, conn->to, options.pathsToDelete);
|
||||||
conn->to << options.ignoreLiveness
|
conn->to << options.ignoreLiveness
|
||||||
<< options.maxFreed
|
<< options.maxFreed
|
||||||
/* removed options */
|
/* removed options */
|
||||||
|
@ -794,9 +795,9 @@ void RemoteStore::queryMissing(const std::vector<StorePathWithOutputs> & targets
|
||||||
ss.push_back(p.to_string(*this));
|
ss.push_back(p.to_string(*this));
|
||||||
conn->to << ss;
|
conn->to << ss;
|
||||||
conn.processStderr();
|
conn.processStderr();
|
||||||
willBuild = read(*this, conn->from, Proxy<StorePathSet> {});
|
willBuild = worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
willSubstitute = read(*this, conn->from, Proxy<StorePathSet> {});
|
willSubstitute = worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
unknown = read(*this, conn->from, Proxy<StorePathSet> {});
|
unknown = worker_proto::read(*this, conn->from, Phantom<StorePathSet> {});
|
||||||
conn->from >> downloadSize >> narSize;
|
conn->from >> downloadSize >> narSize;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,15 +68,43 @@ struct Source;
|
||||||
|
|
||||||
/* To guide overloading */
|
/* To guide overloading */
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct Proxy {};
|
struct Phantom {};
|
||||||
|
|
||||||
|
|
||||||
|
namespace worker_proto {
|
||||||
|
/* FIXME maybe move more stuff inside here */
|
||||||
|
|
||||||
|
std::string read(const Store & store, Source & from, Phantom<std::string> _);
|
||||||
|
void write(const Store & store, Sink & out, const std::string & str);
|
||||||
|
|
||||||
|
StorePath read(const Store & store, Source & from, Phantom<StorePath> _);
|
||||||
|
void write(const Store & store, Sink & out, const StorePath & storePath);
|
||||||
|
|
||||||
|
ContentAddress read(const Store & store, Source & from, Phantom<ContentAddress> _);
|
||||||
|
void write(const Store & store, Sink & out, const ContentAddress & ca);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::set<T> read(const Store & store, Source & from, Proxy<std::set<T>> _)
|
std::set<T> read(const Store & store, Source & from, Phantom<std::set<T>> _);
|
||||||
|
template<typename T>
|
||||||
|
void write(const Store & store, Sink & out, const std::set<T> & resSet);
|
||||||
|
|
||||||
|
template<typename K, typename V>
|
||||||
|
std::map<K, V> read(const Store & store, Source & from, Phantom<std::map<K, V>> _);
|
||||||
|
template<typename K, typename V>
|
||||||
|
void write(const Store & store, Sink & out, const std::map<K, V> & resMap);
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::optional<T> read(const Store & store, Source & from, Phantom<std::optional<T>> _);
|
||||||
|
template<typename T>
|
||||||
|
void write(const Store & store, Sink & out, const std::optional<T> & optVal);
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
std::set<T> read(const Store & store, Source & from, Phantom<std::set<T>> _)
|
||||||
{
|
{
|
||||||
std::set<T> resSet;
|
std::set<T> resSet;
|
||||||
auto size = readNum<size_t>(from);
|
auto size = readNum<size_t>(from);
|
||||||
while (size--) {
|
while (size--) {
|
||||||
resSet.insert(read(store, from, Proxy<T> {}));
|
resSet.insert(read(store, from, Phantom<T> {}));
|
||||||
}
|
}
|
||||||
return resSet;
|
return resSet;
|
||||||
}
|
}
|
||||||
|
@ -91,14 +119,14 @@ void write(const Store & store, Sink & out, const std::set<T> & resSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename K, typename V>
|
template<typename K, typename V>
|
||||||
std::map<K, V> read(const Store & store, Source & from, Proxy<std::map<K, V>> _)
|
std::map<K, V> read(const Store & store, Source & from, Phantom<std::map<K, V>> _)
|
||||||
{
|
{
|
||||||
std::map<K, V> resMap;
|
std::map<K, V> resMap;
|
||||||
auto size = readNum<size_t>(from);
|
auto size = readNum<size_t>(from);
|
||||||
while (size--) {
|
while (size--) {
|
||||||
resMap.insert_or_assign(
|
resMap.insert_or_assign(
|
||||||
read(store, from, Proxy<K> {}),
|
read(store, from, Phantom<K> {}),
|
||||||
read(store, from, Proxy<V> {}));
|
read(store, from, Phantom<V> {}));
|
||||||
}
|
}
|
||||||
return resMap;
|
return resMap;
|
||||||
}
|
}
|
||||||
|
@ -107,21 +135,23 @@ template<typename K, typename V>
|
||||||
void write(const Store & store, Sink & out, const std::map<K, V> & resMap)
|
void write(const Store & store, Sink & out, const std::map<K, V> & resMap)
|
||||||
{
|
{
|
||||||
out << resMap.size();
|
out << resMap.size();
|
||||||
for (auto & [key, value] : resMap) {
|
for (auto & i : resMap) {
|
||||||
write(store, out, key);
|
// out << i.first;
|
||||||
write(store, out, value);
|
write(store, out, i.first);
|
||||||
|
write(store, out, i.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::optional<T> read(const Store & store, Source & from, Proxy<std::optional<T>> _)
|
std::optional<T> read(const Store & store, Source & from, Phantom<std::optional<T>> _)
|
||||||
{
|
{
|
||||||
auto tag = readNum<uint8_t>(from);
|
auto tag = readNum<uint8_t>(from);
|
||||||
switch (tag) {
|
switch (tag) {
|
||||||
case 0:
|
case 0:
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
case 1:
|
case 1:
|
||||||
return read(store, from, Proxy<T> {});
|
// return nix::worker_proto::read(store, from, Phantom<T> {});
|
||||||
|
return read(store, from, Phantom<T> {});
|
||||||
default:
|
default:
|
||||||
throw Error("got an invalid tag bit for std::optional: %#04x", (size_t)tag);
|
throw Error("got an invalid tag bit for std::optional: %#04x", (size_t)tag);
|
||||||
}
|
}
|
||||||
|
@ -132,19 +162,11 @@ void write(const Store & store, Sink & out, const std::optional<T> & optVal)
|
||||||
{
|
{
|
||||||
out << (uint64_t) (optVal ? 1 : 0);
|
out << (uint64_t) (optVal ? 1 : 0);
|
||||||
if (optVal)
|
if (optVal)
|
||||||
write(store, out, *optVal);
|
nix::worker_proto::write(store, out, *optVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string read(const Store & store, Source & from, Proxy<std::string> _);
|
|
||||||
|
|
||||||
void write(const Store & store, Sink & out, const std::string & str);
|
|
||||||
|
|
||||||
StorePath read(const Store & store, Source & from, Proxy<StorePath> _);
|
|
||||||
|
|
||||||
void write(const Store & store, Sink & out, const StorePath & storePath);
|
|
||||||
|
|
||||||
ContentAddress read(const Store & store, Source & from, Proxy<ContentAddress> _);
|
|
||||||
|
|
||||||
void write(const Store & store, Sink & out, const ContentAddress & ca);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -815,7 +815,7 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||||
case cmdQueryValidPaths: {
|
case cmdQueryValidPaths: {
|
||||||
bool lock = readInt(in);
|
bool lock = readInt(in);
|
||||||
bool substitute = readInt(in);
|
bool substitute = readInt(in);
|
||||||
auto paths = read(*store, in, Proxy<StorePathSet> {});
|
auto paths = nix::worker_proto::read(*store, in, Phantom<StorePathSet> {});
|
||||||
if (lock && writeAllowed)
|
if (lock && writeAllowed)
|
||||||
for (auto & path : paths)
|
for (auto & path : paths)
|
||||||
store->addTempRoot(path);
|
store->addTempRoot(path);
|
||||||
|
@ -845,19 +845,19 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
write(*store, out, store->queryValidPaths(paths));
|
nix::worker_proto::write(*store, out, store->queryValidPaths(paths));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case cmdQueryPathInfos: {
|
case cmdQueryPathInfos: {
|
||||||
auto paths = read(*store, in, Proxy<StorePathSet> {});
|
auto paths = nix::worker_proto::read(*store, in, Phantom<StorePathSet> {});
|
||||||
// !!! Maybe we want a queryPathInfos?
|
// !!! Maybe we want a queryPathInfos?
|
||||||
for (auto & i : paths) {
|
for (auto & i : paths) {
|
||||||
try {
|
try {
|
||||||
auto info = store->queryPathInfo(i);
|
auto info = store->queryPathInfo(i);
|
||||||
out << store->printStorePath(info->path)
|
out << store->printStorePath(info->path)
|
||||||
<< (info->deriver ? store->printStorePath(*info->deriver) : "");
|
<< (info->deriver ? store->printStorePath(*info->deriver) : "");
|
||||||
write(*store, out, info->references);
|
nix::worker_proto::write(*store, out, info->references);
|
||||||
// !!! Maybe we want compression?
|
// !!! Maybe we want compression?
|
||||||
out << info->narSize // downloadSize
|
out << info->narSize // downloadSize
|
||||||
<< info->narSize;
|
<< info->narSize;
|
||||||
|
@ -885,7 +885,7 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
case cmdExportPaths: {
|
case cmdExportPaths: {
|
||||||
readInt(in); // obsolete
|
readInt(in); // obsolete
|
||||||
store->exportPaths(read(*store, in, Proxy<StorePathSet> {}), out);
|
store->exportPaths(nix::worker_proto::read(*store, in, Phantom<StorePathSet> {}), out);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,9 +934,9 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||||
case cmdQueryClosure: {
|
case cmdQueryClosure: {
|
||||||
bool includeOutputs = readInt(in);
|
bool includeOutputs = readInt(in);
|
||||||
StorePathSet closure;
|
StorePathSet closure;
|
||||||
store->computeFSClosure(read(*store, in, Proxy<StorePathSet> {}),
|
store->computeFSClosure(nix::worker_proto::read(*store, in, Phantom<StorePathSet> {}),
|
||||||
closure, false, includeOutputs);
|
closure, false, includeOutputs);
|
||||||
write(*store, out, closure);
|
nix::worker_proto::write(*store, out, closure);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,7 +949,7 @@ static void opServe(Strings opFlags, Strings opArgs)
|
||||||
if (deriver != "")
|
if (deriver != "")
|
||||||
info.deriver = store->parseStorePath(deriver);
|
info.deriver = store->parseStorePath(deriver);
|
||||||
info.narHash = Hash::parseAny(readString(in), htSHA256);
|
info.narHash = Hash::parseAny(readString(in), htSHA256);
|
||||||
info.references = read(*store, in, Proxy<StorePathSet> {});
|
info.references = nix::worker_proto::read(*store, in, Phantom<StorePathSet> {});
|
||||||
in >> info.registrationTime >> info.narSize >> info.ultimate;
|
in >> info.registrationTime >> info.narSize >> info.ultimate;
|
||||||
info.sigs = readStrings<StringSet>(in);
|
info.sigs = readStrings<StringSet>(in);
|
||||||
info.ca = parseContentAddressOpt(readString(in));
|
info.ca = parseContentAddressOpt(readString(in));
|
||||||
|
|
Loading…
Reference in a new issue