* Set the default system filter to "*". This ensures that (for

instance) "nix-env -i wine" works on x86_64-linux, even though Wine
  is built on i686-linux.  In the event that there are multiple
  matching derivations, prefer those built for the current system.
This commit is contained in:
Eelco Dolstra 2010-08-04 09:32:42 +00:00
parent 6d6200f37a
commit 315d8fbd75
1 changed files with 13 additions and 7 deletions

View File

@ -247,11 +247,12 @@ static DrvInfos filterBySelector(EvalState & state, const DrvInfos & allElems,
} }
/* If `newestOnly', if a selector matches multiple derivations /* If `newestOnly', if a selector matches multiple derivations
with the same name, pick the one with the highest priority. with the same name, pick the one matching the current
If there are multiple derivations with the same priority, system. If there are still multiple derivations, pick the
pick the one with the highest version. If there are one with the highest priority. If there are still multiple
multiple derivations with the same priority and name and derivations, pick the one with the highest version.
version, then pick the first one. */ Finally, if there are still multiple derivations,
arbitrarily pick the first one. */
if (newestOnly) { if (newestOnly) {
/* Map from package names to derivations. */ /* Map from package names to derivations. */
@ -266,7 +267,12 @@ static DrvInfos filterBySelector(EvalState & state, const DrvInfos & allElems,
Newest::iterator k = newest.find(drvName.name); Newest::iterator k = newest.find(drvName.name);
if (k != newest.end()) { if (k != newest.end()) {
d = comparePriorities(state, j->first, k->second.first); d = j->first.system == k->second.first.system ? 0 :
j->first.system == thisSystem ? 1 :
k->second.first.system == thisSystem ? -1 : 0;
printMsg(lvlError, format("%1% %2% %3% %4%") % j->first.system % k->second.first.system % thisSystem % d);
if (d == 0)
d = comparePriorities(state, j->first, k->second.first);
if (d == 0) if (d == 0)
d = compareVersions(drvName.version, DrvName(k->second.first.name).version); d = compareVersions(drvName.version, DrvName(k->second.first.name).version);
} }
@ -1230,7 +1236,7 @@ void run(Strings args)
globals.instSource.type = srcUnknown; globals.instSource.type = srcUnknown;
globals.instSource.nixExprPath = getDefNixExprPath(); globals.instSource.nixExprPath = getDefNixExprPath();
globals.instSource.systemFilter = thisSystem; globals.instSource.systemFilter = "*";
globals.dryRun = false; globals.dryRun = false;
globals.preserveInstalled = false; globals.preserveInstalled = false;