* Make the --prebuilt-only' /
-b' option work not just for queries
but installations/upgrades as well. So `nix-env -ub \*' will upgrade only those packages for which a substitute is available (or to be precise, it will upgrade each package to the highest version for which a substitute is available).
This commit is contained in:
parent
0b95603595
commit
bfea7b1f35
3 changed files with 24 additions and 17 deletions
|
@ -92,7 +92,8 @@
|
||||||
output is already in the Nix store or that can be substituted (i.e.,
|
output is already in the Nix store or that can be substituted (i.e.,
|
||||||
downloaded from somewhere). In other words, it shows the packages
|
downloaded from somewhere). In other words, it shows the packages
|
||||||
that can be installed “quickly”, i.e., don’t need to be built from
|
that can be installed “quickly”, i.e., don’t need to be built from
|
||||||
source.</para></listitem>
|
source. TODO: flag is also available in nix-env -i /
|
||||||
|
-u.</para></listitem>
|
||||||
|
|
||||||
|
|
||||||
<listitem><para>TODO: new built-ins
|
<listitem><para>TODO: new built-ins
|
||||||
|
|
|
@ -63,8 +63,6 @@ Query flags:
|
||||||
--out-path: print path of derivation output
|
--out-path: print path of derivation output
|
||||||
--description: print description
|
--description: print description
|
||||||
--meta: print all meta attributes (only with --xml)
|
--meta: print all meta attributes (only with --xml)
|
||||||
--prebuilt-only: only show derivations whose prebuilt binaries are
|
|
||||||
available on this machine or are downloadable
|
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
|
@ -74,3 +72,5 @@ Options:
|
||||||
--keep-failed / -K: keep temporary directories of failed builds
|
--keep-failed / -K: keep temporary directories of failed builds
|
||||||
--preserve-installed: do not replace currently installed versions in `-i'
|
--preserve-installed: do not replace currently installed versions in `-i'
|
||||||
--system-filter SYSTEM: only use derivations for specified platform
|
--system-filter SYSTEM: only use derivations for specified platform
|
||||||
|
--prebuilt-only / -b: only use derivations whose prebuilt binaries are
|
||||||
|
available on this machine or are downloadable
|
||||||
|
|
|
@ -47,8 +47,9 @@ struct InstallSourceInfo
|
||||||
Path nixExprPath; /* for srcNixExprDrvs, srcNixExprs */
|
Path nixExprPath; /* for srcNixExprDrvs, srcNixExprs */
|
||||||
Path profile; /* for srcProfile */
|
Path profile; /* for srcProfile */
|
||||||
string systemFilter; /* for srcNixExprDrvs */
|
string systemFilter; /* for srcNixExprDrvs */
|
||||||
|
bool prebuiltOnly;
|
||||||
ATermMap autoArgs;
|
ATermMap autoArgs;
|
||||||
InstallSourceInfo() : autoArgs() { };
|
InstallSourceInfo() : prebuiltOnly(false) { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,6 +95,8 @@ static bool parseInstallSourceOptions(Globals & globals,
|
||||||
}
|
}
|
||||||
else if (arg == "--attr" || arg == "-A")
|
else if (arg == "--attr" || arg == "-A")
|
||||||
globals.instSource.type = srcAttrPath;
|
globals.instSource.type = srcAttrPath;
|
||||||
|
else if (arg == "--prebuilt-only" || arg == "-b")
|
||||||
|
globals.instSource.prebuiltOnly = true;
|
||||||
else return false;
|
else return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -319,9 +322,16 @@ static int comparePriorities(EvalState & state,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static DrvInfos filterBySelector(EvalState & state,
|
static bool isPrebuilt(EvalState & state, const DrvInfo & elem)
|
||||||
const DrvInfos & allElems,
|
{
|
||||||
const Strings & args, bool newestOnly)
|
return
|
||||||
|
store->isValidPath(elem.queryOutPath(state)) ||
|
||||||
|
store->hasSubstitutes(elem.queryOutPath(state));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static DrvInfos filterBySelector(EvalState & state, const DrvInfos & allElems,
|
||||||
|
const Strings & args, bool newestOnly, bool prebuiltOnly)
|
||||||
{
|
{
|
||||||
DrvNames selectors = drvNamesFromArgs(args);
|
DrvNames selectors = drvNamesFromArgs(args);
|
||||||
|
|
||||||
|
@ -340,7 +350,8 @@ static DrvInfos filterBySelector(EvalState & state,
|
||||||
DrvName drvName(j->name);
|
DrvName drvName(j->name);
|
||||||
if (i->matches(drvName)) {
|
if (i->matches(drvName)) {
|
||||||
i->hits++;
|
i->hits++;
|
||||||
matches.push_back(std::pair<DrvInfo, unsigned int>(*j, n));
|
if (!prebuiltOnly || isPrebuilt(state, *j))
|
||||||
|
matches.push_back(std::pair<DrvInfo, unsigned int>(*j, n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +440,8 @@ static void queryInstSources(EvalState & state,
|
||||||
loadDerivations(state, instSource.nixExprPath,
|
loadDerivations(state, instSource.nixExprPath,
|
||||||
instSource.systemFilter, instSource.autoArgs, "", allElems);
|
instSource.systemFilter, instSource.autoArgs, "", allElems);
|
||||||
|
|
||||||
elems = filterBySelector(state, allElems, args, newestOnly);
|
elems = filterBySelector(state, allElems, args,
|
||||||
|
newestOnly, instSource.prebuiltOnly);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -495,7 +507,7 @@ static void queryInstSources(EvalState & state,
|
||||||
case srcProfile: {
|
case srcProfile: {
|
||||||
elems = filterBySelector(state,
|
elems = filterBySelector(state,
|
||||||
queryInstalled(state, instSource.profile),
|
queryInstalled(state, instSource.profile),
|
||||||
args, newestOnly);
|
args, newestOnly, instSource.prebuiltOnly);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -999,7 +1011,7 @@ static void opQuery(Globals & globals,
|
||||||
|
|
||||||
DrvInfos elems = filterBySelector(globals.state,
|
DrvInfos elems = filterBySelector(globals.state,
|
||||||
source == sInstalled ? installedElems : availElems,
|
source == sInstalled ? installedElems : availElems,
|
||||||
remaining, false);
|
remaining, false, prebuiltOnly);
|
||||||
|
|
||||||
DrvInfos & otherElems(source == sInstalled ? availElems : installedElems);
|
DrvInfos & otherElems(source == sInstalled ? availElems : installedElems);
|
||||||
|
|
||||||
|
@ -1040,12 +1052,6 @@ static void opQuery(Globals & globals,
|
||||||
/* For XML output. */
|
/* For XML output. */
|
||||||
XMLAttrs attrs;
|
XMLAttrs attrs;
|
||||||
|
|
||||||
if (prebuiltOnly) {
|
|
||||||
if (!store->isValidPath(i->queryOutPath(globals.state)) &&
|
|
||||||
!store->hasSubstitutes(i->queryOutPath(globals.state)))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (printStatus) {
|
if (printStatus) {
|
||||||
bool hasSubs = store->hasSubstitutes(i->queryOutPath(globals.state));
|
bool hasSubs = store->hasSubstitutes(i->queryOutPath(globals.state));
|
||||||
bool isInstalled = installed.find(i->queryOutPath(globals.state)) != installed.end();
|
bool isInstalled = installed.find(i->queryOutPath(globals.state)) != installed.end();
|
||||||
|
|
Loading…
Reference in a new issue