Try adding an option to output with armor

This commit is contained in:
Andrew Lubawy 2024-07-24 08:39:51 -07:00
parent de96bd907d
commit c1b9550d8e
No known key found for this signature in database
GPG key ID: 8E98BAE1F49C2709

View file

@ -118,6 +118,10 @@ function keys {
(@nixInstantiate@ --json --eval --strict -E "(let rules = import $RULES; in rules.\"$1\".publicKeys)" | @jqBin@ -r .[]) || exit 1 (@nixInstantiate@ --json --eval --strict -E "(let rules = import $RULES; in rules.\"$1\".publicKeys)" | @jqBin@ -r .[]) || exit 1
} }
function armor {
(@nixInstantiate@ --json --eval --strict -E "(let rules = import $RULES; in (builtins.hasAttr \"armor\" rules.\"$1\" && rules.\"$1\".armor))") || exit 1
}
function decrypt { function decrypt {
FILE=$1 FILE=$1
KEYS=$2 KEYS=$2
@ -148,6 +152,7 @@ function decrypt {
function edit { function edit {
FILE=$1 FILE=$1
KEYS=$(keys "$FILE") || exit 1 KEYS=$(keys "$FILE") || exit 1
ARMOR=$(armor "$FILE") || exit 1
CLEARTEXT_DIR=$(@mktempBin@ -d) CLEARTEXT_DIR=$(@mktempBin@ -d)
CLEARTEXT_FILE="$CLEARTEXT_DIR/$(basename "$FILE")" CLEARTEXT_FILE="$CLEARTEXT_DIR/$(basename "$FILE")"
@ -169,6 +174,9 @@ function edit {
[ -f "$FILE" ] && [ "$EDITOR" != ":" ] && @diffBin@ -q "$CLEARTEXT_FILE.before" "$CLEARTEXT_FILE" && warn "$FILE wasn't changed, skipping re-encryption." && return [ -f "$FILE" ] && [ "$EDITOR" != ":" ] && @diffBin@ -q "$CLEARTEXT_FILE.before" "$CLEARTEXT_FILE" && warn "$FILE wasn't changed, skipping re-encryption." && return
ENCRYPT=() ENCRYPT=()
if [[ "$ARMOR" == "true" ]]; then
ENCRYPT+=(--armor)
fi
while IFS= read -r key while IFS= read -r key
do do
if [ -n "$key" ]; then if [ -n "$key" ]; then