Documentation ¶
Index ¶
- Constants
- Variables
- func EnsureNixpkgsPrefetched(ctx context.Context, w io.Writer, pkgs []*Package) error
- func FillNarInfoCache(ctx context.Context, packages ...*Package) error
- func IsNix(p *Package, _ int) bool
- func IsRunX(p *Package, _ int) bool
- type Package
- func (p *Package) AllowInsecure() bool
- func (p *Package) CanonicalName() string
- func (p *Package) EnsureUninstallableIsInLockfile() error
- func (p *Package) Equals(other *Package) bool
- func (p *Package) FlakeInputName() string
- func (p *Package) FullPackageAttributePath() (string, error)
- func (p *Package) Hash() string
- func (p *Package) HashFromNixPkgsURL() string
- func (p *Package) InputAddressedPath() (string, error)
- func (p *Package) Installable() (string, error)
- func (p *Package) IsDevboxPackage() bool
- func (p *Package) IsInBinaryCache() (bool, error)
- func (p *Package) IsInstallable() bool
- func (p *Package) IsLegacy() bool
- func (p *Package) IsNix() bool
- func (p *Package) IsRunX() bool
- func (p *Package) LegacyToVersioned() string
- func (p *Package) NormalizedDevboxPackageReference() (string, error)
- func (p *Package) NormalizedPackageAttributePath() (string, error)
- func (p *Package) PackageAttributePath() (string, error)
- func (p *Package) RunXPath() string
- func (p *Package) StoreName() (string, error)
- func (p *Package) URLForFlakeInput() string
- func (p *Package) ValidateExists(ctx context.Context) (bool, error)
- func (p *Package) ValidateInstallsOnSystem() (bool, error)
- func (p *Package) Versioned() string
Constants ¶
const BinaryCache = "https://cache.nixos.org"
BinaryCache is the store from which to fetch this package's binaries. It is used as FromStore in builtins.fetchClosure.
Variables ¶
var ErrCannotBuildPackageOnSystem = errors.New("unable to build for system")
Functions ¶
func EnsureNixpkgsPrefetched ¶
EnsureNixpkgsPrefetched will prefetch flake for the nixpkgs registry for the package. This is an internal method, and should not be called directly.
func FillNarInfoCache ¶
FillNarInfoCache checks the remote binary cache for the narinfo of each package in the list, and caches the result. Callers of IsInBinaryCache may call this function first as a perf-optimization.
Types ¶
type Package ¶
type Package struct { plugins.BuiltIn url.URL // Raw is the devbox package name from the devbox.json config. // Raw has a few forms: // 1. Devbox Packages // a. versioned packages // examples: go@1.20, python@latest // b. any others? // 2. Local // flakes in a relative sub-directory // example: ./local_flake_subdir#myPackage // 3. Github // remote flakes with raw name starting with `Github:` // example: github:nixos/nixpkgs/5233fd2ba76a3accb5aaa999c00509a11fd0793c#hello Raw string // contains filtered or unexported fields }
Package represents a "package" added to the devbox.json config. A unique feature of flakes is that they have well-defined "inputs" and "outputs". This Package will be aggregated into a specific "flake input" (see shellgen.flakeInput).
func PackageFromString ¶
PackageFromString constructs Package from the raw name provided. The raw name corresponds to a devbox package from the devbox.json config.
func PackageFromStrings ¶
PackageFromStrings constructs Package from the list of package names provided. These names correspond to devbox packages from the devbox.json config.
func PackagesFromConfig ¶
func (*Package) AllowInsecure ¶
func (*Package) CanonicalName ¶
CanonicalName returns the name of the package without the version it only applies to devbox packages
func (*Package) EnsureUninstallableIsInLockfile ¶
func (*Package) Equals ¶
Equals compares two Packages. This may be an expensive operation since it may have to normalize a Package's attribute path, which may require a network call.
func (*Package) FlakeInputName ¶
FlakeInputName generates a name for the input that will be used in the generated flake.nix to import this package. This name must be unique in that flake so we attach a hash to (quasi) ensure uniqueness. Input name will be different from raw package name
func (*Package) FullPackageAttributePath ¶
FullPackageAttributePath returns the attribute path for a package. It is not always normalized which means it should not be used to compare packages. During happy paths (devbox packages and nix flakes that contains a fragment) it is much faster than NormalizedPackageAttributePath
func (*Package) HashFromNixPkgsURL ¶
func (*Package) InputAddressedPath ¶
InputAddressedPath is the input-addressed path in /nix/store It is also the key in the BinaryCache for this package
func (*Package) Installable ¶
Installable for this package. Installable is a nix concept defined here: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix.html#installables
func (*Package) IsDevboxPackage ¶
IsDevboxPackage specifies whether this package is a devbox package. Devbox packages have the format `canonicalName@version`and can be resolved by lockfile.Resolve (including runx packages) This also returns true for legacy packages which are just an attribute path. An explicit flake reference is _not_ a devbox package. TODO: Consider renaming to IsResolvable
func (*Package) IsInBinaryCache ¶
IsInBinaryCache returns true if the package is in the binary cache. ALERT: Callers in a perf-sensitive code path should call FillNarInfoCache before calling this function.
func (*Package) IsInstallable ¶
IsInstallable returns whether this package is installable. Not to be confused with the Installable() method which returns the corresponding nix concept.
func (*Package) LegacyToVersioned ¶
func (*Package) NormalizedDevboxPackageReference ¶
func (*Package) NormalizedPackageAttributePath ¶
NormalizedPackageAttributePath returns an attribute path normalized by nix search. This is useful for comparing different attribute paths that may point to the same package. Note, it may be an expensive call.
func (*Package) PackageAttributePath ¶
PackageAttributePath returns the short attribute path for a package which does not include packages/legacyPackages or the system name.
func (*Package) StoreName ¶
StoreName returns the last section of the store path. Example: /nix/store/abc123-foo-1.0.0 -> foo-1.0.0 Warning, this is probably slowish. If you need to call this multiple times, consider caching the result.
func (*Package) URLForFlakeInput ¶
URLForFlakeInput returns the input url to be used in a flake.nix file. This input can be used to import the package.