Skip to content

Commit 50d152e

Browse files
committed
fix(chezmoi): make --exclude=encrypted configurable via extra_args option
Removes hardcoded --exclude=encrypted from both build-time apply and postCreateCommand. New extra_args string option (default: --exclude=encrypted) preserves backward compatibility. Set to empty string to apply encrypted files when providing a decryption key via env_vars. Bumps version to 1.9.1.
1 parent 565ee65 commit 50d152e

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/chezmoi/devcontainer-feature.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "chezmoi",
33
"id": "chezmoi",
4-
"version": "1.9.0",
4+
"version": "1.9.1",
55
"description": "Install chezmoi",
66
"documentationURL": "https://github.com/ckagerer/devcontainer-features/tree/main/src/chezmoi",
77
"options": {
@@ -49,6 +49,11 @@
4949
"type": "boolean",
5050
"default": false,
5151
"description": "Skip chezmoi run_* scripts at build time and run them in postCreateCommand instead. Combine with the persist-nix-store feature so the Nix store persists across rebuilds. When false (default) behaviour is identical to the previous version."
52+
},
53+
"extra_args": {
54+
"type": "string",
55+
"default": "--exclude=encrypted",
56+
"description": "Extra flags appended to chezmoi apply at build time and in postCreateCommand. Defaults to '--exclude=encrypted'. Set to empty string to apply encrypted files (provide the decryption key via env_vars)."
5257
}
5358
},
5459
"postCreateCommand": "/usr/local/share/chezmoi-post-create.sh",

src/chezmoi/install.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ if [ -n "${ENV_VARS:-}" ]; then
109109
fi
110110

111111
# run chezmoi
112-
CHEZMOI_ARGS="init --apply --exclude=encrypted"
112+
CHEZMOI_ARGS="init --apply"
113+
if [ -n "${EXTRA_ARGS:-}" ]; then
114+
CHEZMOI_ARGS="${CHEZMOI_ARGS} ${EXTRA_ARGS}"
115+
fi
113116
if [ -n "${CHEZMOI_BRANCH}" ]; then
114117
CHEZMOI_ARGS="${CHEZMOI_ARGS} --branch '${CHEZMOI_BRANCH}'"
115118
fi
@@ -133,6 +136,7 @@ if [ "${DEBUG:-false}" = "true" ]; then
133136
printf 'CHEZMOI_USER=%s\n' "${CHEZMOI_USER}"
134137
printf 'CHEZMOI_USER_HOME=%s\n' "${CHEZMOI_USER_HOME}"
135138
printf 'ENV_VARS=%s\n' "${ENV_VARS:-}"
139+
printf 'EXTRA_ARGS=%s\n' "${EXTRA_ARGS:-}"
136140
printf 'KEEP_GOING=%s\n' "${KEEP_GOING:-false}"
137141
printf '\n-- Resolved chezmoi command --\n'
138142
printf '%s\n' "cd '${CHEZMOI_USER_HOME}' && ${CHEZMOI_ENV_SOURCE}REMOTE_CONTAINERS=1 ${CMD}"
@@ -178,6 +182,7 @@ tee "$POST_CREATE_SCRIPT_PATH" >/dev/null <<'EOF'
178182
179183
KEEP_GOING="__KEEP_GOING_PLACEHOLDER__"
180184
DEFER_SCRIPTS="__DEFER_SCRIPTS_PLACEHOLDER__"
185+
EXTRA_ARGS="__EXTRA_ARGS_PLACEHOLDER__"
181186
182187
if [[ "${KEEP_GOING}" == "true" ]]; then
183188
set +o errexit +o nounset +o pipefail
@@ -189,7 +194,8 @@ set -x
189194
# Run deferred chezmoi scripts (Nix install, home-manager switch, …).
190195
# The /nix named volume is mounted at this point, so the Nix store persists.
191196
if [[ "${DEFER_SCRIPTS}" == "true" ]]; then
192-
chezmoi apply --include=scripts --exclude=encrypted
197+
# shellcheck disable=SC2086
198+
chezmoi apply --include=scripts ${EXTRA_ARGS}
193199
fi
194200
195201
ATUIN_USER="__ATUIN_USER_PLACEHOLDER__"
@@ -227,13 +233,15 @@ EOF
227233

228234
KEEP_GOING_ESCAPED="$(escape_sed_replacement "${KEEP_GOING:-false}")"
229235
DEFER_SCRIPTS_ESCAPED="$(escape_sed_replacement "${DEFER_SCRIPTS:-false}")"
236+
EXTRA_ARGS_ESCAPED="$(escape_sed_replacement "${EXTRA_ARGS:-}")"
230237
ATUIN_USER_ESCAPED="$(escape_sed_replacement "${ATUIN_USER:-}")"
231238
ATUIN_PASSWORD_ESCAPED="$(escape_sed_replacement "${ATUIN_PASSWORD:-}")"
232239
ATUIN_KEY_ESCAPED="$(escape_sed_replacement "${ATUIN_KEY:-}")"
233240

234241
sed -i \
235242
-e "s|__KEEP_GOING_PLACEHOLDER__|${KEEP_GOING_ESCAPED}|g" \
236243
-e "s|__DEFER_SCRIPTS_PLACEHOLDER__|${DEFER_SCRIPTS_ESCAPED}|g" \
244+
-e "s|__EXTRA_ARGS_PLACEHOLDER__|${EXTRA_ARGS_ESCAPED}|g" \
237245
-e "s|__ATUIN_USER_PLACEHOLDER__|${ATUIN_USER_ESCAPED}|g" \
238246
-e "s|__ATUIN_PASSWORD_PLACEHOLDER__|${ATUIN_PASSWORD_ESCAPED}|g" \
239247
-e "s|__ATUIN_KEY_PLACEHOLDER__|${ATUIN_KEY_ESCAPED}|g" \

0 commit comments

Comments
 (0)