Schema Reference

This document is the authoritative reference for both the global configuration file (~/.anvil/config.yaml) and the workload definition file (workload.yaml). All field names, types, and defaults are derived from the Rust source structs.


Configuration File (~/.anvil/config.yaml)

The global configuration file stores user preferences and default settings. If the file does not exist, Anvil uses the built-in defaults shown below.

defaults

Default settings applied to CLI commands.

KeyTypeDefaultDescription
defaults.shellstring"powershell"Default shell for script execution (powershell, pwsh).
defaults.script_timeoutinteger300Default script timeout in seconds.
defaults.output_formatstring"table"Output format for commands. Valid values: table, json, yaml, html.
defaults.colorstring"auto"Color output mode. Valid values: auto, always, never.

backup

Controls automatic backup behavior during installs.

KeyTypeDefaultDescription
backup.auto_backupbooleantrueCreate a backup before install operations.
backup.retention_daysinteger30Delete backups older than this many days.
backup.max_backupsinteger10Maximum number of backups to keep per workload.
backup.compressbooleanfalseCompress backups by default.

install

Settings that govern package installation behavior.

KeyTypeDefaultDescription
install.parallel_packagesbooleanfalseInstall packages in parallel.
install.skip_installedbooleantrueSkip packages that are already installed.
install.confirmbooleantruePrompt for confirmation before installing.

workloads

Workload discovery configuration.

KeyTypeDefaultDescription
workloads.pathslist of strings[]Additional directories to search for workloads.

logging

Logging configuration.

KeyTypeDefaultDescription
logging.levelstring"info"Log verbosity level. Valid values: error, warn, info, debug, trace.
logging.filestring or nullnullPath to a log file. null disables file logging.

Full Example

defaults:
  shell: powershell
  script_timeout: 300
  output_format: table
  color: auto

backup:
  auto_backup: true
  retention_days: 30
  max_backups: 10
  compress: false

install:
  parallel_packages: false
  skip_installed: true
  confirm: true

workloads:
  paths:
    - ~/my-workloads
    - /shared/team-workloads

logging:
  level: info
  file: ~/.anvil/anvil.log

Workload Schema (workload.yaml)

A workload is defined by a workload.yaml file inside a workload directory. The directory may also contain files/ and scripts/ subdirectories.

Top-Level Fields

FieldTypeRequiredDefaultDescription
namestringyesUnique workload identifier (kebab-case).
versionstringyesSemantic version (e.g., "1.0.0").
descriptionstringyesHuman-readable description of the workload.
extendslist of stringsnonullParent workload names to inherit from.
packagesobjectnonullPackage definitions, grouped by manager.
fileslist of FileEntrynonullConfiguration files to deploy.
scriptsobjectnonullScripts to execute at various phases.
commandsobjectnonullInline commands to execute at various phases.
environmentobjectnonullEnvironment variables and PATH additions.
healthobjectnonullHealth check configuration flags.
assertionslist of AssertionnonullDeclarative assertions for health validation.

packages

The packages object groups package definitions by package manager. Each manager key is optional.

FieldTypeRequiredDescription
packages.wingetlist of WingetPackagenoWindows packages managed by winget.
packages.brewlist of BrewPackagenomacOS/Linux packages managed by Homebrew.
packages.aptlist of AptPackagenoDebian/Ubuntu packages managed by APT.

Winget Package

FieldTypeRequiredDefaultDescription
idstringyesWinget package identifier (e.g., Git.Git).
versionstringnolatestSpecific version to install.
sourcestringnonullPackage source (e.g., msstore for Microsoft Store apps).
overridelist of stringsnonullOverride arguments passed to the installer.
override_argslist of stringsnonullAdditional winget arguments.
packages:
  winget:
    - id: Git.Git
    - id: Microsoft.VisualStudioCode
      version: "1.95.0"
    - id: Notepad++.Notepad++
      override:
        - --override
        - "/VERYSILENT /NORESTART"
    - id: 9NBLGGH4NNS1
      source: msstore

