Repository navigation
feat(chezmoi): apply private secondary sources with a dotfiles wrapper - #118
Merged
Merged
Conversation
…y source A secondary source checked out at managed-<name>/ has no tooling of its own. mise tasks now run in the invocation directory and pass this repository's pre-commit config explicitly, hook file filters also match paths relative to a secondary source's root, and yamllint skips the nested checkouts.
The ignore rules split Icon[ and ] across two lines so the bracket held a literal carriage return. LF normalization drops that CR, leaving an invalid pattern that StyLua rejects. [[:cntrl:]] matches the CR without depending on it.
A secondary source is a separate Git repository checked out at managed-<name>/ and applied by its own chezmoi invocation with its own state file. dotfiles runs init, update, apply, diff, and status against this repository and then each secondary source, and refuses a secondary source that ships a config template. Work machines prompt for the work source URL, and Git uses the work identity inside managed-work/. ADR 0001 records the layout and the alternatives it rejected.
0xA3B
force-pushed
the
feat/multi-source-chezmoi
branch
from
November 11, 2026 00:39
2346ee4 to
865cc52
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some machines need dotfiles that must stay out of this public repository, and chezmoi applies only
one source directory per invocation. This change lets a machine apply private secondary sources
alongside this repository.
Solution
A secondary source is a separate Git repository checked out at
managed-<name>/inside thisrepository, which Git ignores. The new
dotfileswrapper applies this repository first and thenruns a separate chezmoi invocation for each secondary source, with that source's own persistent
state file and the shared config. Nesting lets a secondary source reuse this repository's tooling
and modify helpers. ADR 0001 records
the layout and the rejected alternatives: a shared state file, chezmoi hooks or a
git-repoexternal, and a sibling checkout.
dotfiles init,update,apply,diff, andstatusact on every source. These verbs acceptonly
-n,--dry-run,-v,--verbose, and--force. The wrapper has no general parser forchezmoi's flags.
dotfiles <name> <args>runs chezmoi against one secondary source. The wrapper appends--persistent-stateand--sourceafter the arguments, because chezmoi takes the last value of arepeated flag. It refuses
init,--init,purge, and--..chezmoiroot, because such a template would replace the shared config.includeIfgivesmanaged-work/the workGit identity.
The global Git ignore and this repository's
.gitignorenow match the macOSIcon\rfile with[[:cntrl:]]. The old two-line bracket pattern lost its carriage return to LF normalization, andStyLua rejected the result when it ran inside a nested repository.
Review notes
[task_config] dir = "{{cwd}}"inmise.tomlmakes every task run in the invocation directory. Atask run from a subdirectory of this repository now covers only that subtree. CI and hooks run
from the root.
dotfiles <name>is a flag that takes a value, chezmoi reads the appended--persistent-stateas that value. The wrapper docstring documents this.deny a tool access to
managed-work/before the first clone. No commit hook checks thisrepository for secondary-source content.
Validation
tests/test_dotfiles_chezmoi.pyruns the wrapper against a real chezmoi binary. CI installs nochezmoi, so it skips there. Locally, with chezmoi v2.74.0, it passes and fails when the appended
--sourceis removed.