mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 16:26:18 +02:00
nix app: Search for installable in the 'apps' output
I.e. you can write $ nix app blender-bin:blender_2_80 which is equivalent to $ nix app blender-bin:apps.blender_2_80
This commit is contained in:
parent
d6c4fe55db
commit
2467c98375
3 changed files with 30 additions and 14 deletions
|
@ -102,6 +102,18 @@ struct SourceExprCommand : virtual Args, EvalCommand, MixFlakeOptions
|
|||
{
|
||||
return {"defaultPackage"};
|
||||
}
|
||||
|
||||
virtual Strings getDefaultFlakeAttrPathPrefixes()
|
||||
{
|
||||
return {
|
||||
// As a convenience, look for the attribute in
|
||||
// 'outputs.packages'.
|
||||
"packages.",
|
||||
// As a temporary hack until Nixpkgs is properly converted
|
||||
// to provide a clean 'packages' set, look in 'legacyPackages'.
|
||||
"legacyPackages."
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
enum RealiseMode { Build, NoBuild, DryRun };
|
||||
|
|
|
@ -257,14 +257,16 @@ struct InstallableFlake : InstallableValue
|
|||
{
|
||||
FlakeRef flakeRef;
|
||||
Strings attrPaths;
|
||||
bool searchPackages = false;
|
||||
Strings prefixes;
|
||||
|
||||
InstallableFlake(SourceExprCommand & cmd, FlakeRef && flakeRef, Strings attrPaths)
|
||||
: InstallableValue(cmd), flakeRef(flakeRef), attrPaths(std::move(attrPaths))
|
||||
{ }
|
||||
|
||||
InstallableFlake(SourceExprCommand & cmd, FlakeRef && flakeRef, std::string attrPath)
|
||||
: InstallableValue(cmd), flakeRef(flakeRef), attrPaths{attrPath}, searchPackages(true)
|
||||
InstallableFlake(SourceExprCommand & cmd, FlakeRef && flakeRef,
|
||||
std::string attrPath, Strings && prefixes)
|
||||
: InstallableValue(cmd), flakeRef(flakeRef), attrPaths{attrPath},
|
||||
prefixes(prefixes)
|
||||
{ }
|
||||
|
||||
std::string what() override { return flakeRef.to_string() + ":" + *attrPaths.begin(); }
|
||||
|
@ -273,15 +275,8 @@ struct InstallableFlake : InstallableValue
|
|||
{
|
||||
std::vector<std::string> res;
|
||||
|
||||
if (searchPackages) {
|
||||
// As a convenience, look for the attribute in
|
||||
// 'outputs.packages'.
|
||||
res.push_back("packages." + *attrPaths.begin());
|
||||
|
||||
// As a temporary hack until Nixpkgs is properly converted
|
||||
// to provide a clean 'packages' set, look in 'legacyPackages'.
|
||||
res.push_back("legacyPackages." + *attrPaths.begin());
|
||||
}
|
||||
for (auto & prefix : prefixes)
|
||||
res.push_back(prefix + *attrPaths.begin());
|
||||
|
||||
for (auto & s : attrPaths)
|
||||
res.push_back(s);
|
||||
|
@ -421,7 +416,11 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
|
|||
else if ((colon = s.rfind(':')) != std::string::npos) {
|
||||
auto flakeRef = std::string(s, 0, colon);
|
||||
auto attrPath = std::string(s, colon + 1);
|
||||
result.push_back(std::make_shared<InstallableFlake>(*this, FlakeRef(flakeRef, true), attrPath));
|
||||
result.push_back(std::make_shared<InstallableFlake>(
|
||||
*this,
|
||||
FlakeRef(flakeRef, true),
|
||||
attrPath,
|
||||
getDefaultFlakeAttrPathPrefixes()));
|
||||
}
|
||||
|
||||
else if (s.find('/') != std::string::npos || s == ".") {
|
||||
|
@ -437,7 +436,7 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
|
|||
}
|
||||
|
||||
else
|
||||
result.push_back(std::make_shared<InstallableFlake>(*this, FlakeRef("nixpkgs"), s));
|
||||
throw Error("unsupported argument '%s'", s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -225,6 +225,11 @@ struct CmdApp : InstallableCommand, RunCommon
|
|||
return {"defaultApp"};
|
||||
}
|
||||
|
||||
Strings getDefaultFlakeAttrPathPrefixes() override
|
||||
{
|
||||
return {"apps."};
|
||||
}
|
||||
|
||||
void run(ref<Store> store) override
|
||||
{
|
||||
auto state = getEvalState();
|
||||
|
|
Loading…
Reference in a new issue