cfg

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRegistry = "public.ecr.aws/w1l3v2k8/devcell"

DefaultRegistry is the default container registry for devcell images. Must match runner.DefaultRegistry.

Variables

This section is empty.

Functions

func ApplyEnv

func ApplyEnv(c *CellConfig, getenv func(string) string)

ApplyEnv overrides scalar fields from environment variables.

func KnownStacks added in v0.4.0

func KnownStacks() []string

KnownStacks returns the list of valid stack names.

func StackSize added in v0.4.0

func StackSize(stack string) (string, bool)

StackSize returns the approximate download size for the given stack.

func ValidateStack added in v0.4.0

func ValidateStack(stack string) error

ValidateStack checks that stack is a known stack name. Empty is valid (defaults to ultimate).

Types

type AwsSection added in v0.4.0

type AwsSection struct {
	ReadOnly *bool `toml:"read_only"` // default: true (nil = not set → true)
}

AwsSection holds [aws] config for AWS credential scoping.

func (AwsSection) ResolvedReadOnly added in v0.4.0

func (a AwsSection) ResolvedReadOnly() bool

ResolvedReadOnly returns false unless explicitly set to true.

type CellConfig

type CellConfig struct {
	Cell     CellSection
	LLM      LLMSection   `toml:"llm"`
	Git      GitSection   `toml:"git"`
	Ports    PortsSection `toml:"ports"`
	Op       OpSection    `toml:"op"`
	Aws      AwsSection   `toml:"aws"`
	Env      map[string]string
	Mise     map[string]string `toml:"mise"` // [mise] — keys map to MISE_<UPPER_KEY> env vars
	Volumes  []VolumeMount
	Packages PackagesSection
}

CellConfig is the merged configuration from all TOML layers.

func LoadFile

func LoadFile(path string) (CellConfig, error)

LoadFile parses a TOML file into CellConfig. Returns zero value + nil error if the file does not exist.

func LoadFromOS

func LoadFromOS(configDir, cwd string) CellConfig

LoadFromOS loads the layered config using real XDG paths and os.Getenv.

func LoadLayered

func LoadLayered(globalPath, projectPath string, getenv func(string) string) CellConfig

LoadLayered loads global + project files, merges them, then applies env overrides.

func Merge

func Merge(global, project CellConfig) CellConfig

Merge returns a new CellConfig with project overriding global for scalars; Env maps and Volumes slices are accumulated (project wins on key conflict).

type CellSection

type CellSection struct {
	ImageTag         string   `toml:"image_tag"`
	Registry         string   `toml:"registry"`          // container registry; default: DefaultRegistry; env: DEVCELL_REGISTRY
	GUI              *bool    `toml:"gui"`               // default: true (nil = not set → true)
	Timezone         string   `toml:"timezone"`          // IANA tz (e.g. "Europe/Prague"); default: host $TZ
	Locale           string   `toml:"locale"`            // POSIX locale (e.g. "en_US.UTF-8"); default: "en_US.UTF-8"
	Stack            string   `toml:"stack"`             // nix stack name (e.g. "go", "python"); default: "base" (see ResolvedStack)
	Modules          []string `toml:"modules"`           // extra nix modules to compose on top of stack
	NixhomePath      string   `toml:"nixhome"`           // local nixhome path; overridden by DEVCELL_NIXHOME_PATH env
	Engine           string   `toml:"engine"`            // execution engine: "docker" (default) or "vagrant"
	VagrantProvider  string   `toml:"vagrant_provider"`  // vagrant provider: "utm" (default) or "libvirt"
	VagrantBox       string   `toml:"vagrant_box"`       // vagrant box name override (default: "utm/bookworm")
	DockerPrivileged bool     `toml:"docker_privileged"` // run container with --privileged; default: false
	PerSessionImage  *bool    `toml:"per_session_image"` // tag user image per tmux session instead of per stack; default: false
	Hostname         string   `toml:"hostname"`          // override container hostname; default: computed "cell-<basename>-<cellID>"; env: DEVCELL_HOSTNAME
	MacAddress       string   `toml:"mac_address"`       // MAC for the container's NIC (XX:XX:XX:XX:XX:XX); pinned across restarts for infra-side identity persistence. Honored on user-defined bridge networks (devcell uses --network devcell-network). Empty → docker auto-assigns a random MAC per launch.
}

CellSection holds [cell] config.

func (CellSection) ResolvedGUI added in v0.4.0

func (c CellSection) ResolvedGUI() bool

ResolvedGUI returns the effective GUI setting: true unless explicitly set to false.

