aboutsummaryrefslogtreecommitdiff
path: root/src/nix-env
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-12-20 13:56:42 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-12-20 13:56:42 +0100
commit7d203faff6d74d839324cd082236381d20444d8e (patch)
treeb77f0e3513d95fadfa50504e82ebe6238ff0b1aa /src/nix-env
parent194e3374b89b8b2dec6296923877304bdb5c6ae2 (diff)
nix-env --set-flag: Barf if a selector doesn't match any installed package
Fixes #184.
Diffstat (limited to 'src/nix-env')
-rw-r--r--src/nix-env/nix-env.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc
index cf74747da..b42fe97eb 100644
--- a/src/nix-env/nix-env.cc
+++ b/src/nix-env/nix-env.cc
@@ -233,6 +233,15 @@ static bool isPrebuilt(EvalState & state, DrvInfo & elem)
}
+static void checkSelectorUse(DrvNames & selectors)
+{
+ /* Check that all selectors have been used. */
+ foreach (DrvNames::iterator, i, selectors)
+ if (i->hits == 0 && i->fullName != "*")
+ throw Error(format("selector `%1%' matches no derivations") % i->fullName);
+}
+
+
static DrvInfos filterBySelector(EvalState & state, const DrvInfos & allElems,
const Strings & args, bool newestOnly)
{
@@ -315,11 +324,7 @@ static DrvInfos filterBySelector(EvalState & state, const DrvInfos & allElems,
}
}
- /* Check that all selectors have been used. */
- foreach (DrvNames::iterator, i, selectors)
- if (i->hits == 0 && i->fullName != "*")
- throw Error(format("selector `%1%' matches no derivations")
- % i->fullName);
+ checkSelectorUse(selectors);
return elems;
}
@@ -673,11 +678,14 @@ static void opSetFlag(Globals & globals,
foreach (DrvNames::iterator, j, selectors)
if (j->matches(drvName)) {
printMsg(lvlInfo, format("setting flag on `%1%'") % i->name);
+ j->hits++;
setMetaFlag(globals.state, *i, flagName, flagValue);
break;
}
}
+ checkSelectorUse(selectors);
+
/* Write the new user environment. */
if (createUserEnv(globals.state, installedElems,
globals.profile, settings.envKeepDerivations, lockToken)) break;