mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
Added backwards compatib. but still something... remains that changes the hashes .... :(
This commit is contained in:
parent
802d7f40bd
commit
09b8b7efbc
4 changed files with 99 additions and 59 deletions
|
|
@ -554,6 +554,8 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
|
|||
drv.env["out"] = outPath;
|
||||
drv.outputs["out"] = DerivationOutput(outPath, outputHashAlgo, outputHash);
|
||||
|
||||
//only add state when we have to to keep compitibilty with the 'old' format.
|
||||
if(enableState){
|
||||
/* Add the state path based on the outPath */
|
||||
string callingUser = "wouterdb"; //TODO: Change into variable
|
||||
string componentHash = printHash(hashDerivationModulo(state, drv)); //hash of the component path
|
||||
|
|
@ -565,6 +567,7 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
|
|||
string createDirsBeforeInstallS = bool2string(createDirsBeforeInstall);
|
||||
|
||||
drv.stateOutputs["state"] = DerivationStateOutput(stateOutPath, outputHashAlgo, outputHash, enableStateS, shareState, syncState, createDirsBeforeInstallS);
|
||||
}
|
||||
|
||||
/* Write the resulting term into the Nix store directory. */
|
||||
Path drvPath = writeDerivation(drv, drvName);
|
||||
|
|
|
|||
|
|
@ -1378,7 +1378,11 @@ void DerivationGoal::startBuilder()
|
|||
|
||||
/* Create the state directory where the component can store it's state files place */
|
||||
//TODO
|
||||
stateDir = createStateDirs(drv.stateOutputDirs, drv.stateOutputs);
|
||||
|
||||
//TODO include addDirsBefore ...
|
||||
//if(enableState){ ...
|
||||
//stateDir = createStateDirs(drv.stateOutputDirs, drv.stateOutputs);
|
||||
//}
|
||||
|
||||
//TODO create the startupscript
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,19 @@ init initDerivationsHelpers
|
|||
#wouter added 2 ATermList
|
||||
|
||||
Derive | ATermList ATermList ATermList ATermList ATermList string string ATermList ATermList | ATerm |
|
||||
|
||||
| string string | ATerm | EnvBinding |
|
||||
| string ATermList | ATerm | DerivationInput |
|
||||
| string string string string | ATerm | DerivationOutput |
|
||||
| string string string string string string string string | ATerm | DerivationStateOutput |
|
||||
| string string string | ATerm | DerivationStateOutputDir |
|
||||
|
||||
#We use DeriveWithOutState to create derivations that dont use state, and thus dont have the stateDerivationStateOutput and DerivationStateOutputDir in their derivation
|
||||
#Ive put this in because eelco requested it, and its easy to stay backwards compatible, but ultimately I thinks that it should be removed to prevent confusion & duplication
|
||||
|
||||
DeriveWithOutState | ATermList ATermList ATermList string string ATermList ATermList | ATerm |
|
||||
| string string | ATerm | EnvBindingWithOutState |
|
||||
| string ATermList | ATerm | DerivationInputWithOutState |
|
||||
| string string string string | ATerm | DerivationOutputWithOutState |
|
||||
|
||||
Closure | ATermList ATermList | ATerm | OldClosure |
|
||||
| string ATermList | ATerm | OldClosureElem |
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "store-api.hh"
|
||||
#include "aterm.hh"
|
||||
#include "globals.hh"
|
||||
#include "util.hh"
|
||||
|
||||
#include "derivations-ast.hh"
|
||||
#include "derivations-ast.cc"
|
||||
|
|
@ -65,10 +66,15 @@ void throwBadDrv(ATerm t)
|
|||
Derivation parseDerivation(ATerm t)
|
||||
{
|
||||
Derivation drv;
|
||||
ATermList outs, stateOuts, stateOutDirs, inDrvs, inSrcs, args, bnds;
|
||||
ATermList outs, inDrvs, inSrcs, args, bnds;
|
||||
ATermList stateOuts = ATempty, stateOutDirs = ATempty;
|
||||
|
||||
ATerm builder, platform;
|
||||
|
||||
if (!matchDerive(t, outs, stateOuts, stateOutDirs, inDrvs, inSrcs, platform, builder, args, bnds))
|
||||
bool withState;
|
||||
if (matchDerive(t, outs, stateOuts, stateOutDirs, inDrvs, inSrcs, platform, builder, args, bnds) ) { withState = true; }
|
||||
else if (matchDeriveWithOutState(t, outs, inDrvs, inSrcs, platform, builder, args, bnds) ) { withState = false; }
|
||||
else
|
||||
throwBadDrv(t);
|
||||
|
||||
for (ATermIterator i(outs); i; ++i) {
|
||||
|
|
@ -83,6 +89,7 @@ Derivation parseDerivation(ATerm t)
|
|||
drv.outputs[aterm2String(id)] = out;
|
||||
}
|
||||
|
||||
if(withState){
|
||||
//parse state part
|
||||
for (ATermIterator i(stateOuts); i; ++i) {
|
||||
ATerm id, statepath, hashAlgo, hash, enabled, shared, synchronization, createDirsBeforeInstall;
|
||||
|
|
@ -99,19 +106,22 @@ Derivation parseDerivation(ATerm t)
|
|||
stateOut.createDirsBeforeInstall = aterm2String(createDirsBeforeInstall);
|
||||
drv.stateOutputs[aterm2String(id)] = stateOut;
|
||||
}
|
||||
}
|
||||
|
||||
if(withState){
|
||||
//parse state dirs part
|
||||
for (ATermIterator i(stateOutDirs); i; ++i) {
|
||||
ATerm id, path, type, interval;
|
||||
if (!matchDerivationStateOutputDir(*i, id, /*path,*/ type, interval))
|
||||
if (!matchDerivationStateOutputDir(*i, id, type, interval))
|
||||
throwBadDrv(t);
|
||||
path = id;
|
||||
path = id; //We prevent duplication since the key is also the path
|
||||
DerivationStateOutputDir stateOutDirs;
|
||||
stateOutDirs.path = aterm2String(path);
|
||||
stateOutDirs.type = aterm2String(type);
|
||||
stateOutDirs.interval = aterm2String(interval);
|
||||
drv.stateOutputDirs[aterm2String(id)] = stateOutDirs;
|
||||
}
|
||||
}
|
||||
|
||||
for (ATermIterator i(inDrvs); i; ++i) {
|
||||
ATerm drvPath;
|
||||
|
|
@ -150,8 +160,7 @@ Derivation parseDerivation(ATerm t)
|
|||
ATerm unparseDerivation(const Derivation & drv)
|
||||
{
|
||||
ATermList outputs = ATempty;
|
||||
for (DerivationOutputs::const_reverse_iterator i = drv.outputs.rbegin();
|
||||
i != drv.outputs.rend(); ++i)
|
||||
for (DerivationOutputs::const_reverse_iterator i = drv.outputs.rbegin(); i != drv.outputs.rend(); ++i)
|
||||
outputs = ATinsert(outputs,
|
||||
makeDerivationOutput(
|
||||
toATerm(i->first),
|
||||
|
|
@ -159,8 +168,14 @@ ATerm unparseDerivation(const Derivation & drv)
|
|||
toATerm(i->second.hashAlgo),
|
||||
toATerm(i->second.hash)));
|
||||
|
||||
//decide if we need to add state to the derivation
|
||||
bool createState = false;
|
||||
|
||||
ATermList stateOutputs = ATempty;
|
||||
for (DerivationStateOutputs::const_reverse_iterator i = drv.stateOutputs.rbegin(); i != drv.stateOutputs.rend(); ++i)
|
||||
for (DerivationStateOutputs::const_reverse_iterator i = drv.stateOutputs.rbegin(); i != drv.stateOutputs.rend(); ++i){
|
||||
if(i->second.enabled == "true"){
|
||||
createState = true;
|
||||
}
|
||||
stateOutputs = ATinsert(stateOutputs,
|
||||
makeDerivationStateOutput(
|
||||
toATerm(i->first),
|
||||
|
|
@ -172,19 +187,18 @@ ATerm unparseDerivation(const Derivation & drv)
|
|||
toATerm(i->second.synchronization),
|
||||
toATerm(i->second.createDirsBeforeInstall)
|
||||
));
|
||||
}
|
||||
|
||||
ATermList stateOutputDirs = ATempty;
|
||||
for (DerivationStateOutputDirs::const_reverse_iterator i = drv.stateOutputDirs.rbegin(); i != drv.stateOutputDirs.rend(); ++i)
|
||||
stateOutputDirs = ATinsert(stateOutputDirs,
|
||||
makeDerivationStateOutputDir(
|
||||
toATerm(i->first),
|
||||
//toATerm(i->second.path),
|
||||
//toATerm(i->second.path), //removed to prevent duplication since the key is also the path
|
||||
toATerm(i->second.type),
|
||||
toATerm(i->second.interval)
|
||||
));
|
||||
|
||||
//toATermList(i->second.dirs)
|
||||
|
||||
|
||||
ATermList inDrvs = ATempty;
|
||||
for (DerivationInputs::const_reverse_iterator i = drv.inputDrvs.rbegin();
|
||||
|
|
@ -207,6 +221,7 @@ ATerm unparseDerivation(const Derivation & drv)
|
|||
toATerm(i->first),
|
||||
toATerm(i->second)));
|
||||
|
||||
if(createState){
|
||||
return makeDerive(
|
||||
outputs,
|
||||
stateOutputs,
|
||||
|
|
@ -218,6 +233,17 @@ ATerm unparseDerivation(const Derivation & drv)
|
|||
args,
|
||||
env);
|
||||
}
|
||||
else{
|
||||
return makeDeriveWithOutState(
|
||||
outputs,
|
||||
inDrvs,
|
||||
toATermList(drv.inputSrcs),
|
||||
toATerm(drv.platform),
|
||||
toATerm(drv.builder),
|
||||
args,
|
||||
env);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool isDerivation(const string & fileName)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue