From d48c973ece20875391bebde3c167d6e0cc1e666e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 25 Apr 2017 15:18:05 +0200 Subject: [PATCH] Set default installable Thus $ nix build -f foo.nix will build foo.nix. And $ nix build will build default.nix. However, this may not be a good idea because it's kind of inconsistent, given that "nix build foo" will build the "foo" attribute from the default installation source (i.e. the synthesis of $NIX_PATH), rather than ./default.nix. So I may revert this. --- src/nix/installables.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/nix/installables.cc b/src/nix/installables.cc index 45517443c..ff345c45d 100644 --- a/src/nix/installables.cc +++ b/src/nix/installables.cc @@ -181,6 +181,12 @@ std::vector> InstallablesCommand::parseInstallables { std::vector> result; + if (installables.empty()) { + if (file == "") + file = "."; + installables = Strings{""}; + } + for (auto & installable : installables) { if (installable.find("/") != std::string::npos) { @@ -198,7 +204,7 @@ std::vector> InstallablesCommand::parseInstallables else if (installable.compare(0, 1, "(") == 0) result.push_back(std::make_shared(*this, installable)); - else if (std::regex_match(installable, attrPathRegex)) + else if (installable == "" || std::regex_match(installable, attrPathRegex)) result.push_back(std::make_shared(*this, installable)); else