Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
1722ae6
Pull out PathReferences super class
Ericson2314 Jun 25, 2020
71e4c9c
WIP: store separate `hasValidPath` bool
Ericson2314 Jun 24, 2020
a9c0ea3
Backport fix from #3754 branch
Ericson2314 Jun 29, 2020
70ed47c
Fix some things in remote store
Ericson2314 Jun 29, 2020
6683406
Fix nar info parsing
Ericson2314 Jun 29, 2020
0e9e599
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Aug 1, 2020
36dd792
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Aug 4, 2020
e61061c
Remove stray tabs
Ericson2314 Aug 4, 2020
45ca7c3
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Sep 23, 2020
dae4409
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Oct 6, 2020
f8d562c
Use PathReferences more widely
Ericson2314 Oct 7, 2020
a0f369a
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Oct 12, 2020
39c11c5
Organize content-address.hh a bit better
Ericson2314 Oct 13, 2020
34b3bfa
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Oct 13, 2020
10e81bf
Fix conditions for ca-references
Ericson2314 Oct 15, 2020
ca09948
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Feb 25, 2021
f0ad29a
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Feb 27, 2021
e12308d
Merge branch 'master' into path-info
Ericson2314 Apr 5, 2021
d5cef6c
Merge commit '9dfb97c987d8b9d6a3d15f016e40f22f91deb764' into path-info
Ericson2314 Apr 5, 2021
1b6cf0d
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Apr 5, 2021
f4f3203
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Sep 30, 2021
13b6b64
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Oct 1, 2021
8ba0895
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Mar 10, 2022
0dc2974
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Mar 25, 2022
2c21cb6
Fill in missing comparison operators for content addresses
Ericson2314 Mar 25, 2022
13c6691
Slight cleanups
Ericson2314 Apr 19, 2022
55caef3
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Apr 19, 2022
e9fc1e4
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Jan 6, 2023
8623143
Make formatting consistent
Ericson2314 Jan 6, 2023
6a16825
Use named field initialization for references
Ericson2314 Jan 6, 2023
9cfa78e
Optimize `ValidPathInfo` construction a bit better
Ericson2314 Jan 6, 2023
46e942f
Do big rename to clean up code
Ericson2314 Jan 6, 2023
91617f8
Fix perl bindings
Ericson2314 Jan 6, 2023
2e7be46
Move new `ValidPathInfo` methods to path-info.cc
Ericson2314 Jan 13, 2023
056cc1c
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Jan 14, 2023
b3d9123
Make `ValidPathInfo` have plain `StorePathSet` references like before
Ericson2314 Jan 14, 2023
c67e0cc
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Jan 23, 2023
4540e7b
Don't add `StorePathDescriptor` for now
Ericson2314 Jan 23, 2023
adb3608
Merge branch 'small-storePath-cleanups' into path-info
Ericson2314 Jan 30, 2023
974a983
Shrink diff in two places
Ericson2314 Jan 30, 2023
79b078a
Merge branch 'small-storePath-cleanups' into path-info
Ericson2314 Jan 30, 2023
b6c9875
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Jan 30, 2023
4341473
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Feb 1, 2023
0983a0b
Shrink diff in one place
Ericson2314 Feb 1, 2023
db759b1
Undo style change
Ericson2314 Feb 1, 2023
59d3175
Put back TODO
Ericson2314 Feb 1, 2023
ee9eb83
Remove some designated initializers
Ericson2314 Feb 1, 2023
87ca462
Merge branch 'master' into path-info
Ericson2314 Feb 2, 2023
c36b584
Fix typo in the method name
Ericson2314 Feb 28, 2023
d12f57c
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Feb 28, 2023
123b11f
Clarify store path grammar and improve comment on `makeType`
Ericson2314 Feb 28, 2023
85bb865
Revert "Remove some designated initializers"
Ericson2314 Feb 28, 2023
d381248
No inheritance for `TextInfo` and `FixedOutputInfo`
Ericson2314 Feb 28, 2023
aa99005
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Mar 30, 2023
a6d00a7
Fix warning
Ericson2314 Mar 30, 2023
c51d554
Use "raw pattern" for content address types
Ericson2314 Mar 30, 2023
5d56e2d
Add comparison methods for content addresses
Ericson2314 Apr 1, 2023
fd21f9d
Merge remote-tracking branch 'upstream/master' into path-info
Ericson2314 Apr 8, 2023
537e871
Explain various `.self = false,`
Ericson2314 Apr 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion perl/lib/Nix/Store.xs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,13 @@ SV * makeFixedOutputPath(int recursive, char * algo, char * hash, char * name)
try {
auto h = Hash::parseAny(hash, parseHashType(algo));
auto method = recursive ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat;
auto path = store()->makeFixedOutputPath(method, h, name);
auto path = store()->makeFixedOutputPath(name, FixedOutputInfo {
.hash = {
.method = method,
.hash = h,
},
.references = {},
});
XPUSHs(sv_2mortal(newSVpv(store()->printStorePath(path).c_str(), 0)));
} catch (Error & e) {
croak("%s", e.what());
Expand Down
16 changes: 14 additions & 2 deletions src/libexpr/primops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,13 @@ drvName, Bindings * attrs, Value & v)
auto h = newHashAllowEmpty(*outputHash, parseHashTypeOpt(outputHashAlgo));