Brew Package

FieldTypeRequiredDefaultDescription
namestringyesPackage name (e.g., git, node).
caskbooleannofalseWhether this is a cask (GUI app) vs formula (CLI tool).
tapstringnonullTap source (e.g., homebrew/cask-fonts).
packages:
  brew:
    - name: git
    - name: visual-studio-code
      cask: true
    - name: font-cascadia-code
      cask: true
      tap: homebrew/cask-fonts

APT Package

FieldTypeRequiredDefaultDescription
namestringyesPackage name (e.g., git, build-essential).
versionstringnonullSpecific version constraint.
packages:
  apt:
    - name: git
    - name: build-essential
      version: "12.9"

files

Each entry in the files list describes a configuration file to deploy.

FieldTypeRequiredDefaultDescription
sourcestringyesPath relative to the workload's files/ directory.
destinationstringyesTarget path. ~ expands to the user's home directory.
backupbooleannotrueBack up the existing file before overwriting.
permissionsstringnonullFile permissions (reserved for future use).
templatebooleannofalseProcess the file as a Handlebars template before deploying.
files:
  - source: user/.config/starship.toml
    destination: "~/.config/starship.toml"
  - source: user/.gitconfig
    destination: "~/.gitconfig"
    backup: true
    template: true

commands

The commands object defines inline shell commands to execute at install phases.

FieldTypeDescription
commands.pre_installlist of CommandEntryCommands to run before package installation.
commands.post_installlist of CommandEntryCommands to run after package installation.

CommandEntry

FieldTypeRequiredDefaultDescription
runstringyesShell command string to execute.
descriptionstringnonullHuman-readable description.
timeoutintegerno300Timeout in seconds.
elevatedbooleannofalseWhether the command requires administrator privileges.
whenConditionnonullCondition that must be true for this command to run.
continue_on_errorbooleannofalseWhether to continue if this command fails.
commands:
  post_install:
    - run: "rustup default stable"
      description: "Set Rust stable as default toolchain"
      timeout: 120
    - run: "cargo install cargo-watch"
      description: "Install cargo-watch"
      when:
        type: command_exists
        command: cargo
      continue_on_error: true

environment

Environment variable and PATH configuration.

FieldTypeDescription
environment.variableslist of EnvVariableEnvironment variables to set.
environment.path_additionslist of stringsDirectory paths to add to the system PATH. ~ expands to the user's home.

EnvVariable

FieldTypeRequiredDefaultDescription
namestringyesVariable name.
valuestringyesVariable value.
scopestringno"user"Scope: user or machine.
environment:
  variables:
    - name: EDITOR
      value: code
      scope: user
    - name: DOTNET_CLI_TELEMETRY_OPTOUT
      value: "1"

  path_additions:
    - "~/.cargo/bin"
    - "~/.local/bin"

health

Flags that control which categories of health checks are evaluated during anvil health.

FieldTypeRequiredDefaultDescription
package_checkbooleannotrueVerify that declared packages are installed.
file_checkbooleannotrueVerify that declared files are deployed.
assertion_checkbooleannotrueEvaluate declarative assertions.
health:
  package_check: true
  file_check: true
  assertion_check: true

assertions

Declarative health assertions using the condition engine. Each assertion pairs a display name with a condition to evaluate.

FieldTypeRequiredDescription
namestringyesDisplay name for the assertion.
checkConditionyesThe condition to evaluate.

Condition Types

Conditions are serialized as tagged objects with a type discriminator field. The following condition types are available:

command_exists

Check whether a command is available on PATH.

FieldTypeRequiredDescription
typestringyes"command_exists"
commandstringyesCommand name to look for.
file_exists

Check whether a file exists at the given path (~ is expanded).

FieldTypeRequiredDescription
typestringyes"file_exists"
pathstringyesFile path to check.
dir_exists

