From 4494f9097f7959b2f7e63decf04a5bd592018836 Mon Sep 17 00:00:00 2001 From: Tom Bereknyei Date: Sat, 19 Aug 2023 17:03:31 -0400 Subject: feat: notation to refer to no attribute search prefix An attrPath prefix of "." indicates no need to try default attrPath prefixes. For example `nixpkgs#legacyPackages.x86_64-linux.ERROR` searches through ``` trying flake output attribute 'packages.x86_64-linux.legacyPackages.x86_64-linux.ERROR' using cached attrset attribute '' trying flake output attribute 'legacyPackages.x86_64-linux.legacyPackages.x86_64-linux.ERROR' using cached attrset attribute 'legacyPackages.x86_64-linux' trying flake output attribute 'legacyPackages.x86_64-linux.ERROR' using cached attrset attribute 'legacyPackages.x86_64-linux' ``` And there is no way to specify that one does not want the automatic search behavior. Now one can specify `nixpkgs#.legacyPackages.x86_64-linux.ERROR` to only refer to the rooted attribute path without any default injection of attribute search path or system. Change-Id: Iac1334e1470137b7ce11dcf845513810230638ec (cherry picked from commit d4aed18883b361133607296fb6cd789c47427a38) --- src/libcmd/installable-flake.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/libcmd/installable-flake.cc') diff --git a/src/libcmd/installable-flake.cc b/src/libcmd/installable-flake.cc index bb75b8ff0..615f70945 100644 --- a/src/libcmd/installable-flake.cc +++ b/src/libcmd/installable-flake.cc @@ -28,6 +28,10 @@ namespace nix { std::vector InstallableFlake::getActualAttrPaths() { std::vector res; + if (attrPaths.size() == 1 && attrPaths.front().starts_with(".")){ + res.push_back(attrPaths.front().substr(1)); + return res; + } for (auto & prefix : prefixes) res.push_back(prefix + *attrPaths.begin()); -- cgit v1.2.3