about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-09T16·12+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-09T16·12+0000
commit6011bd0da24c100f86239ed826fa7b496bbdddf8 (patch)
treea97710dbe6f7cacc871443df24fab0b00fbda5e3 /src
parent2b95a9dc05d0a943859ba92bb301c294473758f1 (diff)
* Outline of the new scheme for derivate distribution.
Diffstat (limited to 'src')
-rw-r--r--src/fstate.cc5
-rw-r--r--src/globals.hh15
-rw-r--r--src/store.cc7
-rw-r--r--src/store.hh12
4 files changed, 35 insertions, 4 deletions
diff --git a/src/fstate.cc b/src/fstate.cc
index 2f0e50fb2d0e..e289ca7b1958 100644
--- a/src/fstate.cc
+++ b/src/fstate.cc
@@ -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;
     }
diff --git a/src/globals.hh b/src/globals.hh
index 2fb9fe7476d3..8d8c63bd7565 100644
--- a/src/globals.hh
+++ b/src/globals.hh
@@ -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. */
 
diff --git a/src/store.cc b/src/store.cc
index 095d20430777..38e059a294b5 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -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);
diff --git a/src/store.hh b/src/store.hh
index a83fa03045a3..f747b7ee3aa8 100644
--- a/src/store.hh
+++ b/src/store.hh
@@ -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. */