MCPcopy Index your code
hub / github.com/jetify-com/devbox / ParseInstallable

Function ParseInstallable

nix/flake/flakeref.go:647–673  ·  view source on GitHub ↗

ParseInstallable parses a flake installable. The raw string must contain a valid flake reference parsable by [ParseRef], optionally followed by an #attrpath and/or an ^output.

(raw string)

Source from the content-addressed store, hash-verified

645// a valid flake reference parsable by [ParseRef], optionally followed by an
646// #attrpath and/or an ^output.
647func ParseInstallable(raw string) (Installable, error) {
648 if raw == "" {
649 return Installable{}, redact.Errorf("empty flake installable")
650 }
651
652 // The output spec must be parsed and removed first, otherwise it will
653 // be parsed as part of the flake ref's URL fragment.
654 install := Installable{}
655 raw, install.Outputs = splitOutputSpec(raw)
656 install.Outputs = strings.Join(install.SplitOutputs(), ",") // clean the outputs
657
658 // Interpret installables with path-style flake refs as URLs to extract
659 // the attribute path (fragment). This means that path-style flake refs
660 // cannot point to files with a '#' or '?' in their name, since those
661 // would be parsed as the URL fragment or query string. This mimic's
662 // Nix's CLI behavior.
663 if raw[0] == '.' || raw[0] == '/' {
664 raw = "path:" + raw
665 }
666
667 var err error
668 install.Ref, install.AttrPath, err = parseURLRef(raw)
669 if err != nil {
670 return Installable{}, err
671 }
672 return install, nil
673}
674
675// SplitOutputs splits and sorts the comma-separated list of outputs. It skips
676// any empty outputs. If one or more of the outputs is a "*", then the result

Callers 7

FixInstallableArgsFunction · 0.92
newPackageFunction · 0.92
resolveFunction · 0.92
IsFlakeFunction · 0.92
FetchResolvedPackageMethod · 0.92
shortRevFunction · 0.92

Calls 4

SplitOutputsMethod · 0.95
ErrorfFunction · 0.92
splitOutputSpecFunction · 0.85
parseURLRefFunction · 0.85

Tested by 1