#!/usr/bin/env bash
set -euo pipefail
set -x
NIX_RULES="$(readlink -f ./.sops.nix)"
SOPS_RULES="/tmp/sopsnix_$(pwd | sha1sum | cut -d' ' -f1)"
nix eval --json -v -f $NIX_RULES --apply 'creation_rules: if builtins.isList creation_rules then { inherit creation_rules; } else throw "Unknown format for secrets.nix"' | yq -r . > "$SOPS_RULES.$$"
if ! diff --color -uN $SOPS_RULES $SOPS_RULES.$$; then
mv $SOPS_RULES.$$ $SOPS_RULES
else
rm $SOPS_RULES.$$
fi
SOPS_CONFIG="$SOPS_RULES" exec sops "$@"
something like that, so that we could be able to declare the secrets settings / keys directly from Nix
or I may have missed something about the module
something like that, so that we could be able to declare the secrets settings / keys directly from Nix
or I may have missed something about the module