Closed raimundomartins closed 9 months ago
Just to confirm, does that mean that I can only manage chezmoi config by means of a template? I can't just store the plain file?
Which should also mean that the only way to create and edit it is to chezmoi cd
and $EDITOR .config.$FORMAT.tmpl
?
Just to confirm, does that mean that I can only manage chezmoi config by means of a template? I can't just store the plain file?
You can use a plain file, but you would need to make changes to it directly (under .config
) outside of chezmoi to avoid the issue described below.
It used to be possible to manage the config file with chezmoi, but it always resulted in any changes made to the config (inside the source state) being one chezmoi apply
behind the rest of the source state. This is strongly discouraged.
Instead, we encourage the usage of a config template, which has its contents evaluated at the same time as the rest of the source state, so you don't need to run chezmoi apply
first in order to propagate your config changes to your other dotfiles. There may be a few edge cases I've forgotten about, but I'm mostly right either way.
I think the docs may need a few more tweaks regarding this.
Which should also mean that the only way to create and edit it is to
chezmoi cd
and$EDITOR .config.$FORMAT.tmpl
?
It's not the only way. You can also use chezmoi edit-config
or chezmoi edit-config-template
. My preferred way is to open my entire source state in my editor.
You cannot store the chezmoi config within itself, because the chezmoi config is required to know how to apply the changes. See #2854 for more details.
As long as there are no secrets in your .config/chezmoi/chezmoi.$FORMAT
, you could copy it to $(chezmoi source-path).chezmoi.$FORMAT.tmpl
and then add templating as required. Be sure that there is nothing you don't want in a (possibly public) repo before you commit it, though, and make it configurable that way.
Thank you for the explanation @bradenhilton, but I don't quite follow how it would be one chezmoi apply
behind, nor how editing it in a template is any different from a normal config file except in edge cases (as opposed to the "always" you mention). After reading more issues, perhaps I should explain my workflow and my difficulties with the docs as they are:
chezmoi init
so it checks out my empty repo (that's how you start, right?).The docs only mention how to Create a config file on a new machine automatically (which I had no need to at first and assumes you had a config file in chezmoi) and the one you sent to Re-create your config file which also assumes you had a config in chezmoi already. The bootstrap step of starting with an empty repo is missing.
You cannot store the chezmoi config within itself, because the chezmoi config is required to know how to apply the changes. See #2854 for more details.
That statement is contradictory with reality, at least the way it is written: the configuration is managed by chezmoi, it's just in a different place. And like I said, not allowing the source-path is very logical, but in none of the issue-tree starting from that one I read any argument as to why the same should be done for .config/chezmoi. I don't question that there isn't, I just didn't find it, which means that this part was confusing for me as a new user.
Finally, chezmoi edit-config
~and chezmoi edit-config-template
~ don't work as I would expect. The former felt like 100% replaceable with $EDITOR ~/.config/chezmoi/chezmoi.toml
except perhaps it checks for the other formats. It doesn't add/update the source-path. ~The latter doesn't apply the config I just setup.~ I see now that this is standard procedure for chezmoi edit
as well, but there is an apply flag for edit
which doesn't exist for edit-config-template
.
In any case, I'm probably wrong somewhere in my reasoning (lack of knowledge and whatnot), but I thought I'd give my feedback on my onboarding experience of chezmoi currently, since I think it's a great project!
Feel free to close this issue.
When you are first starting with chezmoi, you will have an empty repo. But that is typically an exactly once operation. After that, you will have your machine specific configuration in ~/.config/chezmoi/chezmoi.$FORMAT
and your dotfiles and templates &c. in the repo/source directory. Then you want to make it easy to start on a new machine (it’s time to upgrade your computer), so you create your .chemoiz.$FORMAT.tmpl
based on your configuration and extract out the pieces that you want to answer (every time or once with fallback to what is in the config now) and then you go to your new computer and you do chezmoi init REPO_URL --apply
and it asks you the questions you set up, determines machine configuration, and then applies based on that configuration so that your new computer's home directory is configured the way you want it to be (modulo missing programs).
If the configuration file were managed by chezmoi, you would have two problems:
apply
behind (reads the current configuration file, then applies to everything including the configuration file, which updates the configuration file which means that you are now in a cycle of needing to apply again to get the updated configuration in place and it starts all over)Chezmoi will be able to answer if your .chezmoi.$FORMAT.tmpl
file is newer than your ~/.config/chezmoi/chezmoi.$FORMAT
file and will suggest using chezmoi init
to update it — but there's no rollback (because the configuration file is not version-controlled).
If you use chezmoi edit-config-template
, you would need to run chezmoi init
to apply any changes to the configuration file.
I hope that this reduces the confusion you have on this. If you have any specific documentation suggestions that would help clarify this, please raise them or open a pull request as we are always looking to make sure that the documentation is as clear as possible.
What exactly are you trying to do?
I'm trying to manage chezmoi's config with chezmoi, but for some reason it's "protected".
I can understand
.local/share/chezmoi
being protected, but not this.Where else have you checked for solutions?
Output of any commands you've tried with
--verbose
flagOutput of
chezmoi doctor
Additional context
I'm still trying out chezmoi, even if quite decided on using it already.
There are no
*chezmoi*
files in.local/share/chezmoi/
(so there can't be any conflicts with that).