Closed tartopohm closed 9 months ago
lazy-lock.json
should not be templated, full stop. It's a state file that, if you use different plug-ins on different machines, will always differ, and using chezmoi's approach for substituting state here is the wrong choice.
Your main options are:
lazy-lock.json
that just needs to be merged when you update it.Configure lazy.nvim
to use a different lockfile for personal and work machines. When you call lazy.setup({})
, do something like this in your (now templated) setup file:
lazy.setup({
lockfile = vim.fn.stdpath("config") .. {{ if isPersonal }}"/lazy-lock.json" {{ else }}"/work-lazy-lock.json"{{ end }}
})
See https://github.com/folke/lazy.nvim?tab=readme-ov-file#%EF%B8%8F-configuration.
Another options is to use a modify_
script.
Another options is to use a
modify_
script.
In general, yes. lazy-lock.json
is a bit of a special case akin to go.sum
. I don't think I’d want to have a modify_
script for go.sum
or Gemfile.lock
.
lazy-lock.json
should not be templated, full stop. It's a state file that, if you use different plug-ins on different machines, will always differ, and using chezmoi's approach for substituting state here is the wrong choice.Your main options are:
1. Use the same plug-ins on all machines. This keeps a stable `lazy-lock.json` that just needs to be merged when you update it. 2. Configure `lazy.nvim` to use a different lockfile for personal and work machines. When you call `lazy.setup({})`, do something like this in your (now templated) setup file: ``` lazy.setup({ lockfile = vim.fn.stdpath("config") .. {{ if isPersonal }}"/lazy-lock.json" {{ else }}"/work-lazy-lock.json"{{ end }} }) ```
See https://github.com/folke/lazy.nvim?tab=readme-ov-file#%EF%B8%8F-configuration.
Here, the file differing on different machines is a feature, not a bug. I care much less about breaking my editor at home than at work. I still want the lockfile to be version-controlled so I can easily roll it back if I need to, as suggested here.
Another options is to use a
modify_
script.In general, yes.
lazy-lock.json
is a bit of a special case akin togo.sum
. I don't think I’d want to have amodify_
script forgo.sum
orGemfile.lock
.
I will look into modify scripts and your option number 2. I mostly wanted more options to consider, thank you both for the suggestions!
What exactly are you trying to do?
I want to keep track of different versions of the same time across two machines. It is a simple JSON file, occasionally updated on the target side.
What have you tried so far?
I followed https://www.chezmoi.io/user-guide/manage-machine-to-machine-differences/#use-completely-different-dotfiles-on-different-machines, and it worked like a charm, until the file is updated. Then, the target version is ahead of the source, and every call to
apply
reminds me the target has changed (and conveniently, offers to skip overwrite). Usingadd
would overwrite my template file and not the machine-specific version of the dotfile. The solution I have been using so far, is too manually copy the target to~/.local/share/chezmoi
. Beyond automatising it whenever that file changes (which I will look into eventually), is there a "more proper" way to deal with that use case?Where else have you checked for solutions?
Additional context
The two machines are a personal Linux a work Linux. The file is
~/.config/nvim/lazy-lock.json
, that keeps track of the version of the installed Neovim plugins installed with the plugin manager lazy.nvim.