IsAmbiguous returns true if a package string could be a Devbox package or a flake installable. For example, "nixpkgs" is both a Devbox package and a flake.
(raw string, parsed flake.Installable)
| 24 | // a flake installable. For example, "nixpkgs" is both a Devbox package and a |
| 25 | // flake. |
| 26 | func IsAmbiguous(raw string, parsed flake.Installable) bool { |
| 27 | // Devbox package strings never have a #attr_path in them. |
| 28 | if parsed.AttrPath != "" { |
| 29 | return false |
| 30 | } |
| 31 | |
| 32 | // Indirect installables must have a "flake:" scheme to disambiguate |
| 33 | // them from legacy (unversioned) devbox package strings. |
| 34 | if parsed.Ref.Type == flake.TypeIndirect { |
| 35 | return !strings.HasPrefix(raw, "flake:") |
| 36 | } |
| 37 | |
| 38 | // Path installables must have a "path:" scheme, start with "/" or start |
| 39 | // with "./" to disambiguate them from devbox package strings. |
| 40 | if parsed.Ref.Type == flake.TypePath { |
| 41 | if raw[0] == '.' || raw[0] == '/' { |
| 42 | return false |
| 43 | } |
| 44 | if strings.HasPrefix(raw, "path:") { |
| 45 | return false |
| 46 | } |
| 47 | return true |
| 48 | } |
| 49 | |
| 50 | // All other flakeref types must have a scheme, so we know those can't |
| 51 | // be devbox package strings. |
| 52 | return false |
| 53 | } |
no outgoing calls
no test coverage detected