Skip to content

.chezmoiroot as template to include large common dotfiles #5041

@RangHo

Description

@RangHo

Is your feature request related to a problem? Please describe.

I am using Arch Linux with Niri on my desktop and Void Linux with Xmonad on my laptop.
Due to the difference in display management system (X11 vs. Wayland), I have many dotfiles specific for each system, but I still have a ton of dotfiles shared across all systems.

For example, I use different application launcher and notification daemon on my desktop and laptop, but I still use Bash, Fish, Vim, Emacs, Ghostty, wallpapers, Git settings, templates, etc...

Reconciling for the difference is possible now, but it requires carefully reading and making sure that .chezmoiignore is correct in all cases. It is working for now, but the difference would just keep getting larger as I move away from my X11-based locker setup on my desktop, and I'd be banging my head against the .chezmoiignore file after finding 1852nd typo that breaks the system.

Describe the solution you'd like

Maybe we can put multiple roots in .chezmoiroot and make the file a template. For example,

common
{{- if eq .chezmoi.hostname "my-desktop" }}
desktop
{{- else if eq .chezmoi.hostname "my-laptop" }}
laptop
{{- else }}
# Maybe this is a server that needs no GUI-related stuff :)
{{- end }}

If there are any conflicts between among dotfiles, the ones specified later in .chezmoiroot always preferred, including the directories with +exact attributes.

Describe alternatives you've considered

Putting everything in .chezmoiignore is for now the only solution, I imagine.

Additional context

My dotfile repository is here. I recently moved to Chezmoi from GNU Stow-based approach, and this is the feature I'm missing the most from Stow.

I've seen a discussion at #3083, but it seems to refer to a system where completely different operating system is used. I thought this issue was different enough to deserve its own feature request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions