mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 14:36:16 +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"};
|
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 };
|
enum RealiseMode { Build, NoBuild, DryRun };
|
||||||
|
|
|
@ -257,14 +257,16 @@ struct InstallableFlake : InstallableValue
|
||||||
{
|
{
|
||||||
FlakeRef flakeRef;
|
FlakeRef flakeRef;
|
||||||
Strings attrPaths;
|
Strings attrPaths;
|
||||||
bool searchPackages = false;
|
Strings prefixes;
|
||||||
|
|
||||||
InstallableFlake(SourceExprCommand & cmd, FlakeRef && flakeRef, Strings attrPaths)
|
InstallableFlake(SourceExprCommand & cmd, FlakeRef && flakeRef, Strings attrPaths)
|
||||||
: InstallableValue(cmd), flakeRef(flakeRef), attrPaths(std::move(attrPaths))
|
: InstallableValue(cmd), flakeRef(flakeRef), attrPaths(std::move(attrPaths))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
InstallableFlake(SourceExprCommand & cmd, FlakeRef && flakeRef, std::string attrPath)
|
InstallableFlake(SourceExprCommand & cmd, FlakeRef && flakeRef,
|
||||||
: InstallableValue(cmd), flakeRef(flakeRef), attrPaths{attrPath}, searchPackages(true)
|
std::string attrPath, Strings && prefixes)
|
||||||
|
: InstallableValue(cmd), flakeRef(flakeRef), attrPaths{attrPath},
|
||||||
|
prefixes(prefixes)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
std::string what() override { return flakeRef.to_string() + ":" + *attrPaths.begin(); }
|
std::string what() override { return flakeRef.to_string() + ":" + *attrPaths.begin(); }
|
||||||
|
@ -273,15 +275,8 @@ struct InstallableFlake : InstallableValue
|
||||||
{
|
{
|
||||||
std::vector<std::string> res;
|
std::vector<std::string> res;
|
||||||
|
|
||||||
if (searchPackages) {
|
for (auto & prefix : prefixes)
|
||||||
// As a convenience, look for the attribute in
|
res.push_back(prefix + *attrPaths.begin());
|
||||||
// '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 & s : attrPaths)
|
for (auto & s : attrPaths)
|
||||||
res.push_back(s);
|
res.push_back(s);
|
||||||
|
@ -421,7 +416,11 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
|
||||||
else if ((colon = s.rfind(':')) != std::string::npos) {
|
else if ((colon = s.rfind(':')) != std::string::npos) {
|
||||||
auto flakeRef = std::string(s, 0, colon);
|
auto flakeRef = std::string(s, 0, colon);
|
||||||
auto attrPath = std::string(s, colon + 1);
|
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 == ".") {
|
else if (s.find('/') != std::string::npos || s == ".") {
|
||||||
|
@ -437,7 +436,7 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
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"};
|
return {"defaultApp"};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Strings getDefaultFlakeAttrPathPrefixes() override
|
||||||
|
{
|
||||||
|
return {"apps."};
|
||||||
|
}
|
||||||
|
|
||||||
void run(ref<Store> store) override
|
void run(ref<Store> store) override
|
||||||
{
|
{
|
||||||
auto state = getEvalState();
|
auto state = getEvalState();
|
||||||
|
|
Loading…
Reference in a new issue