about summary refs log tree commit diff
path: root/src/nix-store
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-26T15·32+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-02-26T15·32+0100
commit6b9cd59a41f059bed393f512bf495be09c1d22f6 (patch)
treeb3a286c1f2cf837a87db019485f35b967690b8d7 /src/nix-store
parent7f74513b4e5b632b4099702cf4fe2800de7b67f9 (diff)
nix-store -r: Respect --add-root for non-derivations
Fixes #68.
Fixes #117.
Diffstat (limited to 'src/nix-store')
-rw-r--r--src/nix-store/nix-store.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index aef55f5c9beb..341a4f6776f4 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -61,7 +61,7 @@ static Path useDeriver(Path path)
 
 /* Realise the given path.  For a derivation that means build it; for
    other paths it means ensure their validity. */
-static PathSet realisePath(const Path & path, bool build = true)
+static PathSet realisePath(Path path, bool build = true)
 {
     DrvPathWithOutputs p = parseDrvPathWithOutputs(path);
 
@@ -95,6 +95,14 @@ static PathSet realisePath(const Path & path, bool build = true)
     else {
         if (build) store->ensurePath(path);
         else if (!store->isValidPath(path)) throw Error(format("path `%1%' does not exist and cannot be created") % path);
+        if (gcRoot == "")
+            printGCWarning();
+        else {
+            Path rootName = gcRoot;
+            rootNr++;
+            if (rootNr > 1) rootName += "-" + int2String(rootNr);
+            path = addPermRoot(*store, path, rootName, indirectRoot);
+        }
         return singleton<PathSet>(path);
     }
 }