1
0
Fork 0
gnu-plus-dotfiles/.chezmoi.yaml.tmpl
rain 0cc12f050a Fix .chezmoi.yaml.tmpl: handle missing ID_LIKE on debian-stable
debian-stable's /etc/os-release has no ID_LIKE field. Template crashed
with 'map has no entry for key idLike' when chezmoi init ran on rye.

Two fixes:
1. hasKey() guard around .chezmoi.osRelease.idLike so missing key
   doesn't error out
2. Flip contains() arg order: sprig's signature is contains(substr, str),
   not contains(str, substr). Was checking backwards.

Tested against:
- miche (ID=debian-derivative with ID_LIKE=arch) -> os_family=arch
- empty ID_LIKE fallback (debian-stable) -> falls through to .id=debian
  -> os_family=debian
2026-06-21 19:37:06 -04:00

22 lines
No EOL
768 B
Cheetah

{{- $osFamily := "unknown" -}}
{{- $idLike := "" -}}
{{- if hasKey .chezmoi.osRelease "idLike" -}}
{{- $idLike = .chezmoi.osRelease.idLike -}}
{{- end -}}
{{- if or (eq .chezmoi.osRelease.id "arch") (contains "arch" $idLike) -}}
{{- $osFamily = "arch" -}}
{{- else if or (eq .chezmoi.osRelease.id "debian") (contains "debian" $idLike) -}}
{{- $osFamily = "debian" -}}
{{- end -}}
encryption: "age"
sourceDir: {{ .chezmoi.sourceDir | quote }}
# When you have age secrets, uncomment and add recipient public keys here.
# recipients:
# - age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p
# - age1miche_pubkey_placeholder
# - age1byte_pubkey_placeholder
data:
os_family: {{ $osFamily | quote }}
os_id: {{ .chezmoi.osRelease.id | quote }}