mise

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package mise: bootstrap config translation — emits [bootstrap.*] sections for mise bootstrap convergence.

Package mise bootstraps the mise binary and runs mise operations.

Index

Constants

View Source
const InstallerURL = "https://mise.run"

InstallerURL is the official mise installer.

View Source
const MinMiseVersion = "2026.8.2"

MinMiseVersion is the hardcoded minimum mise version required by dotdrift.

Variables

This section is empty.

Functions

func CompareVersions

func CompareVersions(a, b string) (int, error)

CompareVersions compares calendar-style versions like 2026.6.6. Returns -1 if a < b, 0 if equal, 1 if a > b. A version carrying a pre-release/build suffix (e.g. "2025.1.0-rc1", "2025.1.0+build.5") compares below the plain release. Unparseable input is an error.

func GenerateApplyConfig added in v0.2.0

func GenerateApplyConfig(plan *resolve.Plan, profileRoot string, f *facts.Facts, interactive bool) string

GenerateApplyConfig emits the full apply-time mise.toml: tools, dotfiles, and hook tasks. The hook tasks need facts and the absolute profile root, so only apply uses this; onboard keeps using GenerateConfig. interactive flows through to GenerateHookTasks.

func GenerateBootstrapAccounts added in v0.10.0

func GenerateBootstrapAccounts(group string, users []string) string

GenerateBootstrapAccounts emits [bootstrap.groups] and [bootstrap.users] for the samba group and its users.

func GenerateBootstrapConfig added in v0.10.0

func GenerateBootstrapConfig(install []string, backend, pluginPath string) string

GenerateBootstrapConfig emits all bootstrap-related sections: packages and the paru plugin registration. Returns "" when there is nothing to emit.

func GenerateBootstrapDirectories added in v0.10.0

func GenerateBootstrapDirectories(paths []string) string

GenerateBootstrapDirectories emits a [bootstrap.directories] section so mise creates mount-point directories before units are enabled.

func GenerateBootstrapFiles added in v0.10.0

func GenerateBootstrapFiles(files []BootstrapFile) string

GenerateBootstrapFiles emits a [bootstrap.files] section. copy/symlink modes become content copies (symlink→copy is a deliberate improvement for system files); template mode adds template = true.

func GenerateBootstrapPackages added in v0.10.0

func GenerateBootstrapPackages(install []string, backend string) string

