devbox icon indicating copy to clipboard operation
devbox copied to clipboard

internal/devconfig: add PackageSpec for parsing package strings

Open gcurtis opened this issue 1 year ago • 0 comments

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.

gcurtis avatar Mar 06 '24 22:03 gcurtis