From c8bfb11b34e4b8d3cfd714c54e7436c80e4d72ef Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 6 Mar 2006 11:21:15 +0000 Subject: * `nix-env (-i|-u) --dry-run' now shows exactly which missing paths will be built or substituted. --- src/nix-env/main.cc | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/nix-env/main.cc') diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc index 84c89a157ae1..8648e4f0f871 100644 --- a/src/nix-env/main.cc +++ b/src/nix-env/main.cc @@ -2,6 +2,7 @@ #include "names.hh" #include "globals.hh" #include "build.hh" +#include "misc.hh" #include "gc.hh" #include "shared.hh" #include "parser.hh" @@ -383,6 +384,33 @@ static void queryInstSources(EvalState & state, } +static void printMissing(EvalState & state, const DrvInfos & elems) +{ + PathSet targets, willBuild, willSubstitute; + for (DrvInfos::const_iterator i = elems.begin(); i != elems.end(); ++i) { + Path drvPath = i->queryDrvPath(state); + if (drvPath != "") + targets.insert(drvPath); + else + targets.insert(i->queryOutPath(state)); + } + + queryMissing(targets, willBuild, willSubstitute); + + if (!willBuild.empty()) { + printMsg(lvlInfo, format("the following derivations will be built:")); + for (PathSet::iterator i = willBuild.begin(); i != willBuild.end(); ++i) + printMsg(lvlInfo, format(" %1%") % *i); + } + + if (!willSubstitute.empty()) { + printMsg(lvlInfo, format("the following paths will be substituted:")); + for (PathSet::iterator i = willSubstitute.begin(); i != willSubstitute.end(); ++i) + printMsg(lvlInfo, format(" %1%") % *i); + } +} + + static void installDerivations(Globals & globals, const Strings & args, const Path & profile) { @@ -417,7 +445,10 @@ static void installDerivations(Globals & globals, printMsg(lvlInfo, format("installing `%1%'") % i->name); - if (globals.dryRun) return; + if (globals.dryRun) { + printMissing(globals.state, newElems); + return; + } createUserEnv(globals.state, allElems, profile, globals.keepDerivations); @@ -500,7 +531,10 @@ static void upgradeDerivations(Globals & globals, } else newElems.push_back(*i); } - if (globals.dryRun) return; + if (globals.dryRun) { + printMissing(globals.state, newElems); + return; + } createUserEnv(globals.state, newElems, profile, globals.keepDerivations); -- cgit 1.4.1