Allow specify apply order
Closed this issue · 5 comments
Is your feature request related to a problem? Please describe.
I managed encrypt file .ssh/id_rsa
and some external private repo:
[".config/xx"]
type = "git-repo"
url = "git@github.com:xx/xx.git"
It works fine under normal circumstances.
However, when init on a new machine, .ssh/id_rsa
is apply after .config/xx
, resulting in no permission to pull git@github.com:xx/xx.git
.
Describe the solution you'd like
Looks like the apply order is alphabetical.
I wish there was a way to specify the order of apply, or there is some other way to solve it.
Describe alternatives you've considered
Try to use run_before script to chezmoi apply .ssh/id_rsa
first, but it's not allowed to run another chezmoi in chezmoi
Additional context
Another alternative is to call apply
2 times:
$ chezmoi apply -k
$ chezmoi apply
From docs:
-k
,--keep-going
Keep going as far as possible after a encountering an error.
I wish there was a way to specify the order of apply, or there is some other way to solve it.
I would suggest the following:
- In your
.chezmoiexternal
file, exclude.config/xx
if you're runningchezmoi init
:
# .chezmoiexternal.tompl
{{ if not has "init" .chezmoi.args }}
[".config/xx"]
type = "git-repo"
url = "git@github.com:xx/xx.git"
{{ end }}
- Use a
run_once_after_
script to checkout the repo on first run:
#!/bin/bash
# run_once_after_checkout-config-xx.sh
git clone git@github.com:xx/xx.git .config/xx
I would suggest the following:
- In your
.chezmoiexternal
file, exclude.config/xx
if you're runningchezmoi init
:# .chezmoiexternal.tompl {{ if not has "init" .chezmoi.args }} [".config/xx"] type = "git-repo" url = "git@github.com:xx/xx.git" {{ end }}
- Use a
run_once_after_
script to checkout the repo on first run:#!/bin/bash # run_once_after_checkout-config-xx.sh git clone git@github.com:xx/xx.git .config/xx
There seems to be a problem with the template syntax, after change accroding to above.
Run chezmoi update
:
chezmoi: /Users/bingo/.local/share/chezmoi/.chezmoiexternal.toml: template: /Users/bingo/.local/share/chezmoi/.chezmoiexternal.toml:9:6: executing "/Users/bingo/.local/share/chezmoi/.chezmoiexternal.toml" at <not>: wrong number of args for not: want 1 got 3
Directly execute template chezmoi execute-template < .chezmoiexternal.toml
chezmoi: template: stdin:9:6: executing "stdin" at <not>: wrong number of args for not: want 1 got 3
@bingo084 Try if not (has "init" .chezmoi.args)