mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
Firefox can now be brought under state control, however, the symlink ~/.mozilla/firefox/ --> /nix/state/...../ can not (yet) be created automatically at build time since ~/ is set to /homeless-shelter/ ...
This commit is contained in:
parent
b6974f2ae6
commit
c0bd494865
11 changed files with 93 additions and 18 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#check if there are enough arguments, if not, exit with an error
|
#check if there are enough arguments, if not, exit with an error
|
||||||
|
|
||||||
debug="echo "; #set to "" for no debugging, set to "echo " to debug the commands
|
debug=""; #set to "" for no debugging, set to "echo " to debug the commands
|
||||||
|
|
||||||
if [ "$#" != 6 ] && [ "$#" != 7 ] ; then
|
if [ "$#" != 6 ] && [ "$#" != 7 ] ; then
|
||||||
echo "Incorrect number of arguments"
|
echo "Incorrect number of arguments"
|
||||||
|
|
@ -34,6 +34,8 @@ if [ "$debug" != "" ] ; then
|
||||||
echo deletesvn: $deletesvn
|
echo deletesvn: $deletesvn
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# TODO: we need a solution for symlinks, svn doesnt support them
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#check if there are enough arguments, if not, exit with an error
|
#check if there are enough arguments, if not, exit with an error
|
||||||
|
|
||||||
debug="echo "; #set to "" for no debugging, set to "echo " to debug the commands
|
debug=""; #set to "" for no debugging, set to "echo " to debug the commands
|
||||||
|
|
||||||
if [ "$#" != 6 ] && [ "$#" != 7 ] ; then
|
if [ "$#" != 6 ] && [ "$#" != 7 ] ; then
|
||||||
echo "Incorrect number of arguments"
|
echo "Incorrect number of arguments"
|
||||||
|
|
|
||||||
|
|
@ -449,7 +449,6 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
|
||||||
drv.args.push_back(s);
|
drv.args.push_back(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add specific state variables
|
//Add specific state variables
|
||||||
else if(key == "stateDirs") {
|
else if(key == "stateDirs") {
|
||||||
|
|
||||||
|
|
@ -508,6 +507,19 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if(key == "solidStateDependencies"){
|
||||||
|
ATermList es;
|
||||||
|
value = evalExpr(state, value);
|
||||||
|
if (!matchList(value, es)) {
|
||||||
|
static bool haveWarned = false;
|
||||||
|
warnOnce(haveWarned, "the `solidStateDependencies' attribute should evaluate to a list");
|
||||||
|
es = flattenList(state, value);
|
||||||
|
}
|
||||||
|
for (ATermIterator i(es); i; ++i) {
|
||||||
|
string s = coerceToString(state, *i, context, true);
|
||||||
|
drv.solidStateDeps.insert(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(key == "shareState") { shareState = coerceToString(state, value, context, true); }
|
else if(key == "shareState") { shareState = coerceToString(state, value, context, true); }
|
||||||
else if(key == "synchronization") { syncState = coerceToString(state, value, context, true); }
|
else if(key == "synchronization") { syncState = coerceToString(state, value, context, true); }
|
||||||
else if(key == "disableState") { disableState = evalBool(state, value); }
|
else if(key == "disableState") { disableState = evalBool(state, value); }
|
||||||
|
|
@ -615,6 +627,13 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
|
||||||
drv.env["out"] = outPath;
|
drv.env["out"] = outPath;
|
||||||
drv.outputs["out"] = DerivationOutput(outPath, outputHashAlgo, outputHash);
|
drv.outputs["out"] = DerivationOutput(outPath, outputHashAlgo, outputHash);
|
||||||
|
|
||||||
|
/* Replace $(statePath) in solidStateDeps */
|
||||||
|
for (StringSet::iterator i = drv.solidStateDeps.begin(); i != drv.solidStateDeps.end(); ++i)
|
||||||
|
if(*i == "$(statePath)" || "$statePath" ){
|
||||||
|
drv.solidStateDeps.erase(*i);
|
||||||
|
drv.solidStateDeps.insert(outPath);
|
||||||
|
}
|
||||||
|
|
||||||
//printMsg(lvlError, format("DerivationOutput %1% %2% %3%") % outPath % outputHashAlgo % outputHash);
|
//printMsg(lvlError, format("DerivationOutput %1% %2% %3%") % outPath % outputHashAlgo % outputHash);
|
||||||
//only add state when we have to to keep compitibilty with the 'old' format.
|
//only add state when we have to to keep compitibilty with the 'old' format.
|
||||||
//We add state when it's enbaled by the keywords, and not excplicitly disabled by the user
|
//We add state when it's enbaled by the keywords, and not excplicitly disabled by the user
|
||||||
|
|
|
||||||
|
|
@ -1703,6 +1703,9 @@ void DerivationGoal::computeClosure()
|
||||||
/* Get rid of all weird permissions. */
|
/* Get rid of all weird permissions. */
|
||||||
canonicalisePathMetaData(path);
|
canonicalisePathMetaData(path);
|
||||||
|
|
||||||
|
/* Just before the very first scanForReferences, we insert the solid state references in its table so its references will show up in the scan*/
|
||||||
|
setSolidStateReferencesTxn(noTxn, path, drv.solidStateDeps);
|
||||||
|
|
||||||
/* For this output path, find the component references to other paths contained in it. */
|
/* For this output path, find the component references to other paths contained in it. */
|
||||||
PathSet references = scanForReferences(path, allPaths);
|
PathSet references = scanForReferences(path, allPaths);
|
||||||
allReferences[path] = references;
|
allReferences[path] = references;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
init initDerivationsHelpers
|
init initDerivationsHelpers
|
||||||
|
|
||||||
#wouter added 2 ATermList
|
Derive | ATermList ATermList ATermList ATermList ATermList ATermList string string ATermList ATermList | ATerm |
|
||||||
|
|
||||||
Derive | ATermList ATermList ATermList ATermList ATermList string string ATermList ATermList | ATerm |
|
|
||||||
| string string | ATerm | EnvBinding |
|
| string string | ATerm | EnvBinding |
|
||||||
| string ATermList | ATerm | DerivationInput |
|
| string ATermList | ATerm | DerivationInput |
|
||||||
| string string string string | ATerm | DerivationOutput |
|
| string string string string | ATerm | DerivationOutput |
|
||||||
|
|
@ -10,7 +8,7 @@ Derive | ATermList ATermList ATermList ATermList ATermList string string ATermLi
|
||||||
| string string string | ATerm | DerivationStateOutputDir |
|
| 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
|
#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 think that it should be removed to prevent confusion & duplication
|
#Ive put this in becuase its easy to stay backwards compatible, but maybe it should be removed somtime to prevent confusion & duplication
|
||||||
#The function will be called matchDerivateWithOutState, but it will match the Derive term to remain backwards compatible
|
#The function will be called matchDerivateWithOutState, but it will match the Derive term to remain backwards compatible
|
||||||
|
|
||||||
Derive | ATermList ATermList ATermList string string ATermList ATermList | ATerm | DeriveWithOutState
|
Derive | ATermList ATermList ATermList string string ATermList ATermList | ATerm | DeriveWithOutState
|
||||||
|
|
|
||||||
|
|
@ -66,13 +66,13 @@ void throwBadDrv(ATerm t)
|
||||||
Derivation parseDerivation(ATerm t)
|
Derivation parseDerivation(ATerm t)
|
||||||
{
|
{
|
||||||
Derivation drv;
|
Derivation drv;
|
||||||
ATermList outs, inDrvs, inSrcs, args, bnds;
|
ATermList outs, solidStateDeps, inDrvs, inSrcs, args, bnds;
|
||||||
ATermList stateOuts = ATempty, stateOutDirs = ATempty;
|
ATermList stateOuts = ATempty, stateOutDirs = ATempty;
|
||||||
|
|
||||||
ATerm builder, platform;
|
ATerm builder, platform;
|
||||||
|
|
||||||
bool withState;
|
bool withState;
|
||||||
if (matchDerive(t, outs, stateOuts, stateOutDirs, inDrvs, inSrcs, platform, builder, args, bnds) ) { withState = true; }
|
if (matchDerive(t, outs, stateOuts, stateOutDirs, solidStateDeps, inDrvs, inSrcs, platform, builder, args, bnds) ) { withState = true; }
|
||||||
else if (matchDeriveWithOutState(t, outs, inDrvs, inSrcs, platform, builder, args, bnds) ) { withState = false; }
|
else if (matchDeriveWithOutState(t, outs, inDrvs, inSrcs, platform, builder, args, bnds) ) { withState = false; }
|
||||||
else
|
else
|
||||||
throwBadDrv(t);
|
throwBadDrv(t);
|
||||||
|
|
@ -89,7 +89,8 @@ Derivation parseDerivation(ATerm t)
|
||||||
drv.outputs[aterm2String(id)] = out;
|
drv.outputs[aterm2String(id)] = out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(withState){
|
if(withState)
|
||||||
|
{
|
||||||
//parse state part
|
//parse state part
|
||||||
for (ATermIterator i(stateOuts); i; ++i) {
|
for (ATermIterator i(stateOuts); i; ++i) {
|
||||||
ATerm id, statepath, componentHash, hashAlgo, hash, stateIdentifier, enabled, shared, synchronization, createDirsBeforeInstall, runtimeStateParamters, username;
|
ATerm id, statepath, componentHash, hashAlgo, hash, stateIdentifier, enabled, shared, synchronization, createDirsBeforeInstall, runtimeStateParamters, username;
|
||||||
|
|
@ -110,9 +111,7 @@ Derivation parseDerivation(ATerm t)
|
||||||
stateOut.username = aterm2String(username);
|
stateOut.username = aterm2String(username);
|
||||||
drv.stateOutputs[aterm2String(id)] = stateOut;
|
drv.stateOutputs[aterm2String(id)] = stateOut;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(withState){
|
|
||||||
//parse state dirs part
|
//parse state dirs part
|
||||||
for (ATermIterator i(stateOutDirs); i; ++i) {
|
for (ATermIterator i(stateOutDirs); i; ++i) {
|
||||||
ATerm id, path, type, interval;
|
ATerm id, path, type, interval;
|
||||||
|
|
@ -125,6 +124,13 @@ Derivation parseDerivation(ATerm t)
|
||||||
stateOutDirs.interval = aterm2String(interval);
|
stateOutDirs.interval = aterm2String(interval);
|
||||||
drv.stateOutputDirs[aterm2String(id)] = stateOutDirs;
|
drv.stateOutputDirs[aterm2String(id)] = stateOutDirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//parse solid state dependencies
|
||||||
|
for (ATermIterator i(solidStateDeps); i; ++i) {
|
||||||
|
if (ATgetType(*i) != AT_APPL)
|
||||||
|
throw badTerm("string expected", *i);
|
||||||
|
drv.solidStateDeps.insert(aterm2String(*i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ATermIterator i(inDrvs); i; ++i) {
|
for (ATermIterator i(inDrvs); i; ++i) {
|
||||||
|
|
@ -202,11 +208,14 @@ ATerm unparseDerivation(const Derivation & drv)
|
||||||
stateOutputDirs = ATinsert(stateOutputDirs,
|
stateOutputDirs = ATinsert(stateOutputDirs,
|
||||||
makeDerivationStateOutputDir(
|
makeDerivationStateOutputDir(
|
||||||
toATerm(i->first),
|
toATerm(i->first),
|
||||||
//toATerm(i->second.path), //removed to prevent duplication since the key is also the path
|
|
||||||
toATerm(i->second.type),
|
toATerm(i->second.type),
|
||||||
toATerm(i->second.interval)
|
toATerm(i->second.interval)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
ATermList solidStateDeps = ATempty;
|
||||||
|
for (StringSet::const_reverse_iterator i = drv.solidStateDeps.rbegin();
|
||||||
|
i != drv.solidStateDeps.rend(); ++i)
|
||||||
|
solidStateDeps = ATinsert(solidStateDeps, toATerm(*i));
|
||||||
|
|
||||||
ATermList inDrvs = ATempty;
|
ATermList inDrvs = ATempty;
|
||||||
for (DerivationInputs::const_reverse_iterator i = drv.inputDrvs.rbegin();
|
for (DerivationInputs::const_reverse_iterator i = drv.inputDrvs.rbegin();
|
||||||
|
|
@ -234,6 +243,7 @@ ATerm unparseDerivation(const Derivation & drv)
|
||||||
outputs,
|
outputs,
|
||||||
stateOutputs,
|
stateOutputs,
|
||||||
stateOutputDirs,
|
stateOutputDirs,
|
||||||
|
solidStateDeps,
|
||||||
inDrvs,
|
inDrvs,
|
||||||
toATermList(drv.inputSrcs),
|
toATermList(drv.inputSrcs),
|
||||||
toATerm(drv.platform),
|
toATerm(drv.platform),
|
||||||
|
|
|
||||||
|
|
@ -158,8 +158,9 @@ typedef std::map<string, string> StringPairs;
|
||||||
struct Derivation
|
struct Derivation
|
||||||
{
|
{
|
||||||
DerivationOutputs outputs; /* keyed on symbolic IDs */
|
DerivationOutputs outputs; /* keyed on symbolic IDs */
|
||||||
DerivationStateOutputs stateOutputs; /* */
|
DerivationStateOutputs stateOutputs; /* TODO */
|
||||||
DerivationStateOutputDirs stateOutputDirs; /* */
|
DerivationStateOutputDirs stateOutputDirs; /* TODO */
|
||||||
|
StringSet solidStateDeps; /* TODO */
|
||||||
DerivationInputs inputDrvs; /* inputs that are sub-derivations */
|
DerivationInputs inputDrvs; /* inputs that are sub-derivations */
|
||||||
PathSet inputSrcs; /* inputs that are sources */
|
PathSet inputSrcs; /* inputs that are sources */
|
||||||
string platform;
|
string platform;
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,12 @@ static TableId dbComponentStateReferrers = 0;
|
||||||
static TableId dbStateComponentReferrers = 0;
|
static TableId dbStateComponentReferrers = 0;
|
||||||
static TableId dbStateStateReferrers = 0;
|
static TableId dbStateStateReferrers = 0;
|
||||||
|
|
||||||
|
/* dbSolidStateReferences :: Path -> [Path]
|
||||||
|
*
|
||||||
|
* TODO Comment!!!!!!!!!!!!!!!!!!!!!!!1
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static TableId dbSolidStateReferences = 0;
|
||||||
|
|
||||||
/* dbSubstitutes :: Path -> [[Path]]
|
/* dbSubstitutes :: Path -> [[Path]]
|
||||||
|
|
||||||
|
|
@ -190,16 +196,18 @@ LocalStore::LocalStore(bool reserveSpace)
|
||||||
|
|
||||||
dbStateInfo = nixDB.openTable("stateinfo");
|
dbStateInfo = nixDB.openTable("stateinfo");
|
||||||
dbStateCounters = nixDB.openTable("statecounters");
|
dbStateCounters = nixDB.openTable("statecounters");
|
||||||
dbComponentComponentReferences = nixDB.openTable("references");
|
dbComponentComponentReferences = nixDB.openTable("references"); /* c_c */
|
||||||
dbComponentStateReferences = nixDB.openTable("references_c_s");
|
dbComponentStateReferences = nixDB.openTable("references_c_s");
|
||||||
dbStateComponentReferences = nixDB.openTable("references_s_c");
|
dbStateComponentReferences = nixDB.openTable("references_s_c");
|
||||||
dbStateStateReferences = nixDB.openTable("references_s_s");
|
dbStateStateReferences = nixDB.openTable("references_s_s");
|
||||||
dbComponentComponentReferrers = nixDB.openTable("referrers", true); /* must be sorted */
|
dbComponentComponentReferrers = nixDB.openTable("referrers", true); /* must be sorted */ /* c_c */
|
||||||
dbComponentStateReferrers = nixDB.openTable("referrers_c_s", true);
|
dbComponentStateReferrers = nixDB.openTable("referrers_c_s", true);
|
||||||
dbStateComponentReferrers = nixDB.openTable("referrers_s_c", true);
|
dbStateComponentReferrers = nixDB.openTable("referrers_s_c", true);
|
||||||
dbStateStateReferrers = nixDB.openTable("referrers_s_s", true);
|
dbStateStateReferrers = nixDB.openTable("referrers_s_s", true);
|
||||||
dbStateRevisions = nixDB.openTable("staterevisions");
|
dbStateRevisions = nixDB.openTable("staterevisions");
|
||||||
|
|
||||||
|
dbSolidStateReferences = nixDB.openTable("references_solid_c_s"); /* The contents of this table is included in references_c_s */
|
||||||
|
|
||||||
int curSchema = 0;
|
int curSchema = 0;
|
||||||
Path schemaFN = nixDBPath + "/schema";
|
Path schemaFN = nixDBPath + "/schema";
|
||||||
if (pathExists(schemaFN)) {
|
if (pathExists(schemaFN)) {
|
||||||
|
|
@ -1709,6 +1717,20 @@ void LocalStore::updateRevisionsRecursively(const Path & statePath)
|
||||||
nix::updateRevisionsRecursivelyTxn(noTxn, statePath);
|
nix::updateRevisionsRecursivelyTxn(noTxn, statePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setSolidStateReferencesTxn(const Transaction & txn, const Path & statePath, const PathSet & paths)
|
||||||
|
{
|
||||||
|
Strings ss = Strings(paths.begin(), paths.end());
|
||||||
|
nixDB.setStrings(txn, dbSolidStateReferences, statePath, ss);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool querySolidStateReferencesTxn(const Transaction & txn, const Path & statePath, PathSet & paths)
|
||||||
|
{
|
||||||
|
Strings ss;
|
||||||
|
bool notempty = nixDB.queryStrings(txn, dbSolidStateReferences, statePath, ss);
|
||||||
|
paths.insert(ss.begin(), ss.end());
|
||||||
|
return notempty;
|
||||||
|
}
|
||||||
|
|
||||||
/* Upgrade from schema 1 (Nix <= 0.7) to schema 2 (Nix >= 0.8). */
|
/* Upgrade from schema 1 (Nix <= 0.7) to schema 2 (Nix >= 0.8). */
|
||||||
static void upgradeStore07()
|
static void upgradeStore07()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,9 @@ void setStateRevisionsTxn(const Transaction & txn, const Path & statePath, const
|
||||||
bool isValidPathTxn(const Transaction & txn, const Path & path);
|
bool isValidPathTxn(const Transaction & txn, const Path & path);
|
||||||
bool isValidStatePathTxn(const Transaction & txn, const Path & path);
|
bool isValidStatePathTxn(const Transaction & txn, const Path & path);
|
||||||
|
|
||||||
|
void setSolidStateReferencesTxn(const Transaction & txn, const Path & statePath, const PathSet & paths);
|
||||||
|
bool querySolidStateReferencesTxn(const Transaction & txn, const Path & statePath, PathSet & paths);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "references.hh"
|
#include "references.hh"
|
||||||
#include "hash.hh"
|
#include "hash.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
#include "local-store.hh"
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
@ -119,6 +120,11 @@ void checkPath(const string & path,
|
||||||
|
|
||||||
|
|
||||||
PathSet scanForReferences(const string & path, const PathSet & paths)
|
PathSet scanForReferences(const string & path, const PathSet & paths)
|
||||||
|
{
|
||||||
|
return scanForReferencesTxn(noTxn, path, paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
PathSet scanForReferencesTxn(const Transaction & txn, const Path & path, const PathSet & paths)
|
||||||
{
|
{
|
||||||
std::map<string, Path> backMap;
|
std::map<string, Path> backMap;
|
||||||
StringSet ids;
|
StringSet ids;
|
||||||
|
|
@ -150,6 +156,14 @@ PathSet scanForReferences(const string & path, const PathSet & paths)
|
||||||
found.insert(j->second);
|
found.insert(j->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get the solid state dependencies, and also insert them
|
||||||
|
PathSet solidStateDeps;
|
||||||
|
querySolidStateReferencesTxn(txn, path, solidStateDeps);
|
||||||
|
found.insert(solidStateDeps.begin(), solidStateDeps.end());
|
||||||
|
|
||||||
|
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! we only scan the paths, if we scan for state references, this STORE path will show up !!!!!!!!!!!!!!
|
||||||
|
//TODO Create a scanForReferencesState() funtion wrapper !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,14 @@
|
||||||
#define __REFERENCES_H
|
#define __REFERENCES_H
|
||||||
|
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
|
#include "db.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
PathSet scanForReferences(const Path & path, const PathSet & refs);
|
PathSet scanForReferences(const Path & path, const PathSet & refs);
|
||||||
|
|
||||||
|
PathSet scanForReferencesTxn(const Transaction & txn, const Path & path, const PathSet & refs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !__REFERENCES_H */
|
#endif /* !__REFERENCES_H */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue