diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-08-04 13:44:46 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2008-08-04 13:44:46 +0000 |
commit | a1d310b6b5c710215265c1cd0d5893248ed50f92 (patch) | |
tree | bf35d52f339ee027fc749bb63cc3d2bbe5a23f49 /src/nix-store/nix-store.cc | |
parent | 42043953c3558f054dc5b9bb3da605a4a3ed6314 (diff) | |
download | guix-a1d310b6b5c710215265c1cd0d5893248ed50f92.tar.gz |
* `nix-store --realise': print what paths will be built/downloaded,
just like nix-env. * `nix-store --realise': --dry-run option.
Diffstat (limited to 'src/nix-store/nix-store.cc')
-rw-r--r-- | src/nix-store/nix-store.cc | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index b59ff27bb3..0030745b46 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); } |