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
()
| 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. |
| 706 | func (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 ^. |
| 731 | func splitOutputSpec(s string) (before, after string) { |
no test coverage detected