mirror of
https://github.com/ryantm/agenix.git
synced 2024-11-22 17:50:48 +03:00
use nix-instantiate instead of nix eval
it has a more stable API
This commit is contained in:
parent
ac8d259fb9
commit
b381af08ec
1 changed files with 6 additions and 4 deletions
|
@ -23,7 +23,7 @@ function show_help () {
|
||||||
echo 'EDITOR environment variable of editor to use when editing FILE'
|
echo 'EDITOR environment variable of editor to use when editing FILE'
|
||||||
echo ' '
|
echo ' '
|
||||||
echo 'RULES environment variable with path to Nix file specifying recipient public keys.'
|
echo 'RULES environment variable with path to Nix file specifying recipient public keys.'
|
||||||
echo "Defaults to 'secrets.nix'"
|
echo "Defaults to './secrets.nix'"
|
||||||
}
|
}
|
||||||
|
|
||||||
test $# -eq 0 && (show_help && exit 1)
|
test $# -eq 0 && (show_help && exit 1)
|
||||||
|
@ -68,7 +68,7 @@ while test $# -gt 0; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
RULES=''${RULES:-secrets.nix}
|
RULES=''${RULES:-./secrets.nix}
|
||||||
|
|
||||||
function cleanup {
|
function cleanup {
|
||||||
if [ ! -z ''${CLEARTEXT_DIR+x} ]
|
if [ ! -z ''${CLEARTEXT_DIR+x} ]
|
||||||
|
@ -84,7 +84,8 @@ trap "cleanup" 0 2 3 15
|
||||||
|
|
||||||
function edit {
|
function edit {
|
||||||
FILE=$1
|
FILE=$1
|
||||||
KEYS=$(nix eval -f "$RULES" --raw "\"$FILE\".public_keys" --apply "builtins.concatStringsSep \"\n\"")
|
KEYS=$(nix-instantiate --eval -E "(let rules = import $RULES; in builtins.concatStringsSep \"\n\" rules.\"$FILE\".public_keys)" | sed 's/"//g' | sed 's/\\n/\n/g')
|
||||||
|
|
||||||
if [ -z "$KEYS" ]
|
if [ -z "$KEYS" ]
|
||||||
then
|
then
|
||||||
>&2 echo "There is no rule for $FILE in $RULES."
|
>&2 echo "There is no rule for $FILE in $RULES."
|
||||||
|
@ -125,7 +126,8 @@ function edit {
|
||||||
|
|
||||||
function rekey {
|
function rekey {
|
||||||
echo "rekeying..."
|
echo "rekeying..."
|
||||||
FILES=$(nix eval -f "$RULES" --raw --apply "f: builtins.concatStringsSep \"\n\" (builtins.attrNames f)")
|
FILES=$(nix-instantiate --eval -E "(let rules = import $RULES; in builtins.concatStringsSep \"\n\" (builtins.attrNames rules))" | sed 's/"//g' | sed 's/\\n/\n/g')
|
||||||
|
|
||||||
for FILE in $FILES
|
for FILE in $FILES
|
||||||
do
|
do
|
||||||
EDITOR=: edit $FILE
|
EDITOR=: edit $FILE
|
||||||
|
|
Loading…
Reference in a new issue