GenerateBootstrapPackages emits a [bootstrap.packages] section. Bare names get the backend prefix; explicit prefixes pass through. Every entry is pinned to "latest" (mise's package-plugin API does not support version pins for AUR). Returns "" when the list is empty.

func GenerateBootstrapPlugins added in v0.10.0

func GenerateBootstrapPlugins(pluginPath string) string

GenerateBootstrapPlugins emits a [bootstrap.plugins] section registering the paru package plugin at the given local path. Returns "" when pluginPath is empty.

func GenerateBootstrapServices added in v0.10.0

func GenerateBootstrapServices(services []BootstrapService) string

GenerateBootstrapServices emits a [bootstrap.services] section.

func GenerateConfig

func GenerateConfig(plan *resolve.Plan) string

GenerateConfig emits a complete mise.toml with tools and dotfiles sections.

func GenerateDotfiles

func GenerateDotfiles(entries []resolve.DotfileEntry) string

GenerateDotfiles emits a mise.toml [dotfiles] section from the resolved plan.

func GenerateHookTasks added in v0.2.0

func GenerateHookTasks(hooks resolve.HooksStep, profileRoot string, f *facts.Facts, interactive bool) string

GenerateHookTasks emits a [tasks] section with one mise task per non-empty hook list ("hooks:pre" and/or "hooks:post"). Each task runs its commands in order from dir (the absolute profile root) with the DOTDRIFT_* facts environment. When interactive is true each task is marked `interactive = true` so mise connects it to the terminal's stdin/stdout/ stderr — a hook running an interactive command (e.g. sudo) can then reach a controlling terminal and disable echo instead of echoing the password. Returns "" when both lists are empty.

func GenerateTools

func GenerateTools(versions map[string]string) string

GenerateTools emits a mise.toml [tools] section from the resolved plan.

func PluginDir added in v0.10.0

func PluginDir(xdgDataHome, name string) string

PluginDir returns the path where dotdrift writes a named mise package plugin (e.g. "paru") under the XDG data home.

func PrefixedPackages added in v0.10.0

func PrefixedPackages(names []string, backend string) []string

PrefixedPackages translates bare package names to manager:pkg keys. Bare names (no colon) get the detected backend's manager prefix (paru, apt, dnf); names already containing a ":" prefix pass through unchanged.

Types

type BootstrapFile added in v0.10.0

type BootstrapFile struct {
	Target   string
	Source   string
	Template bool
}

BootstrapFile is one concrete file target for [bootstrap.files].

func ResolveBootstrapFiles added in v0.10.0

func ResolveBootstrapFiles(entries []resolve.DotfileEntry, sourceRoot, homeDir string) ([]BootstrapFile, error)

ResolveBootstrapFiles expands system-scope dotfile entries into individual file targets. symlink-each entries are expanded by listing the source directory. sourceRoot must be an absolute path to the profile root.

type BootstrapService added in v0.10.0

type BootstrapService struct {
	Name    string // unit name, e.g. "mnt-data.mount"
	Enabled bool
	Running bool
}

BootstrapService is one systemd unit to converge via [bootstrap.services].

type DotfilesStep

type DotfilesStep struct {
	Runner     Runner
	Plan       *resolve.Plan
	ConfigPath string
	Yes        bool
}

DotfilesStep runs mise dotfiles apply for the dotfiles in the resolved plan.

func (*DotfilesStep) Name

func (s *DotfilesStep) Name() string

func (*DotfilesStep) Run

func (s *DotfilesStep) Run(ctx context.Context) error

type DotfilesSystemStep added in v0.2.0

type DotfilesSystemStep struct {
	Exec       *ExecMise
	Entries    []resolve.DotfileEntry
	ConfigPath string
	Yes        bool
}

DotfilesSystemStep applies system-scope dotfile entries with root privileges. It takes the concrete ExecMise (like HooksStep) because the sudo-aware entry point is deliberately not part of the Runner interface. cmd/apply.go only constructs it when at least one system-scope entry exists; Run also no-ops on an empty list as a second line of defense.

func (*DotfilesSystemStep) Name added in v0.2.0

func (s *DotfilesSystemStep) Name() string

func (*DotfilesSystemStep) Run added in v0.2.0

type ExecMise

type ExecMise struct {
	// contains filtered or unexported fields
}

ExecMise wraps a Mise value so it can be used as a Runner by step code.

func NewExecMise

func NewExecMise(m *Mise) *ExecMise

NewExecMise creates a Runner backed by a Mise instance.

func (*ExecMise) Bootstrap added in v0.10.0

func (e *ExecMise) Bootstrap(ctx context.Context, configPath string, yes bool, only ...string) error

Bootstrap invokes `mise bootstrap --yes` against the config. It runs the full declarative convergence (packages, files, services, etc.) in one call. dotdrift's resume orchestrator may instead drive `--only`/`--skip` slices.

func (*ExecMise) DotfilesApply

func (e *ExecMise) DotfilesApply(ctx context.Context, configPath string, yes, force bool) error

func (*ExecMise) DotfilesApplySudo added in v0.2.0

func (e *ExecMise) DotfilesApplySudo(ctx context.Context, configPath string, yes bool) error

DotfilesApplySudo applies system-scope dotfiles with root privileges. When the process is not already root it invokes sudo (failing loudly if sudo is missing or authentication fails); as root it applies directly.

func (*ExecMise) EnsureAndInstall

func (e *ExecMise) EnsureAndInstall(ctx context.Context, configPath string) error

func (*ExecMise) RunTask added in v0.2.0

func (e *ExecMise) RunTask(ctx context.Context, configPath, taskName string) error

RunTask runs a named task (e.g. "hooks:pre") from the generated config.

type FakeRunner

type FakeRunner struct {
	InstallCalled   bool
	DotfilesCalled  bool
	BootstrapCalled bool
	Yes             bool
	Force           bool
	Err             error
}

func (*FakeRunner) Bootstrap added in v0.10.0

func (f *FakeRunner) Bootstrap(ctx context.Context, configPath string, yes bool, only ...string) error

func (*FakeRunner) DotfilesApply

func (f *FakeRunner) DotfilesApply(ctx context.Context, configPath string, yes, force bool) error

func (*FakeRunner) EnsureAndInstall

func (f *FakeRunner) EnsureAndInstall(ctx context.Context, configPath string) error

type HooksStep

type HooksStep struct {
	Exec       *ExecMise
	Commands   []string
	ConfigPath string
	Task       string // mise task name, e.g. "hooks:pre"
	StepName   string // pipeline step name, e.g. "hooks-pre"
}

HooksStep runs one pre/post hook command list as a mise task from the// generated apply config. cmd/apply.go only constructs HooksSteps for non-empty command lists; Run also no-ops on an empty list as a second line of defense.

func (*HooksStep) Name

func (s *HooksStep) Name() string

func (*HooksStep) Run

func (s *HooksStep) Run(ctx context.Context) error

type InstallKind

type InstallKind int

InstallKind classifies how a mise binary is managed.

const (
	InstallKindUnknown InstallKind = iota
	InstallKindSystemWide
	InstallKindUserManaged
)

func ClassifyInstall

func ClassifyInstall(path string) InstallKind

ClassifyInstall determines whether a mise binary is system-wide or user-managed.

System-wide (no auto-upgrade):

  • DOTDRIFT_MISE_SYSTEM=1
  • path under /usr/bin, /usr/local/bin, /bin, /sbin, /usr/sbin, /opt
  • path under $HOME but not writable by the current user

User-managed (may auto-upgrade):

  • path under $HOME and writable by the current user

func (InstallKind) String

func (k InstallKind) String() string

type Mise

type Mise struct {
	LookPath   func(string) (string, error)
	Run        func(string, ...string) (string, error)
	RunContext func(context.Context, string, ...string) (string, error)
	Install    func() (string, error)
	Classify   func(string) InstallKind

	// Env is extra environment ("KEY=value") appended to the subprocess
	// environment on the real exec path; fakes (Run/RunContext) bypass it.
	Env []string

	// Verbose streams operation subprocesses (install/dotfiles/tasks) live
	// to Out/Err instead of capturing and discarding their output, echoing
	// each command line set -x-style ("+ argv") to Err before it runs. Only
	// the ExecMise operation calls stream: version probes and the mise.run
	// bootstrap always stay captured and unechoed (their output is parsed
	// or one-time).
	Verbose bool

	// Out/Err are the Verbose streaming destinations; nil defaults to
	// os.Stdout/os.Stderr.
	Out io.Writer
	Err io.Writer
	// contains filtered or unexported fields
}

Mise finds, installs, or upgrades a mise binary.

RunContext is preferred over the legacy Run; both are kept so existing fakes that only set Run keep working. The result of the first Ensure call is memoized for the lifetime of the struct.

func DefaultMise

func DefaultMise() *Mise

DefaultMise returns a Mise configured with real OS dependencies. Run and RunContext stay nil so runner() uses the env-aware real exec path.

func (*Mise) Ensure

func (m *Mise) Ensure() (string, error)

Ensure finds or installs a mise binary meeting the minimum version. The result (success or failure) is computed once and memoized.

func (*Mise) EnsureContext added in v0.2.0

func (m *Mise) EnsureContext(ctx context.Context) (string, error)

EnsureContext is Ensure with ctx propagated to every subprocess.

type Runner

type Runner interface {
	EnsureAndInstall(ctx context.Context, configPath string) error
	Bootstrap(ctx context.Context, configPath string, yes bool, only ...string) error
	DotfilesApply(ctx context.Context, configPath string, yes, force bool) error
}

type ToolsStep

type ToolsStep struct {
	Runner     Runner
	Plan       *resolve.Plan
	ConfigPath string
}

ToolsStep runs mise install for the tools in the resolved plan.

func (*ToolsStep) Name

func (s *ToolsStep) Name() string

func (*ToolsStep) Run

func (s *ToolsStep) Run(ctx context.Context) error

Jump to

Keyboard shortcuts

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