devbox
devbox copied to clipboard
internal/devconfig: add PackageSpec for parsing package strings
Attempt to formalize raw Devbox package strings (hereby called package specs) by introducing a new PackageSpec type.
This commit just adds the new parsing logic, it doesn't integrate it with any other code yet. The PackageSpec type is the result of parsing a raw string with ParsePackageSpec:
type PackageSpec struct {
Name, Version string
Installable flake.Installable
AttrPathInstallable flake.Installable
RunX types.PkgRef
}
func ParsePackageSpec(raw, nixpkgsCommit string) PackageSpec
When a package spec is ambiguous, ParsePackageSpec will populate the PackageSpec fields with all possible interpretations. For example, the spec go could be go@latest, a flake named go, or the attribute path nixpkgs#go. It's up to a resolver to try them in some priority order and pick one.