devpkg

package
v0.0.0-...-b4a2add Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCannotBuildPackageOnSystem = errors.New("unable to build for system")

Functions

func ClearNarInfoCache

func ClearNarInfoCache()

func EnsureNixpkgsPrefetched

func EnsureNixpkgsPrefetched(ctx context.Context, w io.Writer, pkgs []*Package) error

EnsureNixpkgsPrefetched will prefetch flake for the nixpkgs registry for the package. This is an internal method, and should not be called directly.

func FillNarInfoCache

func FillNarInfoCache(ctx context.Context, packages ...*Package) error

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.

func IsNix

func IsNix(p *Package, _ int) bool

func IsRunX

func IsRunX(p *Package, _ int) bool

Types

type Output

type Output struct {
	Name     string
	CacheURI string
}

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:  [email protected], 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

	// 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 PackageFromStringWithDefaults

func PackageFromStringWithDefaults(raw string, locker lock.Locker) *Package

func PackageFromStringWithOptions

func PackageFromStringWithOptions(raw string, locker lock.Locker, opts devopt.AddOpts) *Package

func PackagesFromConfig

func PackagesFromConfig(packages []configfile.Package, l lock.Locker) []*Package

func PackagesFromStringsWithOptions

func PackagesFromStringsWithOptions(rawNames []string, l lock.Locker, opts devopt.AddOpts) []*Package

func (*Package) AreAllOutputsInCache

func (p *Package) AreAllOutputsInCache(
	ctx context.Context, w io.Writer, cacheURI string,
) (bool, error)

func (*Package) CanonicalName

func (p *Package) CanonicalName() string

CanonicalName returns the name of the package without the version it only applies to devbox packages

func (*Package) DocsURL

func (p *Package) DocsURL() string

func (*Package) EnsureUninstallableIsInLockfile

func (p *Package) EnsureUninstallableIsInLockfile() error

func (*Package) Equals

func (p *Package) Equals(other *Package) bool

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

func (p *Package) FlakeInputName() string

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

func (p *Package) FullPackageAttributePath() (string, error)

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

func (p *Package) GetOutputNames() ([]string, error)

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

func (p *Package) GetOutputsWithCache() ([]Output, error)

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

func (p *Package) GetResolvedStorePaths() ([]string, error)

GetResolvedStorePaths returns the store paths that are resolved (in lockfile)

func (*Package) GetStorePaths

func (p *Package) GetStorePaths(ctx context.Context, w io.Writer) ([]string, error)

func (*Package) HasAllowInsecure

func (p *Package) HasAllowInsecure() bool

func (*Package) Hash

func (p *Package) Hash() string

func (*Package) HashFromNixPkgsURL

func (p *Package) HashFromNixPkgsURL() string

func (*Package) InputAddressedPathForOutput

func (p *Package) InputAddressedPathForOutput(output string) (string, error)

func (*Package) InputAddressedPaths

func (p *Package) InputAddressedPaths() ([]string, error)

InputAddressedPath is the input-addressed path in /nix/store It is also the key in the BinaryCache for this package

func (*Package) InstallableForOutput

func (p *Package) InstallableForOutput(output string) (string, error)

func (*Package) Installables

func (p *Package) Installables() ([]string, error)

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

func (p *Package) IsInBinaryCache() (bool, error)

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

func (p *Package) IsInstallable() bool

IsInstallable returns whether this package is installable. Not to be confused with the Installable() method which returns the corresponding nix concept.

func (*Package) IsLegacy

func (p *Package) IsLegacy() bool

func (*Package) IsNix

func (p *Package) IsNix() bool

func (*Package) IsOutputInBinaryCache

func (p *Package) IsOutputInBinaryCache(outputName string) (bool, error)

func (*Package) IsRunX

func (p *Package) IsRunX() bool

func (*Package) LegacyToVersioned

func (p *Package) LegacyToVersioned() string

func (*Package) LockfileKey

func (p *Package) LockfileKey() string

func (*Package) NormalizedDevboxPackageReference

func (p *Package) NormalizedDevboxPackageReference() (string, error)

func (*Package) NormalizedPackageAttributePath

func (p *Package) NormalizedPackageAttributePath() (string, error)

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

func (p *Package) PackageAttributePath() (string, error)

PackageAttributePath returns the short attribute path for a package which does not include packages/legacyPackages or the system name.

func (*Package) PatchGlibc

func (p *Package) PatchGlibc() bool

func (*Package) RunXPath

func (p *Package) RunXPath() string

func (*Package) StoreName

func (p *Package) StoreName() (string, error)

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) String

func (p *Package) String() string

func (*Package) URLForFlakeInput

func (p *Package) URLForFlakeInput() string

URLForFlakeInput returns the input url to be used in a flake.nix file. This input can be used to import the package.

func (*Package) ValidateExists

func (p *Package) ValidateExists(ctx context.Context) (bool, error)

func (*Package) ValidateInstallsOnSystem

func (p *Package) ValidateInstallsOnSystem() (bool, error)

func (*Package) Versioned

func (p *Package) Versioned() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL