Documentation
¶
Index ¶
- Constants
- Variables
- func ClearNarInfoCache()
- 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 Output
- type Package
- func PackageFromStringWithDefaults(raw string, locker lock.Locker) *Package
- func PackageFromStringWithOptions(raw string, locker lock.Locker, opts devopt.AddOpts) *Package
- func PackagesFromConfig(packages []configfile.Package, l lock.Locker) []*Package
- func PackagesFromStringsWithOptions(rawNames []string, l lock.Locker, opts devopt.AddOpts) []*Package
- func (p *Package) AreAllOutputsInCache(ctx context.Context, w io.Writer, cacheURI string) (bool, error)
- func (p *Package) CanonicalName() string
- func (p *Package) DocsURL() string
- func (p *Package) EnsureUninstallableIsInLockfile() error
- func (p *Package) Equals(other *Package) bool
- func (p *Package) FlakeInputName() string
- func (p *Package) FlakeInstallable() (flake.Installable, error)
- func (p *Package) FullPackageAttributePath() (string, error)
- func (p *Package) GetOutputNames() ([]string, error)
- func (p *Package) GetOutputsWithCache() ([]Output, error)
- func (p *Package) GetResolvedStorePaths() ([]string, error)
- func (p *Package) GetStorePaths(ctx context.Context, w io.Writer) ([]string, error)
- func (p *Package) HasAllowInsecure() bool
- func (p *Package) Hash() string
- func (p *Package) HashFromNixPkgsURL() string
- func (p *Package) InputAddressedPathForOutput(output string) (string, error)
- func (p *Package) InputAddressedPaths() ([]string, error)
- func (p *Package) InstallableForOutput(output string) (string, error)
- func (p *Package) Installables() ([]string, error)
- func (p *Package) IsInBinaryCache() (bool, error)
- func (p *Package) IsInstallable() bool
- func (p *Package) IsLegacy() bool
- func (p *Package) IsNix() bool
- func (p *Package) IsOutputInBinaryCache(outputName string) (bool, error)
- func (p *Package) IsRunX() bool
- func (p *Package) LegacyToVersioned() string
- func (p *Package) LockfileKey() string
- func (p *Package) NormalizedDevboxPackageReference() (string, error)
- func (p *Package) NormalizedPackageAttributePath() (string, error)
- func (p *Package) PackageAttributePath() (string, error)
- func (p *Package) ResolvedVersion() (string, error)
- func (p *Package) RunXPath() string
- func (p *Package) StoreName() (string, error)
- func (p *Package) String() string
- 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 MissingStorePathsWarning = "Outputs for %s are not in lockfile. To fix this issue and improve performance, please run " +
"`devbox install --tidy-lockfile`\n"
Variables ¶
var ErrCannotBuildPackageOnSystem = errors.New("unable to build for system")
Functions ¶
func ClearNarInfoCache ¶
func ClearNarInfoCache()
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 IsDevboxPackage bool // If package triggers a built-in plugin, setting this to true will disable it. // If package does not trigger plugin, this will have no effect. DisablePlugin bool // 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 // Patch controls if Devbox environments will do additional patching to // address known issues with the package. Patch bool // AllowInsecure are a list of nix packages that are whitelisted to be // installed even if they are marked as insecure. AllowInsecure []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 PackagesFromConfig ¶
func PackagesFromConfig(packages []configfile.Package, l lock.Locker) []*Package
func (*Package) AreAllOutputsInCache ¶
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) FlakeInstallable ¶
func (p *Package) FlakeInstallable() (flake.Installable, error)
FlakeInstallable returns a flake installable. The raw string must contain a valid flake reference parsable by ParseFlakeRef, optionally followed by an #attrpath and/or an ^output.
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) GetOutputNames ¶
GetOutputNames returns the names of the nix package outputs. Outputs can be specified in devbox.json package fields or as part of the flake reference.
func (*Package) GetOutputsWithCache ¶
GetOutputsWithCache return outputs and their cache URIs if the package is in the binary cache. n+1 WARNING: This will make an http request if FillNarInfoCache is not called before. Grep note: this is used in flake template
func (*Package) GetResolvedStorePaths ¶
GetResolvedStorePaths returns the store paths that are resolved (in lockfile)
func (*Package) GetStorePaths ¶
func (*Package) HasAllowInsecure ¶
func (*Package) HashFromNixPkgsURL ¶
func (*Package) InputAddressedPathForOutput ¶
func (*Package) InputAddressedPaths ¶
InputAddressedPaths is the input-addressed path in /nix/store It is also the key in the BinaryCache for this package
func (*Package) InstallableForOutput ¶
func (*Package) Installables ¶
Installables for this package. Installables is a nix concept defined here: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix.html#installables
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) IsOutputInBinaryCache ¶
func (*Package) LegacyToVersioned ¶
func (*Package) LockfileKey ¶
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) ResolvedVersion ¶
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.