1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-03 02:01:48 +02:00

repl: use installables

This commit is contained in:
Tom Bereknyei 2022-03-11 13:26:08 -05:00
parent 81567a0962
commit 5640b52834
5 changed files with 48 additions and 20 deletions

View file

@ -114,6 +114,7 @@ struct InstallablesCommand : virtual Args, SourceExprCommand
InstallablesCommand();
void prepare() override;
Installables load();
virtual bool useDefaultInstallables() { return true; }
@ -132,7 +133,6 @@ struct InstallableCommand : virtual Args, SourceExprCommand
InstallableCommand(bool supportReadOnlyMode = false);
void prepare() override;
std::shared_ptr<Installable> load();
std::optional<FlakeRef> getFlakeRefForCompletion() override
{

View file

@ -1025,11 +1025,16 @@ InstallablesCommand::InstallablesCommand()
void InstallablesCommand::prepare()
{
installables = load();
}
Installables InstallablesCommand::load() {
Installables installables;
if (_installables.empty() && useDefaultInstallables())
// FIXME: commands like "nix profile install" should not have a
// default, probably.
_installables.push_back(".");
installables = parseInstallables(getStore(), _installables);
return parseInstallables(getStore(), _installables);
}
std::optional<FlakeRef> InstallablesCommand::getFlakeRefForCompletion()
@ -1054,13 +1059,10 @@ InstallableCommand::InstallableCommand(bool supportReadOnlyMode)
}}
});
}
std::shared_ptr<Installable> InstallableCommand::load() {
return parseInstallable(getStore(), _installable);
}
void InstallableCommand::prepare()
{
installable = load();
installable = parseInstallable(getStore(), _installable);
}
}

View file

@ -131,6 +131,7 @@ struct Installable
OperateOn operateOn,
const std::vector<std::shared_ptr<Installable>> & installables);
};
typedef std::vector<std::shared_ptr<Installable>> Installables;
struct InstallableValue : Installable
{