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

Method String

nix/flake/flakeref.go:706–728  ·  view source on GitHub ↗

String encodes the installable as a Nix command line argument. It normalizes the result such that if two installable values are equal, then their strings will also be equal. String always cleans the outputs spec as described by the Outputs field's documentation. The same normalization rules from [R

()

Source from the content-addressed store, hash-verified

704// String always cleans the outputs spec as described by the Outputs field's
705// documentation. The same normalization rules from [Ref.String] still apply.
706func (fi Installable) String() string {
707 str := fi.Ref.String()
708 if str == "" {
709 return ""
710 }
711 if fi.AttrPath != "" {
712 url, err := url.Parse(str)
713 if err != nil {
714 // This should never happen. Even an empty string is a
715 // valid URL.
716 panic("invalid URL from Ref.String: " + str)
717 }
718 url.Fragment = fi.AttrPath
719 str = url.String()
720 }
721 if fi.Outputs != "" {
722 clean := strings.Join(fi.SplitOutputs(), ",")
723 if clean != "" {
724 str += "^" + clean
725 }
726 }
727 return str
728}
729
730// splitOutputSpec cuts a flake installable around the last instance of ^.
731func splitOutputSpec(s string) (before, after string) {

Callers 1

AddMethod · 0.95

Calls 2

SplitOutputsMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected