Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/system-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mise can place config files (dotfiles) at machine-global paths via the
"~/.ssh/config" = { source = "dotfiles/ssh_config.tmpl", mode = "template" }
"~/.config/nvim" = "dotfiles/nvim" # symlink the directory itself
"~/.local/bin" = { source = "dotfiles/bin", mode = "symlink-each" } # symlink each file within
"~/.config/*.toml" = { source = "dotfiles/config/*.toml", mode = "copy" }
```

Each entry is keyed by the target path — absolute or starting with `~/` —
Expand All @@ -22,6 +23,18 @@ To manage one piece of a file something else owns (a line in `.zshrc`, an
entry in `/etc/hosts`) rather than the whole file, see
[System Edits](/system-edits.html).

Source paths may contain glob wildcards like `*`, `**`, `?`, or `[ab]`.
When a wildcard source matches multiple paths, the target path must contain
matching wildcards so each source expands to a unique target:

```toml
[system.files]
"~/.config/*.toml" = "dotfiles/config/*.toml"
"~/.local/share/app/**/*.json" = { source = "dotfiles/app/**/*.json", mode = "copy" }
"~/.config/app?.toml" = "dotfiles/config/app?.toml"
"~/.config/theme-[ab].toml" = "dotfiles/config/theme-[ab].toml"
```

## Modes

| Mode | Behavior |
Expand Down
29 changes: 29 additions & 0 deletions e2e/cli/test_system_files
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,34 @@ assert "readlink ~/.config/nvim" "$PWD/dotfiles/nvim"
assert "readlink ~/.local/mybin/one" "$PWD/dotfiles/bin/one"
assert "readlink ~/.local/mybin/two" "$PWD/dotfiles/bin/two"

# wildcard sources expand to concrete target paths using matching target wildcards
mkdir -p dotfiles/config dotfiles/question dotfiles/classes dotfiles/tree/nested
echo "bat config" >dotfiles/config/bat.conf
echo "question config" >dotfiles/question/app1.conf
echo "class config" >dotfiles/classes/theme-a.conf
echo "root config" >dotfiles/tree/root.conf
echo "tool config" >dotfiles/tree/nested/tool.conf
cat <<EOF >>mise.toml
"~/.config/*.conf" = { source = "dotfiles/config/*.conf", mode = "copy" }
"~/.local/question/app?.conf" = { source = "dotfiles/question/app?.conf", mode = "copy" }
"~/.local/classes/theme-[ab].conf" = { source = "dotfiles/classes/theme-[ab].conf", mode = "copy" }
"~/.local/tree/**/*.conf" = "dotfiles/tree/**/*.conf"
EOF
assert_succeed "mise system install --yes"
assert "cat ~/.config/bat.conf" "bat config"
assert "cat ~/.local/question/app1.conf" "question config"
assert "cat ~/.local/classes/theme-a.conf" "class config"
assert "readlink ~/.local/tree/root.conf" "$PWD/dotfiles/tree/root.conf"
assert "readlink ~/.local/tree/nested/tool.conf" "$PWD/dotfiles/tree/nested/tool.conf"

# empty wildcard sources are skipped instead of blocking unrelated entries
cat <<EOF >>mise.toml
"~/.config/missing-*.conf" = "dotfiles/config/missing-*.conf"
EOF
assert_succeed "mise system status"
assert_contains "mise system status 2>&1" "source pattern matched no files"
assert_succeed "mise system install --yes"

# symlink-each leaves room for files mise doesn't manage
touch ~/.local/mybin/unmanaged

Expand All @@ -49,6 +77,7 @@ assert_succeed "mise system install --yes"
assert "cat ~/.config/starship.toml" "starship v2"

# template permission drift is detected and repaired
chmod 644 ~/.ssh/config
chmod 600 dotfiles/ssh_config.tmpl
assert_contains "mise system status" "permissions differ"
assert_succeed "mise system install --yes"
Expand Down
Loading
Loading