forked from lix-project/lix
Use "." as the default installable
This makes e.g. "nix build" do something more or less reasonable (namely, build the default package of the flake in the current directory).
This commit is contained in:
parent
4fb594a375
commit
cc51e37ad0
|
@ -3,7 +3,6 @@
|
|||
#include "common-args.hh"
|
||||
#include "shared.hh"
|
||||
#include "store-api.hh"
|
||||
#include "primops/flake.hh"
|
||||
|
||||
using namespace nix;
|
||||
|
||||
|
|
|
@ -108,6 +108,8 @@ struct InstallablesCommand : virtual Args, SourceExprCommand
|
|||
|
||||
void prepare() override;
|
||||
|
||||
virtual bool useDefaultInstallables() { return true; }
|
||||
|
||||
private:
|
||||
|
||||
std::vector<std::string> _installables;
|
||||
|
@ -119,14 +121,14 @@ struct InstallableCommand : virtual Args, SourceExprCommand
|
|||
|
||||
InstallableCommand()
|
||||
{
|
||||
expectArg("installable", &_installable);
|
||||
expectArg("installable", &_installable, true);
|
||||
}
|
||||
|
||||
void prepare() override;
|
||||
|
||||
private:
|
||||
|
||||
std::string _installable;
|
||||
std::string _installable{"."};
|
||||
};
|
||||
|
||||
/* A command that operates on zero or more store paths. */
|
||||
|
@ -146,6 +148,8 @@ public:
|
|||
virtual void run(ref<Store> store, Paths storePaths) = 0;
|
||||
|
||||
void run(ref<Store> store) override;
|
||||
|
||||
bool useDefaultInstallables() override { return !all; }
|
||||
};
|
||||
|
||||
/* A command that operates on exactly one store path. */
|
||||
|
|
|
@ -334,6 +334,10 @@ PathSet toDerivations(ref<Store> store,
|
|||
|
||||
void InstallablesCommand::prepare()
|
||||
{
|
||||
if (_installables.empty() && !file && useDefaultInstallables())
|
||||
// FIXME: commands like "nix install" should not have a
|
||||
// default, probably.
|
||||
_installables.push_back(".");
|
||||
installables = parseInstallables(getStore(), _installables);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue