Skip to content

Commit 076da53

Browse files
authored
devpkg: more FlakeRef and FlakeInstallable docs (#1628)
1 parent 9a28885 commit 076da53

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

internal/devpkg/flakeref.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const (
2424
// For example, the string "nixpkgs" and "./flake" are valid flake references,
2525
// but "nixpkgs#hello" and "./flake#app^bin,dev" are not.
2626
//
27+
// The JSON encoding of FlakeRef corresponds to the exploded attribute set
28+
// form of the flake reference in Nix.
29+
//
2730
// See the [Nix manual] for details on flake references.
2831
//
2932
// [Nix manual]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake
@@ -350,6 +353,8 @@ func isGitHash(s string) bool {
350353
}
351354

352355
func isArchive(path string) bool {
356+
// As documented under the tarball type:
357+
// https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake#types
353358
return strings.HasSuffix(path, ".tar") ||
354359
strings.HasSuffix(path, ".tar.gz") ||
355360
strings.HasSuffix(path, ".tgz") ||
@@ -447,14 +452,30 @@ const (
447452
//
448453
// [Nix manual]: https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix#installables
449454
type FlakeInstallable struct {
450-
Ref FlakeRef
455+
// Ref is the flake reference portion of the installable.
456+
Ref FlakeRef
457+
458+
// AttrPath is an attribute path of the flake, encoded as a URL
459+
// fragment.
451460
AttrPath string
452461

462+
// Outputs is the installable's output spec, which is a comma-separated
463+
// list of package outputs to install. The outputs spec is anything
464+
// after the last caret '^' in an installable. Unlike the
465+
// attribute path, output specs are not URL-encoded.
466+
//
467+
// The special values DefaultOutputs ("") and AllOutputs ("*") specify
468+
// the default set of package outputs and all package outputs,
469+
// respectively.
470+
//
471+
// ParseFlakeInstallable cleans the list of outputs by removing empty
472+
// elements and sorting the results. Lists containing a "*" are
473+
// simplified to a single "*".
453474
Outputs string
454475
}
455476

456-
// ParseFlakeInstallable parses a flake installable. The string s must contain a
457-
// valid flake reference parsable by ParseFlakeRef, optionally followed by an
477+
// ParseFlakeInstallable parses a flake installable. The raw string must contain
478+
// a valid flake reference parsable by ParseFlakeRef, optionally followed by an
458479
// #attrpath and/or an ^output.
459480
func ParseFlakeInstallable(raw string) (FlakeInstallable, error) {
460481
if raw == "" {

0 commit comments

Comments
 (0)