nix

package
v0.0.0-...-fa7fddc Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnotationFlake         = "containix.dev/flake"
	AnnotationEntrypoint    = "containix.dev/entrypoint"
	AnnotationTimeout       = "containix.dev/timeout"            // e.g. "120s", "5m"
	AnnotationContainerType = "io.kubernetes.cri.container-type" // injected by CRI
)
View Source
const DefaultBuildTimeout = 2 * time.Minute

DefaultBuildTimeout is the upper bound on a single Nix build invocation when the pod doesn't override via the containix.dev/timeout annotation. Tuned for "fetch a moderately sized closure from a binary cache" — too short for first-time-on-node fresh builds, fine for cached pulls.

View Source
const MaxBuildTimeout = 30 * time.Minute

MaxBuildTimeout caps how long a single container can wait for Nix work, regardless of what the pod requests. Prevents a misbehaving annotation from holding a pod in ContainerCreating forever.

Variables

View Source
var ErrTimeout = errors.New("nix subprocess timed out")

ErrTimeout is returned when a Nix subprocess is killed because its context deadline expired. Distinct from a normal command failure so callers can surface a clearer error to operators.

Functions

func Closure

func Closure(ctx context.Context, storePath string) ([]string, error)

Closure returns all store paths in the closure of the given path.

Honors the context's deadline (if any). Closure queries should be fast (no network, no compilation) but can still hang on misbehaving daemons.

func PrepareRootfs

func PrepareRootfs(bundlePath string, flakeOutput FlakeOutput, cfg *ContainixConfig, closurePaths []string) error

PrepareRootfs modifies the OCI bundle to mount the Nix store paths and set the entrypoint.

Types

type ContainixConfig

type ContainixConfig struct {
	FlakeRef   string
	Entrypoint string
	// Timeout is the maximum time allowed for the combined Nix build +
	// closure resolution for this container. Always populated; defaults to
	// DefaultBuildTimeout and is clamped to MaxBuildTimeout.
	Timeout time.Duration
}

func FromBundle

func FromBundle(bundlePath string) (*ContainixConfig, error)

FromBundle reads the containix annotations from the OCI bundle's config.json. Returns nil if no containix annotations are present (passthrough to runc).

type FlakeOutput

type FlakeOutput struct {
	StorePath   string
	MainProgram string //empty if not declared by the derivation
}

func Build

func Build(ctx context.Context, flakeRef string) (FlakeOutput, error)

Build resolves a flake reference to a Nix store path.

Honors the context's deadline (if any) by killing the underlying nix subprocess when ctx is canceled. Caller is responsible for deciding the timeout; typically derived from the container's containix.dev/timeout annotation.

Jump to

Keyboard shortcuts

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