func (CellSection) ResolvedHostname added in v0.7.0

func (c CellSection) ResolvedHostname(computed string) string

ResolvedHostname returns the effective container hostname. Precedence: DEVCELL_HOSTNAME env > [cell] hostname in TOML > computed default (typically "cell-<basename>-<cellID>" assembled by config.Load).

func (CellSection) ResolvedPerSessionImage added in v0.6.0

func (c CellSection) ResolvedPerSessionImage() bool

ResolvedPerSessionImage returns true only when explicitly enabled.

func (CellSection) ResolvedRegistry added in v0.4.0

func (c CellSection) ResolvedRegistry() string

ResolvedRegistry returns the effective registry: env > toml > default.

func (CellSection) ResolvedStack added in v0.4.0

func (c CellSection) ResolvedStack() string

ResolvedStack returns Stack if set, else "base".

type GitSection added in v0.3.0

type GitSection struct {
	AuthorName     string `toml:"author_name"`
	AuthorEmail    string `toml:"author_email"`
	CommitterName  string `toml:"committer_name"`
	CommitterEmail string `toml:"committer_email"`
}

GitSection holds [git] config for git identity inside the container.

func (GitSection) HasIdentity added in v0.3.0

func (g GitSection) HasIdentity() bool

HasIdentity reports whether any git identity field is set.

func (GitSection) ResolvedCommitterEmail added in v0.3.0

func (g GitSection) ResolvedCommitterEmail() string

ResolvedCommitterEmail returns CommitterEmail if set, else falls back to AuthorEmail.

func (GitSection) ResolvedCommitterName added in v0.3.0

func (g GitSection) ResolvedCommitterName() string

ResolvedCommitterName returns CommitterName if set, else falls back to AuthorName.

type LLMModelsSection added in v0.3.0

type LLMModelsSection struct {
	Default   string                 `toml:"default"`
	Providers map[string]LLMProvider `toml:"providers"`
}

LLMModelsSection holds [llm.models] config — provider/model declarations.

type LLMProvider added in v0.2.0

type LLMProvider struct {
	BaseURL string   `toml:"base_url"`
	Models  []string `toml:"models"`
}

LLMProvider holds a single provider entry under [llm.models.providers.<name>].

type LLMSection added in v0.3.0

type LLMSection struct {
	SystemPrompt     string           `toml:"system_prompt"`
	SystemPromptFile string           `toml:"system_prompt_file"`
	UseOllama        bool             `toml:"use_ollama"`
	Models           LLMModelsSection `toml:"models"`
}

LLMSection holds [llm] config — all AI agent settings in one place.

SystemPrompt and SystemPromptFile are mutually exclusive — set one or neither. The resolver in internal/runner.ResolveSystemPrompt validates this and returns an error when both are set, so we don't fail config load for projects where the conflict is harmless (e.g. callers that don't read system prompts).

type OpSection added in v0.3.0

type OpSection struct {
	Documents []string `toml:"documents"` // 1Password document names to resolve via `op item get`
	Items     []string `toml:"items"`     // deprecated: use documents (kept for backwards compat)
}

OpSection holds [op] config for 1Password secret injection.

func (OpSection) ResolvedDocuments added in v0.4.0

func (o OpSection) ResolvedDocuments() []string

ResolvedDocuments returns the merged list of documents + legacy items (deduped).

type PackagesSection

type PackagesSection struct {
	Npm    map[string]string `toml:"npm"`
	Python map[string]string `toml:"python"`
}

PackagesSection holds [packages] config for npm and python tools.

type PortsSection added in v0.4.0

type PortsSection struct {
	Forward   []string `toml:"forward"`    // port mappings: "3000", "8080:3000"
	PublishIP string   `toml:"publish_ip"` // host interface for `docker run -p`; default "0.0.0.0". Applies to VNC, RDP, and all forward entries.
}

PortsSection holds [ports] config for port forwarding.

func (PortsSection) ResolvedPublishIP added in v0.7.0

func (p PortsSection) ResolvedPublishIP() string

ResolvedPublishIP returns the effective host IP for `docker run -p`. Defaults to "0.0.0.0" when unset so cells are reachable from other hosts regardless of dockerd's bind default (some Docker Desktop / rootless setups default to 127.0.0.1, which would silently break remote RDP/VNC). Override in TOML to bind a specific NIC or "127.0.0.1" for loopback-only.

type VolumeMount

type VolumeMount struct {
	Mount string `toml:"mount"`
}

VolumeMount holds a single [[volumes]] entry.

Jump to

Keyboard shortcuts

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