Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to include directories outside of Chezmoi's root #3766

Closed
TibiIius opened this issue May 16, 2024 · 1 comment
Closed

Option to include directories outside of Chezmoi's root #3766

TibiIius opened this issue May 16, 2024 · 1 comment
Labels
enhancement New feature or request won't fix This will not be worked on

Comments

@TibiIius
Copy link

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.

@TibiIius TibiIius added the enhancement New feature or request label May 16, 2024
@twpayne
Copy link
Owner

twpayne commented May 20, 2024

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.

@twpayne twpayne closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
@twpayne twpayne added the won't fix This will not be worked on label May 20, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request won't fix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants