* Outline of the new scheme for derivate distribution.

This commit is contained in:
Eelco Dolstra 2003-07-09 16:12:40 +00:00
parent 2b95a9dc05
commit 6011bd0da2
4 changed files with 35 additions and 4 deletions

View File

@ -250,6 +250,10 @@ static FState realise(FState fs, StringSet & paths)
/* Register the normal form. */
nf = storeSuccessor(fs, nf, paths);
/* Expand the hash into the target path. */
expandHash(hash, path);
#if 0
/* Perhaps the path already exists and has the right hash? */
if (pathExists(path)) {
@ -267,6 +271,7 @@ static FState realise(FState fs, StringSet & paths)
copyPath(path2, path);
}
#endif
return nf;
}

View File

@ -30,6 +30,21 @@ extern string dbHash2Paths;
*/
extern string dbSuccessors;
/* dbSubstitutes :: Hash -> [Hash]
Each pair $(h, [hs])$ tells Nix that it can realise any of the
fstate expressions referenced by the hashes in $hs$ to obtain a Nix
archive that, when unpacked, will produce a path with hash $h$.
The main purpose of this is for distributed caching of derivates.
One system can compute a derivate with hash $h$ and put it on a
website (as a Nix archive), for instance, and then another system
can register a substitute for that derivate. The substitute in
this case might be an fstate expression that fetches the Nix
archive.
*/
extern string dbSubstitutes;
/* Path names. */

View File

@ -158,6 +158,9 @@ static string queryPathByHashPrefix(Hash hash, const string & prefix)
}
string expandHash(const Hash & hash, const string & outPath = "")
{
string queryPathByHash(Hash hash)
{
return queryPathByHashPrefix(hash, "/");
@ -187,8 +190,8 @@ void addToStore(string srcPath, string & dstPath, Hash & hash)
void deleteFromStore(const string & path)
{
string prefix = nixStore + "/";
if (string(path, 0, prefix.size()) != prefix)
string prefix = + "/";
if (!isInPrefix(path, nixStore))
throw Error(format("path %1% is not in the store") % path);
unregisterPath(path);

View File

@ -13,8 +13,16 @@ void copyPath(string src, string dst);
/* Register a path keyed on its hash. */
Hash registerPath(const string & path, Hash hash = Hash());
/* Query a path (any path) through its hash. */
string queryPathByHash(Hash hash);
/* Return a path whose contents have the given hash. If outPath is
not empty, ensure that such a path is realised in outPath (if
necessary by copying from another location). If prefix is not
empty, only return a path that is an descendent of prefix.
If no path with the given hash is known to exist in the file
system, ...
*/
string expandHash(const Hash & hash, const string & outPath = "",
const string & prefix = "/");
/* Copy a file to the nixStore directory and register it in dbRefs.
Return the hash code of the value. */