aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/add-to-store.cc16
-rw-r--r--src/nix/make-content-addressable.cc38
-rw-r--r--src/nix/prefetch.cc8
-rw-r--r--src/nix/profile.cc13
-rw-r--r--src/nix/sigs.cc3
-rw-r--r--src/nix/verify.cc6
6 files changed, 53 insertions, 31 deletions
diff --git a/src/nix/add-to-store.cc b/src/nix/add-to-store.cc
index 2ae042789..ab2b62da2 100644
--- a/src/nix/add-to-store.cc
+++ b/src/nix/add-to-store.cc
@@ -42,14 +42,20 @@ struct CmdAddToStore : MixDryRun, StoreCommand
}
ValidPathInfo info {
- store->makeFixedOutputPath(ingestionMethod, hash, *namePart),
+ *store,
+ StorePathDescriptor {
+ .name = *namePart,
+ .info = FixedOutputInfo {
+ {
+ .method = std::move(ingestionMethod),
+ .hash = std::move(hash),
+ },
+ {},
+ },
+ },
narHash,
};
info.narSize = sink.s->size();
- info.ca = std::optional { FixedOutputHash {
- .method = ingestionMethod,
- .hash = hash,
- } };
if (!dryRun) {
auto source = StringSource { *sink.s };
diff --git a/src/nix/make-content-addressable.cc b/src/nix/make-content-addressable.cc
index f5bdc7e65..29f855f95 100644
--- a/src/nix/make-content-addressable.cc
+++ b/src/nix/make-content-addressable.cc
@@ -46,19 +46,15 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
StringMap rewrites;
- StorePathSet references;
- bool hasSelfReference = false;
+ PathReferences<StorePath> refs;
+ refs.hasSelfReference = oldInfo->hasSelfReference;
for (auto & ref : oldInfo->references) {
- if (ref == path)
- hasSelfReference = true;
- else {
- auto i = remappings.find(ref);
- auto replacement = i != remappings.end() ? i->second : ref;
- // FIXME: warn about unremapped paths?
- if (replacement != ref)
- rewrites.insert_or_assign(store->printStorePath(ref), store->printStorePath(replacement));
- references.insert(std::move(replacement));
- }
+ auto i = remappings.find(ref);
+ auto replacement = i != remappings.end() ? i->second : ref;
+ // FIXME: warn about unremapped paths?
+ if (replacement != ref)
+ rewrites.insert_or_assign(store->printStorePath(ref), store->printStorePath(replacement));
+ refs.references.insert(std::move(replacement));
}
*sink.s = rewriteStrings(*sink.s, rewrites);
@@ -69,16 +65,20 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON
auto narHash = hashModuloSink.finish().first;
ValidPathInfo info {
- store->makeFixedOutputPath(FileIngestionMethod::Recursive, narHash, path.name(), references, hasSelfReference),
+ *store,
+ StorePathDescriptor {
+ .name = std::string { path.name() },
+ .info = FixedOutputInfo {
+ {
+ .method = FileIngestionMethod::Recursive,
+ .hash = narHash,
+ },
+ std::move(refs),
+ },
+ },
narHash,
};
- info.references = std::move(references);
- if (hasSelfReference) info.references.insert(info.path);
info.narSize = sink.s->size();
- info.ca = FixedOutputHash {
- .method = FileIngestionMethod::Recursive,
- .hash = info.narHash,
- };
if (!json)
notice("rewrote '%s' to '%s'", pathS, store->printStorePath(info.path));
diff --git a/src/nix/prefetch.cc b/src/nix/prefetch.cc
index b7da3ea5a..07c41587e 100644
--- a/src/nix/prefetch.cc
+++ b/src/nix/prefetch.cc
@@ -67,7 +67,13 @@ std::tuple<StorePath, Hash> prefetchFile(
the store. */
if (expectedHash) {
hashType = expectedHash->type;
- storePath = store->makeFixedOutputPath(ingestionMethod, *expectedHash, *name);
+ storePath = store->makeFixedOutputPath(*name, FixedOutputInfo {
+ {
+ .method = ingestionMethod,
+ .hash = *expectedHash,
+ },
+ {},
+ });
if (store->isValidPath(*storePath))
hash = expectedHash;
else
diff --git a/src/nix/profile.cc b/src/nix/profile.cc
index 4d275f577..bd1be44e6 100644
--- a/src/nix/profile.cc
+++ b/src/nix/profile.cc
@@ -161,12 +161,21 @@ struct ProfileManifest
auto narHash = hashString(htSHA256, *sink.s);
ValidPathInfo info {
- store->makeFixedOutputPath(FileIngestionMethod::Recursive, narHash, "profile", references),
+ *store,
+ StorePathDescriptor {
+ "profile",
+ FixedOutputInfo {
+ {
+ .method = FileIngestionMethod::Recursive,
+ .hash = narHash,
+ },
+ { references },
+ },
+ },
narHash,
};
info.references = std::move(references);
info.narSize = sink.s->size();
- info.ca = FixedOutputHash { .method = FileIngestionMethod::Recursive, .hash = info.narHash };
auto source = StringSource { *sink.s };
store->addToStore(info, source);
diff --git a/src/nix/sigs.cc b/src/nix/sigs.cc
index c64b472b6..10d0ae985 100644
--- a/src/nix/sigs.cc
+++ b/src/nix/sigs.cc
@@ -63,7 +63,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)
diff --git a/src/nix/verify.cc b/src/nix/verify.cc
index 1721c7f16..e01014440 100644
--- a/src/nix/verify.cc
+++ b/src/nix/verify.cc
@@ -81,14 +81,14 @@ struct CmdVerify : StorePathsCommand
ThreadPool pool;
- auto doPath = [&](const Path & storePath) {
+ auto doPath = [&](const StorePath & storePath) {
try {
checkInterrupt();
MaintainCount<std::atomic<size_t>> mcActive(active);
update();
- auto info = store->queryPathInfo(store->parseStorePath(storePath));
+ auto info = store->queryPathInfo(storePath);
// Note: info->path can be different from storePath
// for binary cache stores when using --all (since we
@@ -177,7 +177,7 @@ struct CmdVerify : StorePathsCommand
};
for (auto & storePath : storePaths)
- pool.enqueue(std::bind(doPath, store->printStorePath(storePath)));
+ pool.enqueue(std::bind(doPath, storePath));
pool.process();