From a1d310b6b5c710215265c1cd0d5893248ed50f92 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 4 Aug 2008 13:44:46 +0000 Subject: * `nix-store --realise': print what paths will be built/downloaded, just like nix-env. * `nix-store --realise': --dry-run option. --- src/nix-store/nix-store.cc | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/nix-store') diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index b59ff27bb..0030745b4 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -77,23 +77,26 @@ static Path realisePath(const Path & path) /* Realise the given paths. */ static void opRealise(Strings opFlags, Strings opArgs) { - if (!opFlags.empty()) throw UsageError("unknown flag"); + bool dryRun = false; + + foreach (Strings::iterator, i, opFlags) + if (*i == "--dry-run") dryRun = true; + else throw UsageError(format("unknown flag `%1%'") % *i); - for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); ++i) + foreach (Strings::iterator, i, opArgs) *i = followLinksToStorePath(*i); - if (opArgs.size() > 1) { - PathSet drvPaths; - for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); ++i) - if (isDerivation(*i)) - drvPaths.insert(*i); - store->buildDerivations(drvPaths); - } + printMissing(PathSet(opArgs.begin(), opArgs.end())); + + if (dryRun) return; + + /* Build all derivations at the same time to exploit parallelism. */ + PathSet drvPaths; + foreach (Strings::iterator, i, opArgs) + if (isDerivation(*i)) drvPaths.insert(*i); + store->buildDerivations(drvPaths); - for (Strings::iterator i = opArgs.begin(); - i != opArgs.end(); ++i) + foreach (Strings::iterator, i,opArgs) cout << format("%1%\n") % realisePath(*i); } -- cgit v1.2.3