Check whether a directory exists at the given path (~ is expanded).

FieldTypeRequiredDescription
typestringyes"dir_exists"
pathstringyesDirectory path to check.
env_var

Check whether an environment variable is set, optionally matching an expected value.

FieldTypeRequiredDescription
typestringyes"env_var"
namestringyesEnvironment variable name.
valuestringnoExpected value. If omitted, only checks that the variable is set.
path_contains

Check whether the system PATH contains a given substring.

FieldTypeRequiredDescription
typestringyes"path_contains"
substringstringyesSubstring to search for in PATH entries.
registry_value

Query a Windows registry value under HKCU or HKLM.

FieldTypeRequiredDescription
typestringyes"registry_value"
hivestringyesRegistry hive: "HKCU" or "HKLM".
keystringyesFull key path (e.g., "SOFTWARE\\Microsoft\\Windows\\CurrentVersion").
namestringyesValue name inside the key.
expectedstringnoExpected data. If omitted, only asserts the value exists.
shell

Run a shell command; the condition passes when the exit code is 0.

FieldTypeRequiredDescription
typestringyes"shell"
commandstringyesShell command to execute.
descriptionstringnoHuman-readable description of the check.
all_of

Logical AND — all child conditions must pass.

FieldTypeRequiredDescription
typestringyes"all_of"
conditionslist of ConditionyesChild conditions to evaluate.
any_of

Logical OR — at least one child condition must pass.

FieldTypeRequiredDescription
typestringyes"any_of"
conditionslist of ConditionyesChild conditions to evaluate.

Assertions Example

assertions:
  - name: "Git is installed"
    check:
      type: command_exists
      command: git

  - name: "Config directory exists"
    check:
      type: dir_exists
      path: "~/.config/app"

  - name: "EDITOR is set to VS Code"
    check:
      type: env_var
      name: EDITOR
      value: code

  - name: "Cargo bin is in PATH"
    check:
      type: path_contains
      substring: ".cargo/bin"

  - name: "Dark mode enabled"
    check:
      type: registry_value
      hive: HKCU
      key: "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"
      name: AppsUseLightTheme
      expected: "0x0"

  - name: "Rust toolchain ready"
    check:
      type: all_of
      conditions:
        - type: command_exists
          command: rustc
        - type: command_exists
          command: cargo
        - type: path_contains
          substring: ".cargo/bin"

Full Example

A complete workload.yaml demonstrating all sections:

name: developer-tools
version: "1.0.0"
description: "Full developer workstation setup"
extends:
  - essentials

packages:
  winget:
    - id: Git.Git
    - id: Microsoft.VisualStudioCode
    - id: Rustlang.Rustup
    - id: Starship.Starship

files:
  - source: user/.config/starship.toml
    destination: "~/.config/starship.toml"
    backup: true
  - source: user/.gitconfig
    destination: "~/.gitconfig"
    template: true

scripts:
  pre_install:
    - path: pre-install.ps1
      description: "System preparation"
      timeout: 60

  post_install:
    - path: configure-terminal.ps1
      description: "Configure Windows Terminal"
      timeout: 300
      elevated: true

commands:
  post_install:
    - run: "rustup default stable"
      description: "Set default Rust toolchain"
      timeout: 120
    - run: "cargo install cargo-watch"
      description: "Install cargo-watch"
      when:
        type: command_exists
        command: cargo
      continue_on_error: true

environment:
  variables:
    - name: EDITOR
      value: code
    - name: DOTNET_CLI_TELEMETRY_OPTOUT
      value: "1"
      scope: user
  path_additions:
    - "~/.cargo/bin"

health:
  package_check: true
  file_check: true
  assertion_check: true

assertions:
  - name: "Git is installed"
    check:
      type: command_exists
      command: git
  - name: "VS Code is installed"
    check:
      type: command_exists
      command: code
  - name: "Starship config deployed"
    check:
      type: file_exists
      path: "~/.config/starship.toml"