script fix

This commit is contained in:
RoyDumblauskas committed 2026-10-16 00:54:59 -05:00
1 parent 1e16bfd1c3
commit 92e9726a02
2 files changed
+14 -14

No files matched your search

-2
View File
@@ -3,7 +3,6 @@ keys:
- &laptop age1zad0qu648dhjav4pzjhkc6vswnqtacuv9230xcgle8wmv56r8ykqn0ud7y - &laptop age1zad0qu648dhjav4pzjhkc6vswnqtacuv9230xcgle8wmv56r8ykqn0ud7y
- &desktop age1rwugh86469664fwhgrj9xuhjxs9vpflx3r0ftuvd0glphf2gecfs8thxsj - &desktop age1rwugh86469664fwhgrj9xuhjxs9vpflx3r0ftuvd0glphf2gecfs8thxsj
- &nixos-homelab-00 age1hzaf8j6djfc4yc98m3kqjzzdj4tcskf9kdzvjmje2xuqcfmrz5lqdtn5w7 - &nixos-homelab-00 age1hzaf8j6djfc4yc98m3kqjzzdj4tcskf9kdzvjmje2xuqcfmrz5lqdtn5w7
- &virtual age1q5zwds8g47j7xsqhp8tk995l3n4a5z876vff7wgx4sztwgdsa3yq7eu6xk
creation_rules: creation_rules:
- path_regex: '.*/secrets/[^/]+\.(yaml|json|env|ini)$' - path_regex: '.*/secrets/[^/]+\.(yaml|json|env|ini)$'
key_groups: key_groups:
@@ -11,4 +10,3 @@ creation_rules:
- *laptop - *laptop
- *desktop - *desktop
- *nixos-homelab-00 - *nixos-homelab-00
- *virtual
+14 -12
View File
@@ -108,22 +108,24 @@ sudo install -o root -g nixbld -m 0440 \
# Requires mikefarah/yq v4 and simple comma-separated age fields. # Requires mikefarah/yq v4 and simple comma-separated age fields.
export AGE_PUBLIC_KEY export AGE_PUBLIC_KEY
if ! yq -e \ # Confirm at least one creation rule contains an age key group.
'.creation_rules | any(.[]; has("age"))' \ if ! yq -e '
"$SOPS_CONFIG" >/dev/null; then [.creation_rules[]
echo "No creation_rules with an age field found in .sops.yaml" >&2 | select(.key_groups != null)
| .key_groups[]
| select(.age != null)]
| length > 0
' "$SOPS_CONFIG" >/dev/null; then
echo "No creation_rules with key_groups.age found in .sops.yaml" >&2
exit 1 exit 1
fi fi
# Add the temporary public key to every age key group.
yq -i ' yq -i '
(.creation_rules[] | select(has("age")) | .age) |= ( (.creation_rules[].key_groups[] | select(.age != null).age) +=
split(",") [strenv(AGE_PUBLIC_KEY)]
| map(trim) |
| map(select(. != "")) (.creation_rules[].key_groups[] | select(.age != null).age) |= unique
| . + [strenv(AGE_PUBLIC_KEY)]
| unique
| join(",")
)
' "$SOPS_CONFIG" ' "$SOPS_CONFIG"
echo "Updating SOPS recipients for secrets in $VM_FOLDER..." echo "Updating SOPS recipients for secrets in $VM_FOLDER..."