From 2bbc4a214ee998816921cefb2d69f30d5f277d12 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 3 Oct 2012 15:35:42 -0400 Subject: [PATCH] =?UTF-8?q?nix-env:=20Support=20=E2=80=98--repair=E2=80=99?= =?UTF-8?q?=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libstore/build.cc | 6 ++++-- src/nix-env/nix-env.cc | 4 +++- src/nix-env/user-env.cc | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index b62991dff0..d05ff75064 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1105,8 +1105,10 @@ void DerivationGoal::repairClosure() if (worker.store.pathContentsGood(*i)) continue; printMsg(lvlError, format("found corrupted or missing path `%1%' in the output closure of `%2%'") % *i % drvPath); Path drvPath2 = outputsToDrv[*i]; - if (drvPath2 == "") throw Error(format("don't know how to repair corrupted or missing path `%1%'") % *i); - addWaitee(worker.makeDerivationGoal(drvPath2, true)); + if (drvPath2 == "") + addWaitee(worker.makeSubstitutionGoal(*i, true)); + else + addWaitee(worker.makeDerivationGoal(drvPath2, true)); } if (waitees.empty()) { diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index dd2fa30481..d9b48e81c9 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -702,7 +702,7 @@ static void opSet(Globals & globals, PathSet paths = singleton(drv.queryDrvPath(globals.state)); printMissing(*store, paths); if (globals.dryRun) return; - store->buildPaths(paths); + store->buildPaths(paths, globals.state.repair); } else { printMissing(*store, singleton(drv.queryOutPath(globals.state))); @@ -1317,6 +1317,8 @@ void run(Strings args) globals.instSource.systemFilter = needArg(i, args, arg); else if (arg == "--prebuilt-only" || arg == "-b") globals.prebuiltOnly = true; + else if (arg == "--repair") + globals.state.repair = true; else { remaining.push_back(arg); if (arg[0] == '-') { diff --git a/src/nix-env/user-env.cc b/src/nix-env/user-env.cc index 510c5ca381..d7de179010 100644 --- a/src/nix-env/user-env.cc +++ b/src/nix-env/user-env.cc @@ -45,7 +45,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems, drvsToBuild.insert(i->queryDrvPath(state)); debug(format("building user environment dependencies")); - store->buildPaths(drvsToBuild); + store->buildPaths(drvsToBuild, state.repair); /* Construct the whole top level derivation. */ PathSet references; @@ -132,7 +132,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems, /* Realise the resulting store expression. */ debug("building user environment"); - store->buildPaths(singleton(topLevelDrv.queryDrvPath(state))); + store->buildPaths(singleton(topLevelDrv.queryDrvPath(state)), state.repair); /* Switch the current user environment to the output path. */ PathLocks lock;