auto method = ingestionMethod.value_or(FileIngestionMethod::Flat);
auto outPath = state.store->makeFixedOutputPath(method, h, drvName);
auto outPath = state.store->makeFixedOutputPath(drvName, FixedOutputInfo {
.hash = {
.method = method,
.hash = h,
},
.references = {},
});
drv.env["out"] = state.store->printStorePath(outPath);
drv.outputs.insert_or_assign("out",
DerivationOutput::CAFixed {
Expand Down Expand Up @@ -2103,7 +2109,13 @@ static void addPath(

std::optional<StorePath> expectedStorePath;
if (expectedHash)
expectedStorePath = state.store->makeFixedOutputPath(method, *expectedHash, name);
expectedStorePath = state.store->makeFixedOutputPath(name, FixedOutputInfo {
.hash = {
.method = method,
.hash = *expectedHash,
},
.references = {},
});

if (!expectedHash || !state.store->isValidPath(*expectedStorePath)) {
StorePath dstPath = settings.readOnlyMode
Expand Down
13 changes: 9 additions & 4 deletions src/libexpr/primops/fetchTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,15 @@ static void fetch(EvalState & state, const PosIdx pos, Value * * args, Value & v

// early exit if pinned and already in the store
if (expectedHash && expectedHash->type == htSHA256) {
auto expectedPath =
unpack
? state.store->makeFixedOutputPath(FileIngestionMethod::Recursive, *expectedHash, name, {})
: state.store->makeFixedOutputPath(FileIngestionMethod::Flat, *expectedHash, name, {});
auto expectedPath = state.store->makeFixedOutputPath(
name,
FixedOutputInfo {
.hash = {
.method = unpack ? FileIngestionMethod::Recursive : FileIngestionMethod::Flat,
.hash = *expectedHash,
},
.references = {}
});

if (state.store->isValidPath(expectedPath)) {
state.allowAndSetStorePathString(expectedPath, v);
Expand Down
8 changes: 7 additions & 1 deletion src/libfetchers/fetchers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ StorePath Input::computeStorePath(Store & store) const
auto narHash = getNarHash();
if (!narHash)
throw Error("cannot compute store path for unlocked input '%s'", to_string());
return store.makeFixedOutputPath(FileIngestionMethod::Recursive, *narHash, getName());
return store.makeFixedOutputPath(getName(), FixedOutputInfo {
.hash = {
.method = FileIngestionMethod::Recursive,
.hash = *narHash,
},
.references = {},
});
}

std::string Input::getType() const
Expand Down
16 changes: 10 additions & 6 deletions src/libfetchers/tarball.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,19 @@ DownloadFileResult downloadFile(
dumpString(res.data, sink);
auto hash = hashString(htSHA256, res.data);
ValidPathInfo info {
store->makeFixedOutputPath(FileIngestionMethod::Flat, hash, name),
*store,
name,
FixedOutputInfo {
.hash = {
.method = FileIngestionMethod::Flat,
.hash = hash,
},
.references = {},
},
hashString(htSHA256, sink.s),
};
info.narSize = sink.s.size();
info.ca = FixedOutputHash {
.method = FileIngestionMethod::Flat,
.hash = hash,
};
auto source = StringSource(sink.s);
auto source = StringSource { sink.s };
store->addToStore(info, source, NoRepair, NoCheckSigs);
storePath = std::move(info.path);
}
Expand Down
48 changes: 36 additions & 12 deletions src/libstore/binary-cache-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,22 @@ StorePath BinaryCacheStore::addToStoreFromDump(Source & dump, std::string_view n
unsupported("addToStoreFromDump");
return addToStoreCommon(dump, repair, CheckSigs, [&](HashResult nar) {
ValidPathInfo info {
makeFixedOutputPath(method, nar.first, name, references),
*this,
name,
FixedOutputInfo {
.hash = {
.method = method,
.hash = nar.first,
},
.references = {
.others = references,
// caller is not capable of creating a self-reference, because this is content-addressed without modulus
.self = false,
Comment thread
Ericson2314 marked this conversation as resolved.
},
},
nar.first,
};
info.narSize = nar.second;
info.references = references;
return info;
})->path;
}
Expand Down Expand Up @@ -414,15 +425,22 @@ StorePath BinaryCacheStore::addToStore(
});
return addToStoreCommon(*source, repair, CheckSigs, [&](HashResult nar) {
ValidPathInfo info {
makeFixedOutputPath(method, h, name, references),
*this,
name,
FixedOutputInfo {
.hash = {
.method = method,
.hash = h,
},
.references = {
.others = references,
// caller is not capable of creating a self-reference, because this is content-addressed without modulus
.self = false,
Comment thread
Ericson2314 marked this conversation as resolved.
},
},
nar.first,
};
info.narSize = nar.second;
info.references = references;
info.ca = FixedOutputHash {
.method = method,
.hash = h,
};
return info;
})->path;
}
Expand All @@ -434,7 +452,7 @@ StorePath BinaryCacheStore::addTextToStore(
RepairFlag repair)
{
auto textHash = hashString(htSHA256, s);
auto path = makeTextPath(name, textHash, references);
auto path = makeTextPath(name, TextInfo { { textHash }, references });

if (!repair && isValidPath(path))
return path;
Expand All @@ -443,10 +461,16 @@ StorePath BinaryCacheStore::addTextToStore(
dumpString(s, sink);
StringSource source(sink.s);
return addToStoreCommon(source, repair, CheckSigs, [&](HashResult nar) {
ValidPathInfo info { path, nar.first };
ValidPathInfo info {
*this,
std::string { name },
TextInfo {
{ .hash = textHash },
references,
},
nar.first,
};
info.narSize = nar.second;
info.ca = TextHash { textHash };
info.references = references;
return info;
})->path;
}
Expand Down
56 changes: 24 additions & 32 deletions src/libstore/build/local-derivation-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2395,27 +2395,26 @@ DrvOutputs LocalDerivationGoal::registerOutputs()
}
};

auto rewriteRefs = [&]() -> std::pair<bool, StorePathSet> {
auto rewriteRefs = [&]() -> StoreReferences {
/* 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,
{},
StoreReferences res {
.self = false,
};
for (auto & r : references) {
auto name = r.name();
auto origHash = std::string { r.hashPart() };
if (r == *scratchPath) {
res.first = true;
res.self = true;
} else if (auto outputRewrite = get(outputRewrites, origHash)) {
std::string newRef = *outputRewrite;
newRef += '-';
newRef += name;
res.second.insert(StorePath { newRef });
res.others.insert(StorePath { newRef });
} else {
res.second.insert(r);
res.others.insert(r);
}
}
return res;
Expand Down Expand Up @@ -2448,18 +2447,22 @@ DrvOutputs LocalDerivationGoal::registerOutputs()
break;
}
auto got = caSink.finish().first;
auto refs = rewriteRefs();

auto finalPath = worker.store.makeFixedOutputPath(
outputHash.method,
got,
outputPathName(drv->name, outputName),
refs.second,
refs.first);
if (*scratchPath != finalPath) {
ValidPathInfo newInfo0 {
worker.store,
outputPathName(drv->name, outputName),
FixedOutputInfo {
.hash = {
.method = outputHash.method,
.hash = got,
},
.references = rewriteRefs(),
},
Hash::dummy,
};
if (*scratchPath != newInfo0.path) {
// Also rewrite the output path
auto source = sinkToSource([&](Sink & nextSink) {
RewritingSink rsink2(oldHashPart, std::string(finalPath.hashPart()), nextSink);
RewritingSink rsink2(oldHashPart, std::string(newInfo0.path.hashPart()), nextSink);
dumpPath(actualPath, rsink2);
rsink2.flush();
});
Expand All @@ -2470,19 +2473,8 @@ DrvOutputs LocalDerivationGoal::registerOutputs()
}

HashResult narHashAndSize = hashPath(htSHA256, actualPath);
ValidPathInfo newInfo0 {
finalPath,
narHashAndSize.first,
};

newInfo0.narHash = narHashAndSize.first;
newInfo0.narSize = narHashAndSize.second;
newInfo0.ca = FixedOutputHash {
.method = outputHash.method,
.hash = got,
};
newInfo0.references = refs.second;
if (refs.first)
newInfo0.references.insert(newInfo0.path);

assert(newInfo0.ca);
return newInfo0;
Expand All @@ -2504,8 +2496,8 @@ DrvOutputs LocalDerivationGoal::registerOutputs()
ValidPathInfo newInfo0 { requiredFinalPath, narHashAndSize.first };
newInfo0.narSize = narHashAndSize.second;
auto refs = rewriteRefs();
newInfo0.references = refs.second;
if (refs.first)
newInfo0.references = std::move(refs.others);
if (refs.self)
newInfo0.references.insert(newInfo0.path);
return newInfo0;
},
Expand All @@ -2519,7 +2511,7 @@ DrvOutputs LocalDerivationGoal::registerOutputs()
/* Check wanted hash */
const Hash & wanted = dof.hash.hash;
assert(newInfo0.ca);
auto got = getContentAddressHash(*newInfo0.ca);
auto got = newInfo0.ca->getHash();
if (wanted != got) {
/* Throw an error after registering the path as
valid. */
Expand Down
4 changes: 3 additions & 1 deletion src/libstore/build/substitution-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ void PathSubstitutionGoal::tryNext()
subs.pop_front();

if (ca) {
subPath = sub->makeFixedOutputPathFromCA(storePath.name(), *ca);
subPath = sub->makeFixedOutputPathFromCA(
std::string { storePath.name() },
ContentAddressWithReferences::withoutRefs(*ca));
if (sub->storeDir == worker.store.storeDir)
assert(subPath == storePath);
} else if (sub->storeDir != worker.store.storeDir) {
Expand Down
Loading