lock

package
v0.0.0-...-b62b346 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLegacyPackage

func IsLegacyPackage(pkg string) bool

This probably belongs in input.go but can't add it there because it will create a circular dependency. We could move Input into own package.

func ResolveRunXPackage

func ResolveRunXPackage(ctx context.Context, pkg string) (types.PkgRef, error)

func SetIgnoreShellMismatch

func SetIgnoreShellMismatch(ignore bool)

SetIgnoreShellMismatch is used to disable the shell comparison when checking if the state is up to date. This is useful when we don't load shellrc (e.g. running)

func UpdateAndSaveStateHashFile

func UpdateAndSaveStateHashFile(args UpdateStateHashFileArgs) error

Types

type File

type File struct {
	LockFileVersion string `json:"lockfile_version"`

	// Packages is keyed by "canonicalName@version"
	Packages map[string]*Package `json:"packages"`
	// contains filtered or unexported fields
}

Lightly inspired by package-lock.json

func GetFile

func GetFile(project devboxProject) (*File, error)

func (*File) Add

func (f *File) Add(pkgs ...string) error

func (*File) FetchResolvedPackage

func (f *File) FetchResolvedPackage(pkg string) (*Package, error)

FetchResolvedPackage fetches a resolution but does not write it to the lock struct. This allows testing new versions of packages without writing to the lock. This is useful to avoid changing nixpkgs commit hashes when version has not changed. This can happen when doing `devbox update` and search has a newer hash than the lock file but same version. In that case we don't want to update because it would be slow and wasteful.

func (*File) Get

func (f *File) Get(pkg string) *Package

func (*File) HasAllowInsecurePackages

func (f *File) HasAllowInsecurePackages() bool

func (*File) IsUpToDateAndInstalled

func (f *File) IsUpToDateAndInstalled(isFish bool) (bool, error)

IsUpToDateAndInstalled returns true if the lockfile is up to date and the local hashes match, which generally indicates all packages are correctly installed and print-dev-env has been computed and cached.

func (*File) LegacyNixpkgsPath

func (f *File) LegacyNixpkgsPath(pkg string) string

func (*File) Remove

func (f *File) Remove(pkgs ...string) error

func (*File) Resolve

func (f *File) Resolve(pkg string) (*Package, error)

Resolve updates the in memory copy for performance but does not write to disk This avoids writing values that may need to be removed in case of error.

func (*File) Save

func (f *File) Save() error

TODO: Consider a design change to have the File struct match disk to make this system easier to reason about, and have isDirty() compare the in-memory struct to the on-disk struct.

Proposal: 1. Have an OutputsRaw field and a method called Outputs() to access it. Outputs() will check if OutputsRaw is zero-value and fills it in from StorePath. 2. Then, in Save(), we can check if OutputsRaw is zero and fill it in prior to writing to disk.

func (*File) SetOutputsForPackage

func (f *File) SetOutputsForPackage(pkg string, outputs []Output) error

func (*File) Tidy

func (f *File) Tidy()

Tidy ensures that the lockfile has the set of packages corresponding to the devbox.json config. It gets rid of older packages that are no longer needed.

type Locker

type Locker interface {
	Get(string) *Package
	LegacyNixpkgsPath(string) string
	ProjectDir() string
	Resolve(string) (*Package, error)
}

type Output

type Output struct {
	// Name is the output's name. Nix appends the name to
	// the output's store path unless it's the default name
	// of "out". Output names can be anything, but
	// conventionally they follow the various "make install"
	// directories such as "bin", "lib", "src", "man", etc.
	Name string `json:"name,omitempty"`

	// Path is the absolute store path (with the /nix/store/
	// prefix) of the output.
	Path string `json:"path,omitempty"`

	// Default indicates if Nix installs this output by
	// default.
	Default bool `json:"default,omitempty"`
}

Output refers to a nix package output. This struct is derived from searcher.Output

type Package

type Package struct {
	AllowInsecure bool   `json:"allow_insecure,omitempty"`
	LastModified  string `json:"last_modified,omitempty"`
	PluginVersion string `json:"plugin_version,omitempty"`
	Resolved      string `json:"resolved,omitempty"`
	Source        string `json:"source,omitempty"`
	Version       string `json:"version,omitempty"`
	// Systems is keyed by the system name
	Systems map[string]*SystemInfo `json:"systems,omitempty"`
}

func (*Package) GetSource

func (p *Package) GetSource() string

func (*Package) IsAllowInsecure

func (p *Package) IsAllowInsecure() bool

type SystemInfo

type SystemInfo struct {
	Outputs []Output `json:"outputs,omitempty"`

	// Legacy Format
	StorePath string `json:"store_path,omitempty"`
	// contains filtered or unexported fields
}

func (*SystemInfo) DefaultOutputs

func (i *SystemInfo) DefaultOutputs() []Output

func (*SystemInfo) Equals

func (i *SystemInfo) Equals(other *SystemInfo) bool

func (*SystemInfo) Output

func (i *SystemInfo) Output(name string) (Output, error)

func (*SystemInfo) String

func (i *SystemInfo) String() string

Useful for debugging when we print the struct

type UpdateStateHashFileArgs

type UpdateStateHashFileArgs struct {
	ProjectDir string
	ConfigHash string
	// IsFish is an arg because in the future we may allow the user
	// to specify shell in devbox.json which should be passed in here.
	IsFish bool
}

Jump to

Keyboard shortcuts

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