1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-26 04:00:59 +01:00

First commit

This commit is contained in:
Wouter den Breejen 2007-05-15 09:26:33 +00:00
parent 1a793c60ce
commit b712f0f019
7 changed files with 164 additions and 13 deletions

View file

@ -1,6 +1,6 @@
#! /bin/sh -e #! /bin/sh -e
mkdir -p config mkdir -p config
libtoolize --copy libtoolize --force --copy
aclocal aclocal
autoheader autoheader
automake --add-missing --copy automake --add-missing --copy

View file

@ -1 +1 @@
SUBDIRS = manual SUBDIRS =

50
install_full.sh Executable file
View file

@ -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

11
install_make.sh Executable file
View file

@ -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

View file

@ -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 /* Construct (as a unobservable side effect) a Nix derivation
expression that performs the derivation described by the argument expression that performs the derivation described by the argument
set. Returns the original set extended with the following set. Returns the original set extended with the following
@ -384,6 +391,12 @@ static Expr prim_derivationStrict(EvalState & state, const ATermVector & args)
string outputHashAlgo; string outputHashAlgo;
bool outputHashRecursive = false; 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) { for (ATermMap::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
string key = aterm2String(i->key); string key = aterm2String(i->key);
ATerm value; 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 /* All other attributes are passed to the builder through
the environment. */ the environment. */
else { 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 have an empty value. This ensures that changes in the set of
output names do get reflected in the hash. */ output names do get reflected in the hash. */
drv.env["out"] = ""; drv.env["out"] = "";
drv.outputs["out"] = drv.outputs["out"] = DerivationOutput("", outputHashAlgo, outputHash);
DerivationOutput("", outputHashAlgo, outputHash);
/* Use the masked derivation expression to compute the output /* Use the masked derivation expression to compute the output
path. */ path. */
Path outPath = makeStorePath("output:out", Path outPath = makeStorePath("output:out", hashDerivationModulo(state, drv), drvName);
hashDerivationModulo(state, drv), drvName);
/* Construct the final derivation store expression. */ /* Construct the final derivation store expression. */
drv.env["out"] = outPath; drv.env["out"] = outPath;
drv.outputs["out"] = drv.outputs["out"] = DerivationOutput(outPath, outputHashAlgo, outputHash);
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. */ /* Write the resulting term into the Nix store directory. */
Path drvPath = writeDerivation(drv, drvName); Path drvPath = writeDerivation(drv, drvName);
printMsg(lvlChatty, format("instantiated `%1%' -> `%2%'") printMsg(lvlChatty, format("instantiated `%1%' -> `%2%'") % drvName % drvPath);
% drvName % drvPath);
/* Optimisation, but required in read-only mode! because in that /* Optimisation, but required in read-only mode! because in that
case we don't actually write store expressions, so we can't 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; PathSet context;
return makeStr(baseNameOf(coerceToString(state, args[0], context)), 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 /* 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 last slash. Return either a path or a string depending on the type

View file

@ -65,10 +65,10 @@ void throwBadDrv(ATerm t)
Derivation parseDerivation(ATerm t) Derivation parseDerivation(ATerm t)
{ {
Derivation drv; Derivation drv;
ATermList outs, inDrvs, inSrcs, args, bnds; ATermList outs, stateOuts, inDrvs, inSrcs, args, bnds;
ATerm builder, platform; 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); throwBadDrv(t);
for (ATermIterator i(outs); i; ++i) { for (ATermIterator i(outs); i; ++i) {
@ -129,6 +129,15 @@ ATerm unparseDerivation(const Derivation & drv)
toATerm(i->second.hashAlgo), toATerm(i->second.hashAlgo),
toATerm(i->second.hash))); 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; ATermList inDrvs = ATempty;
for (DerivationInputs::const_reverse_iterator i = drv.inputDrvs.rbegin(); for (DerivationInputs::const_reverse_iterator i = drv.inputDrvs.rbegin();
i != drv.inputDrvs.rend(); ++i) i != drv.inputDrvs.rend(); ++i)
@ -152,6 +161,7 @@ ATerm unparseDerivation(const Derivation & drv)
return makeDerive( return makeDerive(
outputs, outputs,
stateOutputs,
inDrvs, inDrvs,
toATermList(drv.inputSrcs), toATermList(drv.inputSrcs),
toATerm(drv.platform), toATerm(drv.platform),

View file

@ -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<string, DerivationOutput> DerivationOutputs; typedef std::map<string, DerivationOutput> DerivationOutputs;
typedef std::map<string, DerivationStateOutput> DerivationStateOutputs;
/* For inputs that are sub-derivations, we specify exactly which /* For inputs that are sub-derivations, we specify exactly which
output IDs we are interested in. */ output IDs we are interested in. */
typedef std::map<Path, StringSet> DerivationInputs; typedef std::map<Path, StringSet> DerivationInputs;
typedef std::map<string, string> StringPairs; typedef std::map<string, string> StringPairs;
struct Derivation struct Derivation
{ {
DerivationOutputs outputs; /* keyed on symbolic IDs */ DerivationOutputs outputs; /* keyed on symbolic IDs */
DerivationStateOutputs stateOutputs; /* */
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;