mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-26 15:56:18 +02:00
Fix "nix ... --all"
When "--all" is used, we should not fill in a default installable.
This commit is contained in:
parent
7dedd3fa24
commit
cef8c169b1
2 changed files with 16 additions and 12 deletions
|
@ -78,7 +78,7 @@ struct InstallablesCommand : virtual Args, StoreCommand
|
||||||
= import ...; bla = import ...; }’. */
|
= import ...; bla = import ...; }’. */
|
||||||
Value * getSourceExpr(EvalState & state);
|
Value * getSourceExpr(EvalState & state);
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Installable>> parseInstallables(ref<Store> store, Strings installables);
|
std::vector<std::shared_ptr<Installable>> parseInstallables(ref<Store> store, Strings ss);
|
||||||
|
|
||||||
PathSet buildInstallables(ref<Store> store, bool dryRun);
|
PathSet buildInstallables(ref<Store> store, bool dryRun);
|
||||||
|
|
||||||
|
@ -86,6 +86,8 @@ struct InstallablesCommand : virtual Args, StoreCommand
|
||||||
|
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
|
||||||
|
virtual bool useDefaultInstallables() { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Strings _installables;
|
Strings _installables;
|
||||||
|
@ -112,6 +114,8 @@ public:
|
||||||
virtual void run(ref<Store> store, Paths storePaths) = 0;
|
virtual void run(ref<Store> store, Paths storePaths) = 0;
|
||||||
|
|
||||||
void run(ref<Store> store) override;
|
void run(ref<Store> store) override;
|
||||||
|
|
||||||
|
bool useDefaultInstallables() override { return !all; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<std::string, ref<Command>> Commands;
|
typedef std::map<std::string, ref<Command>> Commands;
|
||||||
|
|
|
@ -177,21 +177,21 @@ struct InstallableAttrPath : Installable
|
||||||
std::string attrRegex = R"([A-Za-z_][A-Za-z0-9-_+]*)";
|
std::string attrRegex = R"([A-Za-z_][A-Za-z0-9-_+]*)";
|
||||||
static std::regex attrPathRegex(fmt(R"(%1%(\.%1%)*)", attrRegex));
|
static std::regex attrPathRegex(fmt(R"(%1%(\.%1%)*)", attrRegex));
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Installable>> InstallablesCommand::parseInstallables(ref<Store> store, Strings installables)
|
std::vector<std::shared_ptr<Installable>> InstallablesCommand::parseInstallables(ref<Store> store, Strings ss)
|
||||||
{
|
{
|
||||||
std::vector<std::shared_ptr<Installable>> result;
|
std::vector<std::shared_ptr<Installable>> result;
|
||||||
|
|
||||||
if (installables.empty()) {
|
if (ss.empty() && useDefaultInstallables()) {
|
||||||
if (file == "")
|
if (file == "")
|
||||||
file = ".";
|
file = ".";
|
||||||
installables = Strings{""};
|
ss = Strings{""};
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & installable : installables) {
|
for (auto & s : ss) {
|
||||||
|
|
||||||
if (installable.find("/") != std::string::npos) {
|
if (s.find("/") != std::string::npos) {
|
||||||
|
|
||||||
auto path = store->toStorePath(store->followLinksToStore(installable));
|
auto path = store->toStorePath(store->followLinksToStore(s));
|
||||||
|
|
||||||
if (store->isStorePath(path)) {
|
if (store->isStorePath(path)) {
|
||||||
if (isDerivation(path))
|
if (isDerivation(path))
|
||||||
|
@ -201,14 +201,14 @@ std::vector<std::shared_ptr<Installable>> InstallablesCommand::parseInstallables
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (installable.compare(0, 1, "(") == 0)
|
else if (s.compare(0, 1, "(") == 0)
|
||||||
result.push_back(std::make_shared<InstallableExpr>(*this, installable));
|
result.push_back(std::make_shared<InstallableExpr>(*this, s));
|
||||||
|
|
||||||
else if (installable == "" || std::regex_match(installable, attrPathRegex))
|
else if (s == "" || std::regex_match(s, attrPathRegex))
|
||||||
result.push_back(std::make_shared<InstallableAttrPath>(*this, installable));
|
result.push_back(std::make_shared<InstallableAttrPath>(*this, s));
|
||||||
|
|
||||||
else
|
else
|
||||||
throw UsageError("don't know what to do with argument ‘%s’", installable);
|
throw UsageError("don't know what to do with argument ‘%s’", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in a new issue