From 09b96075deb18f334e3e712c52cd7f6250e3858d Mon Sep 17 00:00:00 2001 From: aloslider <53711835+aloslider@users.noreply.github.com> Date: Wed, 22 Apr 2026 18:30:41 +0300 Subject: [PATCH] Add age key creation skip; Move paths to vars; --- .chezmoi.toml.tmpl | 11 ++++++----- .chezmoidata/vars.yaml | 3 +++ .../run_onchange_before_11-setup-age-key.sh.tmpl | 9 +++++++-- 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 .chezmoidata/vars.yaml diff --git a/.chezmoi.toml.tmpl b/.chezmoi.toml.tmpl index 16e6130..7bc08d1 100644 --- a/.chezmoi.toml.tmpl +++ b/.chezmoi.toml.tmpl @@ -1,10 +1,11 @@ encryption = "age" + [age] - {{- if eq .chezmoi.osRelease.id "nixos" }} - identity = "/etc/age/key.txt" - {{- else }} - identity = "~/.config/chezmoi/key.txt" - {{- end }} + {{ if eq .chezmoi.osRelease.id "nixos" }} + identity = "{{ .vars.nixosAgeKeyPath }}" + {{ else }} + identity = "{{ .vars.defaultAgeKeyPath }}" + {{ end }} recipient = "age1tl5hp6v0t38fl8gxuqds40z503mwz885ev22au4jdy5r24aak3zsza23sx" [bitwarden] diff --git a/.chezmoidata/vars.yaml b/.chezmoidata/vars.yaml new file mode 100644 index 0000000..bcd7365 --- /dev/null +++ b/.chezmoidata/vars.yaml @@ -0,0 +1,3 @@ +defaultAgeKeyPath: "~/.config/age/key.txt" +nixosAgeKeyPath: "/etc/age/key.txt" +skipCreatingAgeKey: true diff --git a/.chezmoiscripts/run_onchange_before_11-setup-age-key.sh.tmpl b/.chezmoiscripts/run_onchange_before_11-setup-age-key.sh.tmpl index ae7ad08..69f0ddb 100755 --- a/.chezmoiscripts/run_onchange_before_11-setup-age-key.sh.tmpl +++ b/.chezmoiscripts/run_onchange_before_11-setup-age-key.sh.tmpl @@ -7,8 +7,13 @@ set -euo pipefail echo "Setting up age key..." -KEY_DIR="$HOME/.config/chezmoi" -KEY_FILE="$KEY_DIR/key.txt" +KEY_FILE="{{ .vars.defaultAgeKeyPath }}" +KEY_DIR="$(dirname "$KEY_FILE")" + +{{ if .vars.skipCreatingAgeKey }} +echo "Expecting age key to be at $KEY_FILE" +exit 0 +{{ end }} mkdir -p "$KEY_DIR" chmod 700 "$KEY_DIR"