Files
devvm/testdata/script/features.txtar
T
w3cjandClaude Opus 5.5 dd3f0deb3f feat(state): config.toml and settings.json hold the defaults, and devvm's own files move to the data folder
~/.config/devvm/config.toml is the defaults you write by hand: backend,
network, ports, features, agents, [size] cpus/memory/disk and
[retention]'s six keys. devvm reads it and never writes it, strictly: an
unknown key (toml.MetaData.Undecoded, its line found by key) or a value
its check refuses (ParseCPUs, ParseGiB, ParsePorts, ask/on/off, a
backend's name, image.FeatureName, image.Agents, ParseDuration,
ParseSize, counts) fails naming the file and the line.
~/.local/share/devvm/settings.json holds what devvm setup, size -g,
ports -g, network -g and retention save (unknown fields ignored).

internal/settings owns both: Defaults (Value and List, each with its
Source: flag, config.toml, settings.json or built-in), Read, Save, which
refuses a key config.toml sets (set_in_config, with a doc link), and
the parsers and retention settings that moved from vm and state. A flag
wins over config.toml, config.toml over settings.json, settings.json
over the built-in default. Settings methods lose their files; setup
uses vm.NetworkChoice instead of its own copy; creation.plan reads one
snapshot (firstRun) after the first-run questions; the registry gets
the default backend through DefaultBackend; state's featureName copy
goes with base-features.

devvm size -g, ports -g, network -g and retention show each value's
source after a #, and in --json (source, sources); devvm doctor names
the file that sets its backend (doctor_backend_from) and adds
backend_source. devvm setup skips what config.toml answers
(setup_in_config) and refuses a flag that would change it.

ssh_config (and so the ~/.ssh/config Include line), known_hosts,
agent-keys.json and secrets/ move to the data folder. agent-keys.json is
{"keys": [{file, fingerprint, confirm, lifetime}]}, parsed once
(AddedKey); Keys formats KeyList.

Tests: settings' table tests (every key, unknown keys, bad values, an
empty file, precedence, Save's refusal and merge, settings.json's
fields), agent-keys.json, the registry's default backend, setup with
config.toml, SizeChoice with config.toml; CLI scripts for size -g,
ports -g, network -g, retention, setup and doctor's sources, each
refusal, a hand-edited config.toml with a typo, and ssh -G resolving
devvm-web through the Include line. Docs: settings.md's config.toml
section with a full example, linked from each command's page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 07:56:29 -07:00

88 lines
3.1 KiB
Plaintext

# Base image features: chosen the first time anything is built (without a
# terminal, every one: devvm's own, then the user's), saved in
# settings.json unless config.toml chooses them, and run in base after
# base.sh, in the order chosen.
env CHOSEN=$DATA/settings.json
rm $CHOSEN
mkdir $XDG_CONFIG_HOME/devvm/features
cp mine.sh $XDG_CONFIG_HOME/devvm/features/mine.sh
cp fzf.sh $XDG_CONFIG_HOME/devvm/features/fzf.sh
mkdir $XDG_CONFIG_HOME/devvm/layers
cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh
# A user feature named like a built-in one is ignored, with a warning.
exec devvm build base
stderr '^devvm: feature_shadowed feature=fzf file=.*/config/devvm/features/fzf\.sh$'
! stdout features_help
stdout '^==> base_features features=cli-tools fzf omb mine$'
grep '^ "features": \[\n "cli-tools",\n "fzf",\n "omb",\n "mine"\n \]$' $CHOSEN
cmp $STUB_DIR/scripts ran-all
catg $DATA/logs/runs/*.log
stdout '^# \[4/9\] running_script script=base\.sh vm=devvm-img-'
stdout '^# \[5/9\] running_script script=cli-tools\.sh vm=devvm-img-'
stdout '^# \[8/9\] running_script script=mine\.sh vm=devvm-img-'
stdout '^# \[9/9\] stopping vm=devvm-img-'
# Chosen once: the next build keeps the choice, and base.
exec devvm build base
! stderr feature_shadowed
! stdout 'base_features|building_image'
# Editing a chosen feature's script rebuilds base on next use.
exec sh -c 'echo "# edited" >> "$XDG_CONFIG_HOME/devvm/features/mine.sh"'
exec devvm build base
stdout '^==> building_image image=base key='
# A chosen feature without a script is skipped, with a warning; the steps
# count only what runs. A layer runs only its own script. config.toml's
# features win over settings.json's.
cp some.toml $CFG/config.toml
exec sh -c ': > "$STUB_DIR/scripts"'
exec devvm build foo
stderr '^devvm: unknown_feature feature=nope$'
! stdout base_features
cmp $STUB_DIR/scripts ran-some
exec sh -c 'cat "$XDG_DATA_HOME"/devvm/logs/runs/*.log'
stdout '^# \[4/7\] running_script script=base\.sh vm=devvm-img-'
stdout '^# \[5/7\] running_script script=fzf\.sh vm=devvm-img-'
stdout '^# \[6/7\] running_script script=omb\.sh vm=devvm-img-'
stdout '^# \[7/7\] stopping vm=devvm-img-'
stdout '^# \[4/5\] running_script script=foo\.sh vm=devvm-img-'
! stdout '\[8/7\]|\[6/5\]'
# None chosen: base runs only base.sh.
cp none.toml $CFG/config.toml
exec sh -c ': > "$STUB_DIR/scripts"'
exec devvm build base
! stderr .
cmp $STUB_DIR/scripts ran-none
grep '"mine"' $CHOSEN
-- some.toml --
features = ["fzf", "omb", "nope"]
-- none.toml --
features = []
-- mine.sh --
#!/bin/bash
# my tools
-- fzf.sh --
#!/bin/bash
# my fzf
-- foo.sh --
#!/bin/bash
echo foo
-- ran-all --
# Essentials, and mise for the shared tools (shared-tools/).
# CLI tools: bat, fd, eza, zoxide (z), btop, tree, tldr
# fzf: fuzzy Ctrl-R history and Ctrl-T file search
# oh-my-bash: themed prompt, completions, aliases
# my tools
-- ran-some --
# Essentials, and mise for the shared tools (shared-tools/).
# fzf: fuzzy Ctrl-R history and Ctrl-T file search
# oh-my-bash: themed prompt, completions, aliases
echo foo
-- ran-none --
# Essentials, and mise for the shared tools (shared-tools/).