twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
13.36k stars 493 forks source link

chezmoiexternals conflict #3409

Closed davidolrik closed 10 months ago

davidolrik commented 11 months ago

I'm trying to install the Helix editor using the precompiled version found on GitHub.

I have also added the helix config to my chezmoi repo.

These are the helix files chezmoi controls:

dot_config/helix
├── config.toml
└── themes
    └── my_theme.toml

This external will include the helix runtime directory in .config/helix/runtime

[".config/helix"]
  type = "archive"
  url = "https://github.com/helix-editor/helix/releases/download/23.10/helix-23.10-aarch64-macos.tar.xz"
  exact = true
  stripComponents = 1
  refreshPeriod = "168h"
  include = [ "helix-23.10-aarch64-macos/runtime/**" ]

Unfortunately this conflicts with the state of .config/helix already added to chezmoi.

As a workaround I'm currently including the external using [".config/helix/runtime"] which installs the directory into .config/helix/runtime/runtime.

twpayne commented 11 months ago

Do you have a specific question?

davidolrik commented 11 months ago

I apologise if I haven't described the bug well enough, but given the that following two files are added to chezmoi:

It is impossible to extract the runtime directory and place it in .config/helix/runtime, as the external seems to be using the same state key: .config/helix.

This is the error I get when trying to apply the config above:

$ chezmoi apply --refresh-externals
chezmoi: .config/helix: inconsistent state (/Users/me/.local/share/chezmoi/dot_config/helix, https://github.com/helix-editor/helix/releases/download/23.10/helix-23.10-aarch64-macos.tar.xz defined in /Users/me/.local/share/chezmoi/.chezmoiexternal.toml)

It seems to me that the archive external should use whatever is in the include parameter as state keys, and not the actual path of the external - in this case .config/helix vs .config/helix/runtime.

Does that make sense?

bradenhilton commented 11 months ago

If I'm not mistaken, this should do what you want:

dot_config/helix/.chezmoiexternal.toml:

["runtime"]
  type = "archive"
  url = "https://github.com/helix-editor/helix/releases/download/23.10/helix-23.10-aarch64-macos.tar.xz"
  exact = true
  stripComponents = 2
  refreshPeriod = "168h"
  include = ["helix-23.10-aarch64-macos/runtime/**"]
davidolrik commented 11 months ago

@bradenhilton Thank you for that, I didn't know that you could have a .chezmoiexternal.toml in a directory other than the root chezmoi dir.

Right now I just have one giant .chezmoiexternal.toml in the root of my chezmoi repo, where I direct multiple files from from multiple archives to various install locations in my home dir using template, and configuration from my chezmoi.toml

I'll rework my template macro for including applications from GitHub, but I believe my original observation still stands:

The archive external should use whatever is in the include parameter as state keys, and not the actual path of the external.