aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-05-06 17:20:23 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-05-06 17:20:23 +0200
commitff394ff206fea222a30d6f68a9d8852170e1ad55 (patch)
tree148e8513e7ab3333b31e96f3c0ff113b596686dc /src/nix
parent80f4b7b6f81bbf01b99b73cb536c323bded45cb3 (diff)
Remove the nixpkgs.<attr> compatibility hack
Since we've changed a lot of things in the 'nix' command (e.g. rename 'nix run') there is not much point in keeping this around.
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/installables.cc62
1 files changed, 24 insertions, 38 deletions
diff --git a/src/nix/installables.cc b/src/nix/installables.cc
index ab938281f..57060e9b1 100644
--- a/src/nix/installables.cc
+++ b/src/nix/installables.cc
@@ -417,10 +417,6 @@ InstallableFlake::getCursor(EvalState & state, bool useEvalCache)
return res;
}
-// FIXME: extend
-std::string attrRegex = R"([A-Za-z_][A-Za-z0-9-_+]*)";
-static std::regex attrPathRegex(fmt(R"(%1%(\.%1%)*)", attrRegex));
-
std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
ref<Store> store, std::vector<std::string> ss)
{
@@ -449,48 +445,38 @@ std::vector<std::shared_ptr<Installable>> SourceExprCommand::parseInstallables(
} else {
for (auto & s : ss) {
- if (hasPrefix(s, "nixpkgs.")) {
- bool static warned;
- warnOnce(warned, "the syntax 'nixpkgs.<attr>' is deprecated; use 'nixpkgs#<attr>' instead");
- result.push_back(std::make_shared<InstallableFlake>(*this,
- FlakeRef::fromAttrs({{"type", "indirect"}, {"id", "nixpkgs"}}),
- Strings{"legacyPackages." + settings.thisSystem.get() + "." + std::string(s, 8)}, Strings{}));
+ std::exception_ptr ex;
+
+ try {
+ auto [flakeRef, fragment] = parseFlakeRefWithFragment(s, absPath("."));
+ result.push_back(std::make_shared<InstallableFlake>(
+ *this, std::move(flakeRef),
+ fragment == "" ? getDefaultFlakeAttrPaths() : Strings{fragment},
+ getDefaultFlakeAttrPathPrefixes()));
+ continue;
+ } catch (...) {
+ ex = std::current_exception();
}
- else {
- std::exception_ptr ex;
-
+ if (s.find('/') != std::string::npos) {
try {
- auto [flakeRef, fragment] = parseFlakeRefWithFragment(s, absPath("."));
- result.push_back(std::make_shared<InstallableFlake>(
- *this, std::move(flakeRef),
- fragment == "" ? getDefaultFlakeAttrPaths() : Strings{fragment},
- getDefaultFlakeAttrPathPrefixes()));
+ result.push_back(std::make_shared<InstallableStorePath>(store, store->printStorePath(store->followLinksToStorePath(s))));
continue;
+ } catch (NotInStore &) {
} catch (...) {
- ex = std::current_exception();
- }
-
- if (s.find('/') != std::string::npos) {
- try {
- result.push_back(std::make_shared<InstallableStorePath>(store, store->printStorePath(store->followLinksToStorePath(s))));
- continue;
- } catch (NotInStore &) {
- } catch (...) {
- if (!ex)
- ex = std::current_exception();
- }
+ if (!ex)
+ ex = std::current_exception();
}
+ }
- std::rethrow_exception(ex);
+ std::rethrow_exception(ex);
- /*
- throw Error(
- pathExists(s)
- ? "path '%s' is not a flake or a store path"
- : "don't know how to handle argument '%s'", s);
- */
- }
+ /*
+ throw Error(
+ pathExists(s)
+ ? "path '%s' is not a flake or a store path"
+ : "don't know how to handle argument '%s'", s);
+ */
}
}