aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstore/binary-cache-store.cc3
-rw-r--r--src/libstore/build.cc38
-rw-r--r--src/libstore/daemon.cc10
-rw-r--r--src/libstore/export-import.cc4
-rw-r--r--src/libstore/legacy-ssh-store.cc7
-rw-r--r--src/libstore/local-store.cc21
-rw-r--r--src/libstore/misc.cc3
-rw-r--r--src/libstore/nar-info-disk-cache.cc2
-rw-r--r--src/libstore/nar-info.cc2
-rw-r--r--src/libstore/path-info.hh49
-rw-r--r--src/libstore/remote-store.cc15
-rw-r--r--src/libstore/store-api.cc29
-rw-r--r--src/nix-store/dotgraph.cc2
-rw-r--r--src/nix-store/graphml.cc2
-rw-r--r--src/nix-store/nix-store.cc8
-rw-r--r--src/nix/make-content-addressable.cc2
-rw-r--r--src/nix/sigs.cc3
17 files changed, 121 insertions, 79 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc
index ebc0bd6a4..d32080692 100644
--- a/src/libstore/binary-cache-store.cc
+++ b/src/libstore/binary-cache-store.cc
@@ -199,8 +199,7 @@ void BinaryCacheStore::addToStore(const ValidPathInfo & info, Source & narSource
reads, but typically they'll already be cached. */
for (auto & ref : info.references)
try {
- if (ref != info.path)
- queryPathInfo(ref);
+ queryPathInfo(ref);
} catch (InvalidPath &) {
throw Error("cannot add '%s' to the binary cache because the reference '%s' is not valid",
printStorePath(info.path), printStorePath(ref));
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index db7dbc17e..90514d81e 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -3950,27 +3950,26 @@ void DerivationGoal::registerOutputs()
}
};
- auto rewriteRefs = [&]() -> std::pair<bool, StorePathSet> {
+ auto rewriteRefs = [&]() -> PathReferences<StorePath> {
/* In the CA case, we need the rewritten refs to calculate the
final path, therefore we look for a *non-rewritten
self-reference, and use a bool rather try to solve the
computationally intractable fixed point. */
- std::pair<bool, StorePathSet> res {
- false,
- {},
+ PathReferences<StorePath> res {
+ .hasSelfReference = false,
};
for (auto & r : references) {
auto name = r.name();
auto origHash = std::string { r.hashPart() };
if (r == scratchPath)
- res.first = true;
+ res.hasSelfReference = true;
else if (outputRewrites.count(origHash) == 0)
- res.second.insert(r);
+ res.references.insert(r);
else {
std::string newRef = outputRewrites.at(origHash);
newRef += '-';
newRef += name;
- res.second.insert(StorePath { newRef });
+ res.references.insert(StorePath { newRef });
}
}
return res;
@@ -4008,8 +4007,8 @@ void DerivationGoal::registerOutputs()
outputHash.method,
got,
outputPathName(drv->name, outputName),
- refs.second,
- refs.first),
+ refs.references,
+ refs.hasSelfReference),
narHashAndSize.first,
};
newInfo0.narSize = narHashAndSize.second;
@@ -4017,9 +4016,7 @@ void DerivationGoal::registerOutputs()
.method = outputHash.method,
.hash = got,
};
- newInfo0.references = refs.second;
- if (refs.first)
- newInfo0.references.insert(newInfo0.path);
+ static_cast<PathReferences<StorePath> &>(newInfo0) = refs;
assert(newInfo0.ca);
return newInfo0;
@@ -4039,10 +4036,7 @@ void DerivationGoal::registerOutputs()
auto narHashAndSize = hashPath(htSHA256, actualPath);
ValidPathInfo newInfo0 { requiredFinalPath, narHashAndSize.first };
newInfo0.narSize = narHashAndSize.second;
- auto refs = rewriteRefs();
- newInfo0.references = refs.second;
- if (refs.first)
- newInfo0.references.insert(newInfo0.path);
+ static_cast<PathReferences<StorePath> &>(newInfo0) = rewriteRefs();
return newInfo0;
},
[&](DerivationOutputCAFixed dof) {
@@ -4297,12 +4291,12 @@ void DerivationGoal::checkOutputs(const std::map<Path, ValidPathInfo> & outputs)
auto i = outputsByPath.find(worker.store.printStorePath(path));
if (i != outputsByPath.end()) {
closureSize += i->second.narSize;
- for (auto & ref : i->second.references)
+ for (auto & ref : i->second.referencesPossiblyToSelf())
pathsLeft.push(ref);
} else {
auto info = worker.store.queryPathInfo(path);
closureSize += info->narSize;
- for (auto & ref : info->references)
+ for (auto & ref : info->referencesPossiblyToSelf())
pathsLeft.push(ref);
}
}
@@ -4341,7 +4335,7 @@ void DerivationGoal::checkOutputs(const std::map<Path, ValidPathInfo> & outputs)
auto used = recursive
? getClosure(info.path).first
- : info.references;
+ : info.referencesPossiblyToSelf();
if (recursive && checks.ignoreSelfRefs)
used.erase(info.path);
@@ -4871,8 +4865,7 @@ void SubstitutionGoal::tryNext()
/* To maintain the closure invariant, we first have to realise the
paths referenced by this one. */
for (auto & i : info->references)
- if (i != storePath) /* ignore self-references */
- addWaitee(worker.makeSubstitutionGoal(i));
+ addWaitee(worker.makeSubstitutionGoal(i));
if (waitees.empty()) /* to prevent hang (no wake-up event) */
referencesValid();
@@ -4892,8 +4885,7 @@ void SubstitutionGoal::referencesValid()
}
for (auto & i : info->references)
- if (i != storePath) /* ignore self-references */
- assert(worker.store.isValidPath(i));
+ assert(worker.store.isValidPath(i));
state = &SubstitutionGoal::tryToRun;
worker.wakeUp(shared_from_this());
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc
index 83f8968b0..a421ec2f7 100644
--- a/src/libstore/daemon.cc
+++ b/src/libstore/daemon.cc
@@ -247,7 +247,7 @@ static void writeValidPathInfo(
{
to << (info->deriver ? store->printStorePath(*info->deriver) : "")
<< info->narHash.to_string(Base16, false);
- writeStorePaths(*store, to, info->references);
+ writeStorePaths(*store, to, info->referencesPossiblyToSelf());
to << info->registrationTime << info->narSize;
if (GET_PROTOCOL_MINOR(clientVersion) >= 16) {
to << info->ultimate
@@ -317,7 +317,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
logger->startWork();
StorePathSet paths;
if (op == wopQueryReferences)
- for (auto & i : store->queryPathInfo(path)->references)
+ for (auto & i : store->queryPathInfo(path)->referencesPossiblyToSelf())
paths.insert(i);
else if (op == wopQueryReferrers)
store->queryReferrers(path, paths);
@@ -677,7 +677,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
else {
to << 1
<< (i->second.deriver ? store->printStorePath(*i->second.deriver) : "");
- writeStorePaths(*store, to, i->second.references);
+ writeStorePaths(*store, to, i->second.referencesPossiblyToSelf(path));
to << i->second.downloadSize
<< i->second.narSize;
}
@@ -700,7 +700,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
for (auto & i : infos) {
to << store->printStorePath(i.first)
<< (i.second.deriver ? store->printStorePath(*i.second.deriver) : "");
- writeStorePaths(*store, to, i.second.references);
+ writeStorePaths(*store, to, i.second.referencesPossiblyToSelf(i.first));
to << i.second.downloadSize << i.second.narSize;
}
break;
@@ -782,7 +782,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
ValidPathInfo info { path, narHash };
if (deriver != "")
info.deriver = store->parseStorePath(deriver);
- info.references = readStorePaths<StorePathSet>(*store, from);
+ info.setReferencesPossiblyToSelf(readStorePaths<StorePathSet>(*store, from));
from >> info.registrationTime >> info.narSize >> info.ultimate;
info.sigs = readStrings<StringSet>(from);
info.ca = parseContentAddressOpt(readString(from));
diff --git a/src/libstore/export-import.cc b/src/libstore/export-import.cc
index ccd466d09..0640add0e 100644
--- a/src/libstore/export-import.cc
+++ b/src/libstore/export-import.cc
@@ -45,7 +45,7 @@ void Store::exportPath(const StorePath & path, Sink & sink)
teeSink
<< exportMagic
<< printStorePath(path);
- writeStorePaths(*this, teeSink, info->references);
+ writeStorePaths(*this, teeSink, info->referencesPossiblyToSelf());
teeSink
<< (info->deriver ? printStorePath(*info->deriver) : "")
<< 0;
@@ -80,7 +80,7 @@ StorePaths Store::importPaths(Source & source, CheckSigsFlag checkSigs)
ValidPathInfo info { path, narHash };
if (deriver != "")
info.deriver = parseStorePath(deriver);
- info.references = references;
+ info.setReferencesPossiblyToSelf(std::move(references));
info.narSize = saved.s->size();
// Ignore optional legacy signature.
diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc
index 5af75669a..202b7b8a5 100644
--- a/src/libstore/legacy-ssh-store.cc
+++ b/src/libstore/legacy-ssh-store.cc
@@ -118,11 +118,10 @@ struct LegacySSHStore : public Store, public virtual LegacySSHStoreConfig
/* Hash will be set below. FIXME construct ValidPathInfo at end. */
auto info = std::make_shared<ValidPathInfo>(path, Hash::dummy);
- PathSet references;
auto deriver = readString(conn->from);
if (deriver != "")
info->deriver = parseStorePath(deriver);
- info->references = readStorePaths<StorePathSet>(*this, conn->from);
+ info->setReferencesPossiblyToSelf(readStorePaths<StorePathSet>(*this, conn->from));
readLongLong(conn->from); // download size
info->narSize = readLongLong(conn->from);
@@ -156,7 +155,7 @@ struct LegacySSHStore : public Store, public virtual LegacySSHStoreConfig
<< printStorePath(info.path)
<< (info.deriver ? printStorePath(*info.deriver) : "")
<< info.narHash.to_string(Base16, false);
- writeStorePaths(*this, conn->to, info.references);
+ writeStorePaths(*this, conn->to, info.referencesPossiblyToSelf());
conn->to
<< info.registrationTime
<< info.narSize
@@ -185,7 +184,7 @@ struct LegacySSHStore : public Store, public virtual LegacySSHStoreConfig
conn->to
<< exportMagic
<< printStorePath(info.path);
- writeStorePaths(*this, conn->to, info.references);
+ writeStorePaths(*this, conn->to, info.referencesPossiblyToSelf());
conn->to
<< (info.deriver ? printStorePath(*info.deriver) : "")
<< 0
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index ee997ef3a..30dfc7591 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -693,8 +693,10 @@ void LocalStore::queryPathInfoUncached(const StorePath & path,
/* Get the references. */
auto useQueryReferences(state->stmtQueryReferences.use()(info->id));
- while (useQueryReferences.next())
- info->references.insert(parseStorePath(useQueryReferences.getStr(0)));
+ while (useQueryReferences.next()) {
+ info->insertReferencePossiblyToSelf(
+ parseStorePath(useQueryReferences.getStr(0)));
+ }
return info;
}));
@@ -898,10 +900,12 @@ void LocalStore::querySubstitutablePathInfos(const StorePathCAMap & paths, Subst
auto narInfo = std::dynamic_pointer_cast<const NarInfo>(
std::shared_ptr<const ValidPathInfo>(info));
infos.insert_or_assign(path.first, SubstitutablePathInfo{
- info->deriver,
info->references,
+ info->hasSelfReference,
+ info->deriver,
narInfo ? narInfo->fileSize : 0,
- info->narSize});
+ info->narSize,
+ });
} catch (InvalidPath &) {
} catch (SubstituterDisabled &) {
} catch (Error & e) {
@@ -948,7 +952,7 @@ void LocalStore::registerValidPaths(const ValidPathInfos & infos)
for (auto & i : infos) {
auto referrer = queryValidPathId(*state, i.path);
- for (auto & j : i.references)
+ for (auto & j : i.referencesPossiblyToSelf())
state->stmtAddReference.use()(referrer)(queryValidPathId(*state, j)).exec();
}
@@ -1024,14 +1028,13 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
deletePath(realPath);
// text hashing has long been allowed to have non-self-references because it is used for drv files.
- bool refersToSelf = info.references.count(info.path) > 0;
- if (info.ca.has_value() && !info.references.empty() && !(std::holds_alternative<TextHash>(*info.ca) && !refersToSelf))
+ if (info.ca.has_value() && !info.references.empty() && !(std::holds_alternative<TextHash>(*info.ca) && info.hasSelfReference))
settings.requireExperimentalFeature("ca-references");
/* While restoring the path from the NAR, compute the hash
of the NAR. */
std::unique_ptr<AbstractHashSink> hashSink;
- if (!info.ca.has_value() || !info.references.count(info.path))
+ if (!info.ca.has_value() || !info.hasSelfReference)
hashSink = std::make_unique<HashSink>(htSHA256);
else
hashSink = std::make_unique<HashModuloSink>(htSHA256, std::string(info.path.hashPart()));
@@ -1323,7 +1326,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
printMsg(lvlTalkative, "checking contents of '%s'", printStorePath(i));
std::unique_ptr<AbstractHashSink> hashSink;
- if (!info->ca || !info->references.count(info->path))
+ if (!info->ca || !info->hasSelfReference)
hashSink = std::make_unique<HashSink>(info->narHash.type);
else
hashSink = std::make_unique<HashModuloSink>(info->narHash.type, std::string(info->path.hashPart()));
diff --git a/src/libstore/misc.cc b/src/libstore/misc.cc
index ad4dccef9..052936a8b 100644
--- a/src/libstore/misc.cc
+++ b/src/libstore/misc.cc
@@ -62,8 +62,7 @@ void Store::computeFSClosure(const StorePathSet & startPaths,
} else {
for (auto & ref : info->references)
- if (ref != path)
- enqueue(printStorePath(ref));
+ enqueue(printStorePath(ref));
if (includeOutputs && path.isDerivation())
for (auto & i : queryDerivationOutputs(path))
diff --git a/src/libstore/nar-info-disk-cache.cc b/src/libstore/nar-info-disk-cache.cc
index 8541cc51f..759342d84 100644
--- a/src/libstore/nar-info-disk-cache.cc
+++ b/src/libstore/nar-info-disk-cache.cc
@@ -199,7 +199,7 @@ public:
narInfo->fileSize = queryNAR.getInt(5);
narInfo->narSize = queryNAR.getInt(7);
for (auto & r : tokenizeString<Strings>(queryNAR.getStr(8), " "))
- narInfo->references.insert(StorePath(r));
+ narInfo->insertReferencePossiblyToSelf(StorePath(r));
if (!queryNAR.isNull(9))
narInfo->deriver = StorePath(queryNAR.getStr(9));
for (auto & sig : tokenizeString<Strings>(queryNAR.getStr(10), " "))
diff --git a/src/libstore/nar-info.cc b/src/libstore/nar-info.cc
index 3454f34bb..7c5c8fdd1 100644
--- a/src/libstore/nar-info.cc
+++ b/src/libstore/nar-info.cc
@@ -59,7 +59,7 @@ NarInfo::NarInfo(const Store & store, const std::string & s, const std::string &
auto refs = tokenizeString<Strings>(value, " ");
if (!references.empty()) throw corrupt();
for (auto & r : refs)
- references.insert(StorePath(r));
+ insertReferencePossiblyToSelf(StorePath(r));
}
else if (name == "Deriver") {
if (value != "unknown-deriver")
diff --git a/src/libstore/path-info.hh b/src/libstore/path-info.hh
index 8ff5c466e..509f100d7 100644
--- a/src/libstore/path-info.hh
+++ b/src/libstore/path-info.hh
@@ -13,25 +13,63 @@ namespace nix {
class Store;
+template<typename Ref>
+struct PathReferences
+{
+ std::set<Ref> references;
+ bool hasSelfReference = false;
+
+ /* Functions to view references + hasSelfReference as one set, mainly for
+ compatibility's sake. */
+ StorePathSet referencesPossiblyToSelf(const Ref & self) const;
+ void insertReferencePossiblyToSelf(const Ref & self, Ref && ref);
+ void setReferencesPossiblyToSelf(const Ref & self, std::set<Ref> && refs);
+};
-struct SubstitutablePathInfo
+template<typename Ref>
+StorePathSet PathReferences<Ref>::referencesPossiblyToSelf(const Ref & self) const
+{
+ StorePathSet refs { references };
+ if (hasSelfReference)
+ refs.insert(self);
+ return refs;
+}
+
+template<typename Ref>
+void PathReferences<Ref>::insertReferencePossiblyToSelf(const Ref & self, Ref && ref)
+{
+ if (ref == self)
+ hasSelfReference = true;
+ else
+ references.insert(std::move(ref));
+}
+
+template<typename Ref>
+void PathReferences<Ref>::setReferencesPossiblyToSelf(const Ref & self, std::set<Ref> && refs)
+{
+ if (refs.count(self))
+ hasSelfReference = true;
+ refs.erase(self);
+
+ references = refs;
+}
+
+
+struct SubstitutablePathInfo : PathReferences<StorePath>
{
std::optional<StorePath> deriver;
- StorePathSet references;
uint64_t downloadSize; /* 0 = unknown or inapplicable */
uint64_t narSize; /* 0 = unknown */
};
typedef std::map<StorePath, SubstitutablePathInfo> SubstitutablePathInfos;
-
-struct ValidPathInfo
+struct ValidPathInfo : PathReferences<StorePath>
{
StorePath path;
std::optional<StorePath> deriver;
// TODO document this
Hash narHash;
- StorePathSet references;
time_t registrationTime = 0;
uint64_t narSize = 0; // 0 = unknown
uint64_t id; // internal use only
@@ -65,6 +103,7 @@ struct ValidPathInfo
return
path == i.path
&& narHash == i.narHash
+ && hasSelfReference == i.hasSelfReference
&& references == i.references;
}
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index be5eb4736..831db0bb8 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -390,7 +390,7 @@ void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, S
auto deriver = readString(conn->from);
if (deriver != "")
info.deriver = parseStorePath(deriver);
- info.references = readStorePaths<StorePathSet>(*this, conn->from);
+ info.setReferencesPossiblyToSelf(i.first, readStorePaths<StorePathSet>(*this, conn->from));
info.downloadSize = readLongLong(conn->from);
info.narSize = readLongLong(conn->from);
infos.insert_or_assign(i.first, std::move(info));
@@ -409,11 +409,12 @@ void RemoteStore::querySubstitutablePathInfos(const StorePathCAMap & pathsMap, S
conn.processStderr();
size_t count = readNum<size_t>(conn->from);
for (size_t n = 0; n < count; n++) {
- SubstitutablePathInfo & info(infos[parseStorePath(readString(conn->from))]);
+ auto path = parseStorePath(readString(conn->from));
+ SubstitutablePathInfo & info { infos[path] };
auto deriver = readString(conn->from);
if (deriver != "")
info.deriver = parseStorePath(deriver);
- info.references = readStorePaths<StorePathSet>(*this, conn->from);
+ info.setReferencesPossiblyToSelf(path, readStorePaths<StorePathSet>(*this, conn->from));
info.downloadSize = readLongLong(conn->from);
info.narSize = readLongLong(conn->from);
}
@@ -428,7 +429,7 @@ ref<const ValidPathInfo> RemoteStore::readValidPathInfo(ConnectionHandle & conn,
auto narHash = Hash::parseAny(readString(conn->from), htSHA256);
auto info = make_ref<ValidPathInfo>(path, narHash);
if (deriver != "") info->deriver = parseStorePath(deriver);
- info->references = readStorePaths<StorePathSet>(*this, conn->from);
+ info->setReferencesPossiblyToSelf(readStorePaths<StorePathSet>(*this, conn->from));
conn->from >> info->registrationTime >> info->narSize;
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 16) {
conn->from >> info->ultimate;
@@ -636,7 +637,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
sink
<< exportMagic
<< printStorePath(info.path);
- writeStorePaths(*this, sink, info.references);
+ writeStorePaths(*this, sink, info.referencesPossiblyToSelf());
sink
<< (info.deriver ? printStorePath(*info.deriver) : "")
<< 0 // == no legacy signature
@@ -647,7 +648,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
conn.processStderr(0, source2.get());
auto importedPaths = readStorePaths<StorePathSet>(*this, conn->from);
- assert(importedPaths.size() <= 1);
+ assert(importedPaths.empty() == 0); // doesn't include possible self reference
}
else {
@@ -655,7 +656,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source,
<< printStorePath(info.path)
<< (info.deriver ? printStorePath(*info.deriver) : "")
<< info.narHash.to_string(Base16, false);
- writeStorePaths(*this, conn->to, info.references);
+ writeStorePaths(*this, conn->to, info.referencesPossiblyToSelf());
conn->to << info.registrationTime << info.narSize
<< info.ultimate << info.sigs << renderContentAddress(info.ca)
<< repair << !checkSigs;
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 1bbc74db8..7041edbe5 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -891,7 +891,7 @@ std::optional<ValidPathInfo> decodeValidPathInfo(const Store & store, std::istre
if (!string2Int(s, n)) throw Error("number expected");
while (n--) {
getline(str, s);
- info.references.insert(store.parseStorePath(s));
+ info.insertReferencePossiblyToSelf(store.parseStorePath(s));
}
if (!str || str.eof()) throw Error("missing input");
return std::optional<ValidPathInfo>(std::move(info));
@@ -914,6 +914,20 @@ string showPaths(const PathSet & paths)
return concatStringsSep(", ", quoteStrings(paths));
}
+StorePathSet ValidPathInfo::referencesPossiblyToSelf() const
+{
+ return PathReferences<StorePath>::referencesPossiblyToSelf(path);
+}
+
+void ValidPathInfo::insertReferencePossiblyToSelf(StorePath && ref)
+{
+ return PathReferences<StorePath>::insertReferencePossiblyToSelf(path, std::move(ref));
+}
+
+void ValidPathInfo::setReferencesPossiblyToSelf(StorePathSet && refs)
+{
+ return PathReferences<StorePath>::setReferencesPossiblyToSelf(path, std::move(refs));
+}
std::string ValidPathInfo::fingerprint(const Store & store) const
{
@@ -924,7 +938,7 @@ std::string ValidPathInfo::fingerprint(const Store & store) const
"1;" + store.printStorePath(path) + ";"
+ narHash.to_string(Base32, true) + ";"
+ std::to_string(narSize) + ";"
- + concatStringsSep(",", store.printStorePathSet(references));
+ + concatStringsSep(",", store.printStorePathSet(referencesPossiblyToSelf()));
}
@@ -939,16 +953,11 @@ bool ValidPathInfo::isContentAddressed(const Store & store) const
auto caPath = std::visit(overloaded {
[&](TextHash th) {
+ assert(!hasSelfReference);
return store.makeTextPath(path.name(), th.hash, references);
},
[&](FixedOutputHash fsh) {
- auto refs = references;
- bool hasSelfReference = false;
- if (refs.count(path)) {
- hasSelfReference = true;
- refs.erase(path);
- }
- return store.makeFixedOutputPath(fsh.method, fsh.hash, path.name(), refs, hasSelfReference);
+ return store.makeFixedOutputPath(fsh.method, fsh.hash, path.name(), references, hasSelfReference);
}
}, *ca);
@@ -982,7 +991,7 @@ bool ValidPathInfo::checkSignature(const Store & store, const PublicKeys & publi
Strings ValidPathInfo::shortRefs() const
{
Strings refs;
- for (auto & r : references)
+ for (auto & r : referencesPossiblyToSelf())
refs.push_back(std::string(r.to_string()));
return refs;
}
diff --git a/src/nix-store/dotgraph.cc b/src/nix-store/dotgraph.cc
index 8b699f39b..45abe0405 100644
--- a/src/nix-store/dotgraph.cc
+++ b/src/nix-store/dotgraph.cc
@@ -58,7 +58,7 @@ void printDotGraph(ref<Store> store, StorePathSet && roots)
cout << makeNode(std::string(path.to_string()), path.name(), "#ff0000");
- for (auto & p : store->queryPathInfo(path)->references) {
+ for (auto & p : store->queryPathInfo(path)->referencesPossiblyToSelf()) {
if (p != path) {
workList.insert(p);
cout << makeEdge(std::string(p.to_string()), std::string(path.to_string()));
diff --git a/src/nix-store/graphml.cc b/src/nix-store/graphml.cc
index 8ca5c9c8d..1cd974e41 100644
--- a/src/nix-store/graphml.cc
+++ b/src/nix-store/graphml.cc
@@ -71,7 +71,7 @@ void printGraphML(ref<Store> store, StorePathSet && roots)
auto info = store->queryPathInfo(path);
cout << makeNode(*info);
- for (auto & p : info->references) {
+ for (auto & p : info->referencesPossiblyToSelf()) {
if (p != path) {
workList.insert(p);
cout << makeEdge(path.to_string(), p.to_string());
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index b027e84b7..9973b9829 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -251,7 +251,7 @@ static void printTree(const StorePath & path,
closure(B). That is, if derivation A is an (possibly indirect)
input of B, then A is printed first. This has the effect of
flattening the tree, preventing deeply nested structures. */
- auto sorted = store->topoSortPaths(info->references);
+ auto sorted = store->topoSortPaths(info->referencesPossiblyToSelf());
reverse(sorted.begin(), sorted.end());
for (const auto &[n, i] : enumerate(sorted)) {
@@ -332,7 +332,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
for (auto & j : ps) {
if (query == qRequisites) store->computeFSClosure(j, paths, false, includeOutputs);
else if (query == qReferences) {
- for (auto & p : store->queryPathInfo(j)->references)
+ for (auto & p : store->queryPathInfo(j)->referencesPossiblyToSelf())
paths.insert(p);
}
else if (query == qReferrers) {
@@ -864,7 +864,7 @@ static void opServe(Strings opFlags, Strings opArgs)
auto info = store->queryPathInfo(i);
out << store->printStorePath(info->path)
<< (info->deriver ? store->printStorePath(*info->deriver) : "");
- writeStorePaths(*store, out, info->references);
+ writeStorePaths(*store, out, info->referencesPossiblyToSelf());
// !!! Maybe we want compression?
out << info->narSize // downloadSize
<< info->narSize;
@@ -958,7 +958,7 @@ static void opServe(Strings opFlags, Strings opArgs)
};
if (deriver != "")
info.deriver = store->parseStorePath(deriver);
- info.references = readStorePaths<StorePathSet>(*store, in);
+ info.setReferencesPossiblyToSelf(readStorePaths<StorePathSet>(*store, in));
in >> info.registrationTime >> info.narSize >> info.ultimate;
info.sigs = readStrings<StringSet>(in);
info.ca = parseContentAddressOpt(readString(in));
diff --git a/src/nix/make-content-addressable.cc b/src/nix/make-content-addressable.cc
index 38b60fc38..7737f6d91 100644
--- a/src/nix/make-content-addressable.cc
+++ b/src/nix/make-content-addressable.cc
@@ -82,7 +82,7 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
narHash,
};
info.references = std::move(references);
- if (hasSelfReference) info.references.insert(info.path);
+ info.hasSelfReference = std::move(hasSelfReference);
info.narSize = sink.s->size();
info.ca = FixedOutputHash {
.method = FileIngestionMethod::Recursive,
diff --git a/src/nix/sigs.cc b/src/nix/sigs.cc
index 7821a5432..fae78c5b4 100644
--- a/src/nix/sigs.cc
+++ b/src/nix/sigs.cc
@@ -65,7 +65,8 @@ struct CmdCopySigs : StorePathsCommand
binary. */
if (info->narHash != info2->narHash ||
info->narSize != info2->narSize ||
- info->references != info2->references)
+ info->references != info2->references ||
+ info->hasSelfReference != info2->hasSelfReference)
continue;
for (auto & sig : info2->sigs)