From 6b9cd59a41f059bed393f512bf495be09c1d22f6 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 26 Feb 2014 16:32:46 +0100 Subject: [PATCH] nix-store -r: Respect --add-root for non-derivations Fixes #68. Fixes #117. --- src/nix-store/nix-store.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index aef55f5c9..341a4f677 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(path); } }