diff --git a/mach_nix/data/nixpkgs.py b/mach_nix/data/nixpkgs.py index cb955e6..aa82f49 100644 --- a/mach_nix/data/nixpkgs.py +++ b/mach_nix/data/nixpkgs.py @@ -78,13 +78,17 @@ class NixpkgsIndex(UserDict): if len(same_ver) == 1: return same_ver[0].nix_key elif len(same_ver) == 0: - highest = self.get_highest_ver(remaining_pkgs).nix_key - print(f'Multiple nixpkgs attributes found for {name}-{ver}: {[p.nix_key for p in remaining_pkgs]}' - f"\nPicking '{highest}' as base attribute name.") - return highest + # If there are no versions that match at this precision + # we pick the best version among the version that matched + # at the prior prefix. + break remaining_pkgs = same_ver - # In any case we should have returned by now - raise Exception("Dude... Check yor code!") + # We've either fallen off the loop (in which case the versions match) + # or all remaining packages match the same length version prefix. + highest = self.get_highest_ver(remaining_pkgs).nix_key + print(f'Multiple nixpkgs attributes found for {name}-{ver}: {[p.nix_key for p in remaining_pkgs]}' + f"\nPicking '{highest}' as base attribute name.") + return highest def exists(self, name, ver=None): try: