Documentation
¶
Overview ¶
Package profile loads and selects modules from a profile.
Index ¶
Constants ¶
const ( ScopeUser = "user" ScopeSystem = "system" )
Scope values for ModuleConfig.Scope. Scope is module-level: it decides whether the module's dotfiles are applied as the invoking user (into ~/) or with root privileges (into /etc and other system paths).
const FilterReason = "module filter"
FilterReason is the Skip.Reason stamped on modules excluded by the positional module filter.
Variables ¶
This section is empty.
Functions ¶
func ParseModuleFilter ¶ added in v0.4.0
ParseModuleFilter normalizes positional module-filter args: each arg is split on commas, whitespace is trimmed, empties are dropped, and duplicates collapse keeping first-seen order. Empty input returns nil.
Types ¶
type Config ¶
type Config struct {
Modules ModulesConfig `toml:"modules"`
}
Config is the top-level dotdrift.toml configuration.
type Hooks ¶ added in v0.2.0
Hooks declares pre/post apply shell commands for a module. Unlike packages/tools/dotfiles, hooks are ordered sequences: layers merge by appending base → host → user (see internal/resolve).
type Module ¶
type Module struct {
ID string
App string
Path string
Config ModuleConfig
}
Module is a discovered module with its resolved identity and path.
type ModuleConfig ¶
type ModuleConfig struct {
ID string `toml:"id"`
App string `toml:"app"`
Scope string `toml:"scope"`
When When `toml:"when"`
Packages Packages `toml:"packages"`
Tools map[string]string `toml:"tools"`
Dotfiles map[string]Dotfile `toml:"dotfiles"`
Hooks Hooks `toml:"hooks"`
Mounts map[string]MountSpec `toml:"mounts"`
Smb SmbSpec `toml:"smb"`
}
ModuleConfig is the base module.toml configuration.
func LoadModuleConfig ¶
func LoadModuleConfig(dir string) (*ModuleConfig, error)
LoadModuleConfig reads a module.toml from the given directory. It returns the parsed config and the resolved module path, or nil if no module.toml exists.
func (ModuleConfig) ScopeOrDefault ¶ added in v0.2.0
func (c ModuleConfig) ScopeOrDefault() string
ScopeOrDefault returns the module's dotfile scope, defaulting to user when the key is omitted. Validity is not checked here — resolve rejects unknown values loudly.
type ModulesConfig ¶
type ModulesConfig struct {
Disable []string `toml:"disable"`
}
ModulesConfig holds the [modules] table.
type MountSpec ¶ added in v0.2.0
type MountSpec struct {
Source string `toml:"source"`
Destination string `toml:"destination"`
Type string `toml:"type"`
Options []string `toml:"options"`
StartAt string `toml:"startat"`
State string `toml:"state"`
}
MountSpec describes a single filesystem attachment declared in module.toml under [mounts.<name>]. Resolve validates structure only (non-empty source/destination/type, known state); Type is never checked against any registry — the registry lives outside resolve and evolves independently.
type Profile ¶
Profile is the loaded set of modules and selection state.
func Load ¶
Load reads a profile directory, unions dotdrift.toml layers, discovers modules, and runs selection against the provided facts.
func (*Profile) LimitTo ¶ added in v0.4.0
LimitTo restricts the selection to the listed module ids. An empty list is a no-op. Every id must name a discovered module, and the filter never resurrects modules skipped for their own reason (disabled, when filter): naming one is an error carrying that reason. Selected modules not in ids move to Skipped with reason "module filter", preserving order.
type ShareSpec ¶ added in v0.2.0
type ShareSpec struct {
}
ShareSpec describes one Samba share declared under [smb.shares.<name>]. A share's path may coincide with a mount's destination, but shares and mounts are declared independently — no derivation exists between them.
type SmbSpec ¶ added in v0.2.0
type SmbSpec struct {
Group string `toml:"group"`
Users []string `toml:"users"`
Avahi *bool `toml:"avahi"`
}
SmbSpec is the [smb] table of a module.toml. Avahi is a *bool so an unset key (nil) is distinguishable from an explicit false; downstream consumers treat nil as the default (avahi enabled). Layers merge the scalar fields by replacement-when-set and Shares whole-entry by name (see internal/resolve).
type When ¶
type When struct {
Hosts []string `toml:"hosts"`
Users []string `toml:"users"`
OS []string `toml:"os"`
GPU string `toml:"gpu"`
Kernel string `toml:"kernel"`
}
When filters a module by host, user, os, gpu, or kernel. Empty fields are ignored; non-empty fields must all match. Kernel holds one "<op> <version>" constraint ("<", "<=", ">", ">=", "==", "!=") compared numerically per dotted segment against the running kernel release; an empty kernel fact never matches a non-empty constraint.