top | item 18903453

(no title)

RagingCactus | 7 years ago

Is there a way to manage different "categories" of systems with chezmoi? For example, a "linux-server" category would contain an essential set of dotfiles, but not all the window manager related stuff from my linux laptop. Looking at the documentation, the only way to do this would be hostname-based templating, but that seems cumbersome as you would have to change every single template to add the new hostname to the section in question.

discuss

order

twp|7 years ago

Yes, you can define your own template variables in the config file, for example if you include:

  data:
    category: "linux-server"
in your .config/chezmoi/chezmoi.yaml file, you can then use it in your templates and a .chezmoiignore file (which is also treated as a template). A .chezmoiignore file could look like:

  {{ if eq .category "linux-server" -}}
  .windowmanager.conf
  {{ end -}}
I use this technique myself: https://github.com/twpayne/dotfiles/blob/master/.chezmoiigno...

RagingCactus|7 years ago

Thanks! Just defining it as a config variable is far too obvious in hindsight, I don't know why it didn't cross my mind.

I'll definitely try it out!