forked from lix-project/lix
Merge pull request #4284 from tweag/fixed-output-depending-on-ca
Allow fixed-output derivations to depend on (floating) content-addressed ones
This commit is contained in:
commit
e5cf501c77
3 changed files with 34 additions and 5 deletions
|
@ -493,8 +493,8 @@ void DerivationGoal::inputsRealised()
|
||||||
if (useDerivation) {
|
if (useDerivation) {
|
||||||
auto & fullDrv = *dynamic_cast<Derivation *>(drv.get());
|
auto & fullDrv = *dynamic_cast<Derivation *>(drv.get());
|
||||||
|
|
||||||
if ((!fullDrv.inputDrvs.empty() &&
|
if ((!fullDrv.inputDrvs.empty() && derivationIsCA(fullDrv.type()))
|
||||||
fullDrv.type() == DerivationType::CAFloating) || fullDrv.type() == DerivationType::DeferredInputAddressed) {
|
|| fullDrv.type() == DerivationType::DeferredInputAddressed) {
|
||||||
/* We are be able to resolve this derivation based on the
|
/* We are be able to resolve this derivation based on the
|
||||||
now-known results of dependencies. If so, we become a stub goal
|
now-known results of dependencies. If so, we become a stub goal
|
||||||
aliasing that resolved derivation goal */
|
aliasing that resolved derivation goal */
|
||||||
|
@ -3121,6 +3121,20 @@ void DerivationGoal::registerOutputs()
|
||||||
newInfo0.references = refs.second;
|
newInfo0.references = refs.second;
|
||||||
if (refs.first)
|
if (refs.first)
|
||||||
newInfo0.references.insert(newInfo0.path);
|
newInfo0.references.insert(newInfo0.path);
|
||||||
|
if (scratchPath != newInfo0.path) {
|
||||||
|
// Also rewrite the output path
|
||||||
|
auto source = sinkToSource([&](Sink & nextSink) {
|
||||||
|
StringSink sink;
|
||||||
|
dumpPath(actualPath, sink);
|
||||||
|
RewritingSink rsink2(oldHashPart, std::string(newInfo0.path.hashPart()), nextSink);
|
||||||
|
rsink2((unsigned char *) sink.s->data(), sink.s->size());
|
||||||
|
rsink2.flush();
|
||||||
|
});
|
||||||
|
Path tmpPath = actualPath + ".tmp";
|
||||||
|
restorePath(tmpPath, *source);
|
||||||
|
deletePath(actualPath);
|
||||||
|
movePath(tmpPath, actualPath);
|
||||||
|
}
|
||||||
|
|
||||||
assert(newInfo0.ca);
|
assert(newInfo0.ca);
|
||||||
return newInfo0;
|
return newInfo0;
|
||||||
|
|
|
@ -16,14 +16,16 @@ rec {
|
||||||
};
|
};
|
||||||
rootCA = mkDerivation {
|
rootCA = mkDerivation {
|
||||||
name = "rootCA";
|
name = "rootCA";
|
||||||
outputs = [ "out" "dev" ];
|
outputs = [ "out" "dev" "foo"];
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
echo "building a CA derivation"
|
echo "building a CA derivation"
|
||||||
echo "The seed is ${toString seed}"
|
echo "The seed is ${toString seed}"
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
echo ${rootLegacy}/hello > $out/dep
|
echo ${rootLegacy}/hello > $out/dep
|
||||||
# test symlink at root
|
ln -s $out $out/self
|
||||||
|
# test symlinks at root
|
||||||
ln -s $out $dev
|
ln -s $out $dev
|
||||||
|
ln -s $out $foo
|
||||||
'';
|
'';
|
||||||
__contentAddressed = true;
|
__contentAddressed = true;
|
||||||
outputHashMode = "recursive";
|
outputHashMode = "recursive";
|
||||||
|
@ -34,7 +36,8 @@ rec {
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
echo "building a dependent derivation"
|
echo "building a dependent derivation"
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
echo ${rootCA}/hello > $out/dep
|
cat ${rootCA}/self/dep
|
||||||
|
echo ${rootCA}/self/dep > $out/dep
|
||||||
'';
|
'';
|
||||||
__contentAddressed = true;
|
__contentAddressed = true;
|
||||||
outputHashMode = "recursive";
|
outputHashMode = "recursive";
|
||||||
|
@ -60,4 +63,15 @@ rec {
|
||||||
echo ${rootCA}/non-ca-hello > $out/dep
|
echo ${rootCA}/non-ca-hello > $out/dep
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
dependentFixedOutput = mkDerivation {
|
||||||
|
name = "dependent-fixed-output";
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
outputHash = "sha256-QvtAMbUl/uvi+LCObmqOhvNOapHdA2raiI4xG5zI5pA=";
|
||||||
|
buildCommand = ''
|
||||||
|
cat ${dependentCA}/dep
|
||||||
|
echo foo > $out
|
||||||
|
'';
|
||||||
|
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ testCutoff () {
|
||||||
#testDerivation dependentCA
|
#testDerivation dependentCA
|
||||||
testCutoffFor transitivelyDependentCA
|
testCutoffFor transitivelyDependentCA
|
||||||
testCutoffFor dependentNonCA
|
testCutoffFor dependentNonCA
|
||||||
|
testCutoffFor dependentFixedOutput
|
||||||
}
|
}
|
||||||
|
|
||||||
testGC () {
|
testGC () {
|
||||||
|
|
Loading…
Reference in a new issue