Documentation
¶
Overview ¶
Package flakelock provides flake.lock file management for reproducible builds.
Package flakelock provides flake.lock file management for reproducible builds.
Index ¶
- Variables
- func CompareFlakeLocks(lock1, lock2 string) bool
- func GetInputRevision(lockContent string, inputName string) (string, error)
- type FlakeLockFile
- type FlakeLockManager
- type Manager
- func (m *Manager) Delete(ctx context.Context, buildID string) error
- func (m *Manager) Generate(ctx context.Context, flakePath string) (string, error)
- func (m *Manager) GetStoredLock(ctx context.Context, buildID string) (*StoredLock, error)
- func (m *Manager) ListBuildIDs(ctx context.Context) []string
- func (m *Manager) Retrieve(ctx context.Context, buildID string) (string, error)
- func (m *Manager) ShouldRegenerate(ctx context.Context, buildID string, sourceHash string) bool
- func (m *Manager) Store(ctx context.Context, buildID string, lockContent string) error
- func (m *Manager) Update(ctx context.Context, flakePath string, existingLock string) (string, error)
- type ManagerOption
- type StoredLock
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyFlakePath is returned when the flake path is empty. ErrEmptyFlakePath = errors.New("flake path is empty") // ErrFlakeNotFound is returned when flake.nix is not found. ErrFlakeNotFound = errors.New("flake.nix not found") // ErrLockGenerationFailed is returned when lock generation fails. ErrLockGenerationFailed = errors.New("failed to generate flake.lock") // ErrLockGenerationTimeout is returned when lock generation times out. ErrLockGenerationTimeout = errors.New("flake.lock generation timed out") // ErrLockUpdateFailed is returned when lock update fails. ErrLockUpdateFailed = errors.New("failed to update flake.lock") // ErrInvalidLockFormat is returned when the lock content is not valid JSON. ErrInvalidLockFormat = errors.New("invalid flake.lock format") // ErrEmptyBuildID is returned when the build ID is empty. ErrEmptyBuildID = errors.New("build ID is empty") // ErrEmptyLockContent is returned when the lock content is empty. ErrEmptyLockContent = errors.New("lock content is empty") // ErrLockNotFound is returned when a stored lock is not found. ErrLockNotFound = errors.New("flake.lock not found for build ID") )
Errors returned by the flakelock package.
Functions ¶
func CompareFlakeLocks ¶
CompareFlakeLocks compares two flake.lock contents and returns true if they are equivalent.
Types ¶
type FlakeLockFile ¶
type FlakeLockFile struct {
Version int `json:"version"`
Nodes map[string]interface{} `json:"nodes"`
Root string `json:"root,omitempty"`
}
FlakeLockFile represents the structure of a flake.lock file.
func ParseFlakeLock ¶
func ParseFlakeLock(content string) (*FlakeLockFile, error)
ParseFlakeLock parses a flake.lock content into a FlakeLockFile.
type FlakeLockManager ¶
type FlakeLockManager interface {
// Generate creates a new flake.lock for a flake.nix.
Generate(ctx context.Context, flakePath string) (string, error)
// Update updates an existing flake.lock.
Update(ctx context.Context, flakePath string, existingLock string) (string, error)
// Store persists a flake.lock for a build.
Store(ctx context.Context, buildID string, lockContent string) error
// Retrieve gets a stored flake.lock.
Retrieve(ctx context.Context, buildID string) (string, error)
// ShouldRegenerate determines if lock should be regenerated.
ShouldRegenerate(ctx context.Context, buildID string, sourceHash string) bool
}
FlakeLockManager manages flake.lock files for reproducibility.
type Manager ¶
type Manager struct {
// Timeout is the maximum time to wait for lock generation.
Timeout time.Duration
// contains filtered or unexported fields
}
Manager implements the FlakeLockManager interface.
func NewManager ¶
func NewManager() *Manager
NewManager creates a new Manager with default settings.
func NewManagerWithOptions ¶
func NewManagerWithOptions(opts ...ManagerOption) *Manager
NewManagerWithOptions creates a new Manager with custom options.
func (*Manager) Generate ¶
Generate creates a new flake.lock for a flake.nix at the given path. It runs `nix flake lock` to generate the lock file.
func (*Manager) GetStoredLock ¶
GetStoredLock retrieves the full stored lock metadata.
func (*Manager) ListBuildIDs ¶
ListBuildIDs returns all build IDs with stored locks.
func (*Manager) ShouldRegenerate ¶
ShouldRegenerate determines if the lock should be regenerated. Returns true if: - No lock exists for the build ID - The source hash has changed (indicating source code changes)
type ManagerOption ¶
type ManagerOption func(*Manager)
ManagerOption is a functional option for configuring Manager.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ManagerOption
WithTimeout sets the timeout for lock generation.