Option to include directories outside of Chezmoi's root
TibiIius opened this issue · comments
Is your feature request related to a problem? Please describe.
No idea if this already is a feature of Chezmoi and I'm just too dumb/blind to figure this out. I currently am in the process of refactoring my dotfiles so that I can use them effortlessly at work, on private workstations, in headless/server environments aswell as minimalistic dev containers/environments. I do need quite a few work-specific scripts/env vars/convenience functions etc. at work, so I'd to separate these different environments.
Describe the solution you'd like
Imagine the following layout:
- dotfiles
- .chezmoiroot # -> 'root'
- root
- dot_config
- nvim
- dot_local
- bin
- some_shared_script
- dot_zshrc
- ...
- work
- dot_config
- work_specific_tool
- dot_local
- bin
- work_related_script
- private
- dot_var
- flatpak
- overrides
- dot_local
- bin
- something_silly
I'd like to conditionally include the work
folder alongside everything in root
. The condition could e.g. be {{ if eq .machineType "work" }} {{ includeFolder "../work" }} {{ end }}
.
Would it be possible to do something like this using Chezmoi or is this outside of its scope?
Describe alternatives you've considered
Alternatives I've considered would be an exhaustive .chezmoiignore
inside the root
folder covering all edge cases were I'd want folder XYZ but not folder ZYX. However, I fear the file could become too complex at some point.
Additional context
Got the idea from Nix's config management, which I used before Chezmoi, were I'd often import common and specific pre-defined configurations to a specific host/user.
The point of chezmoi is to use a single source of truth and use templates and .chezmoiignore
files to control what files are populated in each machine. If you have separate directories for "work" and "private" then you will run into problems when both need to change the same file. The solution is to use a template.
For modifying files outside of your home directory (i.e. for "root" in your example) there's a good description of how to do this here: #2574.