Documentation
¶
Index ¶
- Constants
- Variables
- func ResolveNixPathFromFlake(ctx context.Context, flake string) (string, error)
- type CommandError
- type Derivation
- type HighlightStyle
- type HighlightStyleANSI
- type HighlightStyleHTML
- type HighlightedMap
- type Highlights
- type IndexPackagesOpts
- type Opts
- type Package
- type PackageSet
- type PackagesSearcher
- type Path
- type SearchedPackage
- type TopLevelPackages
Constants ¶
const DefaultANSIEscapeColor = "\x1b[31m" // FgRed
DefaultANSIEscapeColor is the default ANSI escape sequence to use for highlighting.
Variables ¶
var DefaultIndexPackageOpts = IndexPackagesOpts{ Nixpkgs: "<nixpkgs>", Parallelism: runtime.GOMAXPROCS(-1), }
DefaultIndexPackageOpts are the default options for IndexPackages.
Functions ¶
func ResolveNixPathFromFlake ¶
ResolveNixPathFromFlake returns the flake-locked Nix store path for the given flake. Using this path, one can directly do `import (path) { }` to evaluate the Nixpkgs instance like using a channel.
Types ¶
type CommandError ¶
type CommandError struct {
// contains filtered or unexported fields
}
CommandError is an error that is returned when a command fails.
func (*CommandError) Error ¶
func (err *CommandError) Error() string
func (*CommandError) Unwrap ¶
func (err *CommandError) Unwrap() error
type Derivation ¶
type Derivation interface {
// contains filtered or unexported methods
}
Derivation is either a package or a package set.
type HighlightStyle ¶
type HighlightStyle interface {
// contains filtered or unexported methods
}
HighlightStyle is a style of highlighting.
type HighlightStyleANSI ¶
type HighlightStyleANSI struct { // ANSIEscape is the ANSI escape sequence to use for highlighting. // It should be a valid ANSI escape sequence with a prefix of "\x1b". // If empty, red is used. ANSIEscape string }
HighlightStyleANSI is a style of highlighting that uses ANSI escape sequences.
func (HighlightStyleANSI) ANSIEscapeWithDefault ¶
func (s HighlightStyleANSI) ANSIEscapeWithDefault() string
type HighlightStyleHTML ¶
type HighlightStyleHTML struct { // Tag is the HTML tag to use for highlighting. // If empty, "mark" is used. Tag string // Attributes is a map of attributes to add to the tag. Attributes map[string]string }
HighlightStyleHTML is a style of highlighting that uses HTML.
func (HighlightStyleHTML) CloseTag ¶
func (s HighlightStyleHTML) CloseTag() string
func (HighlightStyleHTML) OpenTag ¶
func (s HighlightStyleHTML) OpenTag() string
type HighlightedMap ¶
type HighlightedMap map[string]Highlights
HighlightedMap maps an arbitrary value to a list of highlights. When printing, simply check if the value is in the map, and if it is, print the highlights.
type Highlights ¶
type Highlights [][2]int
Highlights is a list of highlights. Each highlight is a pair of start and end indices.
type IndexPackagesOpts ¶
type IndexPackagesOpts struct { // Nixpkgs is the Nixpkgs path to index. Nixpkgs string // Parallelism is the number of parallel workers to use. Parallelism int }
IndexPackagesOpts are options for IndexPackages.
type Opts ¶
type Opts struct { // Highlight is an optional highlighter for this package. // If not nil, it can be used to prehighlight matching terms of all // packages. Highlight HighlightStyle // Regex is whether to use regex matching instead. // If unsupported, it should return an error. Regex bool // Exact is whether to match the package exactly according to the string. // Note that this filter is applied on top of Bluge's, meaning it narrows // down Bluge's results but does not expand them. Exact bool }
Opts are options for searching.
type Package ¶
type Package struct { Name string `json:"name,omitempty"` Version string `json:"version,omitempty"` Description string `json:"description"` LongDescription string `json:"longDescription,omitempty"` Licenses []string `json:"license,omitempty"` // usually SPDX identifiers MainProgram string `json:"mainProgram,omitempty"` Broken bool `json:"broken,omitempty"` Unfree bool `json:"unfree,omitempty"` UnsupportedPlatform bool `json:"unsupportedPlatform,omitempty"` }
Package is a package that is a derivation.
type PackageSet ¶
type PackageSet map[string]Derivation
PackageSet is a package that is a package set.
func (PackageSet) Count ¶
func (s PackageSet) Count() int
Count returns the number of packages in this set.
func (PackageSet) MarshalJSON ¶
func (s PackageSet) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (PackageSet) UnmarshalJSON ¶
func (s PackageSet) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type PackagesSearcher ¶
type PackagesSearcher interface { // SearchPackages returns a channel of packages that match the given query. // The channel is closed when there are no more results or ctx is canceled. SearchPackages(ctx context.Context, query string, opts Opts) (iter.Seq[SearchedPackage], error) }
PackagesSearcher is a searcher for packages.
type Path ¶
type Path []string
Path is a path to a package. It always starts with the channel name.
func FromDotPath ¶
FromDotPath converts a dot-separated path to a Path.
func (Path) Pop ¶
Pop pops the last name off the path. The returned path will not be a reallocated slice.
func (Path) PushInplace ¶
PushInplace is like Append, but it appends to the path in-place. Go may or may not reallocate the slice.
type SearchedPackage ¶
type SearchedPackage struct { // Path is the path to the derivation. Path string `json:"path"` Package // Highlighted is the color-highlighted package, if any. // This is only used if Highlight is set in Opts. Highlighted *SearchedPackage `json:"unhighlighted"` }
SearchedPackage is a package that was searched for.
type TopLevelPackages ¶
type TopLevelPackages struct { PackageSet // Channel is the name of the channel that these packages are from. // For example, "nixpkgs". Channel string `json:"channel"` }
TopLevelPackages is a set of packages that are top-level packages.
func IndexPackages ¶
func IndexPackages(ctx context.Context, opts IndexPackagesOpts) (TopLevelPackages, error)
IndexPackages indexes all packages in the given channel.