diff --git a/bootstrap.sh b/bootstrap.sh index f007c713b..f1a698385 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,6 +1,6 @@ #! /bin/sh -e mkdir -p config -libtoolize --copy +libtoolize --force --copy aclocal autoheader automake --add-missing --copy diff --git a/doc/Makefile.am b/doc/Makefile.am index e76efafdb..150a20f00 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1 +1 @@ -SUBDIRS = manual +SUBDIRS = diff --git a/install_full.sh b/install_full.sh new file mode 100755 index 000000000..6882d428d --- /dev/null +++ b/install_full.sh @@ -0,0 +1,50 @@ +#! /bin/sh -e + +if [ "$1" = "full" ]; then + nix-env-all-pkgs.sh -i autoconf + nix-env-all-pkgs.sh -i automake + nix-env-all-pkgs.sh -i gnused + nix-env-all-pkgs.sh -i db4 + nix-env-all-pkgs.sh -i aterm + nix-env-all-pkgs.sh -i bzip2 + nix-env-all-pkgs.sh -i flex + nix-env-all-pkgs.sh -i bsdiff + nix-env-all-pkgs.sh -i libtool + nix-env-all-pkgs.sh -i docbook5 + nix-env-all-pkgs.sh -i docbook5-xsl + nix-env-all-pkgs.sh -i bison + nix-env-all-pkgs.sh -i gdb #optional for debugging +fi + +export nixstatepath=/nixstate/nix +export ACLOCAL_PATH=/root/.nix-profile/share/aclocal + +./bootstrap.sh +./configure --with-aterm=$HOME/.nix-profile \ + --with-bzip2=$HOME/.nix-profile \ + --with-bdb=$HOME/.nix-profile \ + --with-docbook-xsl=$HOME/.nix-profile \ + --with-docbook-rng=/root/.nix-profile/xml/rng/docbook \ + --with-docbook-xsl=/root/.nix-profile/xml/xsl/docbook \ + --prefix=$nixstatepath \ + --with-store-dir=/nix/store \ + --localstatedir=/nix/var + +#Options from the nix expr +#--disable-init-state +#--with-store-dir=/nix/store +#--localstatedir=/nix/var +#--with-aterm=/nix/store/pkmzbb613wa8cwngx8jjb5jaic8yhyzs-aterm-2.4.2-fixes +#--with-bdb=/nix/store/4yv4j1cd7i5j3mhs5wpc1kzlz1cj8n82-db4-4.5.20 +#--with-bzip2=/nix/store/dh0mdgkvhv3pwrf8zp58phpzn9rcm49r-bzip2-1.0.3 +#--disable-init-state + + +echo "New state nix version by wouter ..." > doc/manual/NEWS.txt +make +make install + +for i in $nixstatepath/bin/*; do + echo "pathing $i" + patchelf --set-rpath ../lib/nix/:$(patchelf --print-rpath $i) $i +done diff --git a/install_make.sh b/install_make.sh new file mode 100755 index 000000000..97ee176e9 --- /dev/null +++ b/install_make.sh @@ -0,0 +1,11 @@ +#! /bin/sh -e + +make +make install + +#export nixstatepath=/nixstate/nix + +#for i in $nixstatepath/bin/*; do +# echo "pathing $i" +# patchelf --set-rpath ../lib/nix/:$(patchelf --print-rpath $i) $i +#done diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index aca5f5856..7addb0235 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -346,6 +346,13 @@ static Hash hashDerivationModulo(EvalState & state, Derivation drv) } +static Expr prim_mkStatePath2(EvalState & state, const ATermVector & args) +{ + PathSet context; + return makeStr("$statepath", context); +} + + /* Construct (as a unobservable side effect) a Nix derivation expression that performs the derivation described by the argument set. Returns the original set extended with the following @@ -384,6 +391,12 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args) string outputHashAlgo; bool outputHashRecursive = false; + //state vars + bool enableState = false; + string shareState = "none"; + string syncState = "all"; + StringSet dirs; + for (ATermMap::const_iterator i = attrs.begin(); i != attrs.end(); ++i) { string key = aterm2String(i->key); ATerm value; @@ -410,6 +423,12 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args) } } + //state variables + else if(key == "dirs") { } + else if(key == "shareState") { string s = coerceToString(state, value, context, true); shareState = s; } + else if(key == "synchronization") { string s = coerceToString(state, value, context, true); syncState = s; } + else if(key == "enableState") { bool b = evalBool(state, value); enableState = b; } + /* All other attributes are passed to the builder through the environment. */ else { @@ -489,24 +508,25 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args) have an empty value. This ensures that changes in the set of output names do get reflected in the hash. */ drv.env["out"] = ""; - drv.outputs["out"] = - DerivationOutput("", outputHashAlgo, outputHash); + drv.outputs["out"] = DerivationOutput("", outputHashAlgo, outputHash); /* Use the masked derivation expression to compute the output path. */ - Path outPath = makeStorePath("output:out", - hashDerivationModulo(state, drv), drvName); + Path outPath = makeStorePath("output:out", hashDerivationModulo(state, drv), drvName); /* Construct the final derivation store expression. */ drv.env["out"] = outPath; - drv.outputs["out"] = - DerivationOutput(outPath, outputHashAlgo, outputHash); + drv.outputs["out"] = DerivationOutput(outPath, outputHashAlgo, outputHash); + + /* Add the state path based on the outPath */ + //hash h = .... + drv.env["statepath"] = outPath; + drv.stateOutputs["statepath"] = DerivationStateOutput(outPath, outputHashAlgo, outputHash, enableState, shareState, syncState, dirs); /* Write the resulting term into the Nix store directory. */ Path drvPath = writeDerivation(drv, drvName); - printMsg(lvlChatty, format("instantiated `%1%' -> `%2%'") - % drvName % drvPath); + printMsg(lvlChatty, format("instantiated `%1%' -> `%2%'") % drvName % drvPath); /* Optimisation, but required in read-only mode! because in that case we don't actually write store expressions, so we can't @@ -574,8 +594,41 @@ static Expr prim_baseNameOf(EvalState & state, const ATermVector & args) { PathSet context; return makeStr(baseNameOf(coerceToString(state, args[0], context)), context); + } +/* ..... */ + +static Expr prim_mkStatePath(EvalState & state, const ATermVector & args) +{ + PathSet context; + string indentifier = coerceToString(state, args[0], context); + string subdir = coerceToString(state, args[1], context); + string callingUser = "wouterdb"; //TODO: Change into variable + string statePrefix = "/nix/state/"; //TODO: Change into variable + + //calculate state hash + Hash hash = hashString(htSHA256, indentifier + callingUser); + + //make the path + string path = statePrefix + printHash(hash) + "/"; + + if(subdir == "") + { + } + else + { + path = path + subdir; + } + + //PRE BUILD, After DRV Rewrite: + //ensureDir + //system("chown callingUser.root " + path); + + //share state location if nessesary + + return makeStr(path, context); +} /* Return the directory of the given path, i.e., everything before the last slash. Return either a path or a string depending on the type diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index 3456a5f71..74e8c233a 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -65,10 +65,10 @@ void throwBadDrv(ATerm t) Derivation parseDerivation(ATerm t) { Derivation drv; - ATermList outs, inDrvs, inSrcs, args, bnds; + ATermList outs, stateOuts, inDrvs, inSrcs, args, bnds; ATerm builder, platform; - if (!matchDerive(t, outs, inDrvs, inSrcs, platform, builder, args, bnds)) + if (!matchDerive(t, outs, stateOuts, inDrvs, inSrcs, platform, builder, args, bnds)) throwBadDrv(t); for (ATermIterator i(outs); i; ++i) { @@ -129,6 +129,15 @@ ATerm unparseDerivation(const Derivation & drv) toATerm(i->second.hashAlgo), toATerm(i->second.hash))); + ATermList stateOutputs = ATempty; + for (DerivationStateOutputs::const_reverse_iterator i = drv.stateOutputs.rbegin(); i != drv.stateOutputs.rend(); ++i) + stateOutputs = ATinsert(stateOutputs, + makeDerivationOutput( + toATerm(i->first), + toATerm(i->second.statepath), + toATerm(i->second.hashAlgo), + toATerm(i->second.hash))); + ATermList inDrvs = ATempty; for (DerivationInputs::const_reverse_iterator i = drv.inputDrvs.rbegin(); i != drv.inputDrvs.rend(); ++i) @@ -152,6 +161,7 @@ ATerm unparseDerivation(const Derivation & drv) return makeDerive( outputs, + stateOutputs, inDrvs, toATermList(drv.inputSrcs), toATerm(drv.platform), diff --git a/src/libstore/derivations.hh b/src/libstore/derivations.hh index 3aa750962..46b852ad8 100644 --- a/src/libstore/derivations.hh +++ b/src/libstore/derivations.hh @@ -33,17 +33,44 @@ struct DerivationOutput } }; +struct DerivationStateOutput +{ + Path statepath; + string hashAlgo; + string hash; + bool enabled; + string shared; + string synchronization; + StringSet dirs; + DerivationStateOutput() + { + } + DerivationStateOutput(Path statepath, string hashAlgo, string hash, bool enabled, string shared, string synchronization, StringSet dirs) + { + this->statepath = statepath; + this->hashAlgo = hashAlgo; + this->hash = hash; + this->enabled = enabled; + this->shared = shared; + this->synchronization = synchronization; + this->dirs = dirs; + } +}; + + + typedef std::map DerivationOutputs; +typedef std::map DerivationStateOutputs; /* For inputs that are sub-derivations, we specify exactly which output IDs we are interested in. */ typedef std::map DerivationInputs; - typedef std::map StringPairs; struct Derivation { DerivationOutputs outputs; /* keyed on symbolic IDs */ + DerivationStateOutputs stateOutputs; /* */ DerivationInputs inputDrvs; /* inputs that are sub-derivations */ PathSet inputSrcs; /* inputs that are sources */ string platform;