mirror of
https://github.com/Mic92/sops-nix.git
synced 2026-05-13 16:38:45 +08:00
first commit
This commit is contained in:
commit
8ccd9ba269
19 changed files with 1237 additions and 0 deletions
8
pkgs/sops-shell-hook/default.nix
Normal file
8
pkgs/sops-shell-hook/default.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{ makeSetupHook, gnupg, sops }:
|
||||
|
||||
makeSetupHook {
|
||||
substitutions = {
|
||||
gpg = "${gnupg}/bin/gpg";
|
||||
};
|
||||
deps = [ sops ];
|
||||
} ./sops-shell-hook.bash
|
||||
23
pkgs/sops-shell-hook/sops-shell-hook.bash
Normal file
23
pkgs/sops-shell-hook/sops-shell-hook.bash
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
_sopsAddKey() {
|
||||
@gpg@ --quiet --import "$key"
|
||||
local fpr
|
||||
fpr=$(@gpg@ --with-fingerprint --with-colons --show-key "$key" \
|
||||
| awk -F: '$1 == "fpr" { print $10;}')
|
||||
export SOPS_PGP_FP=''${SOPS_PGP_FP}''${SOPS_PGP_FP:+','}$fpr
|
||||
}
|
||||
|
||||
sopsShellHook() {
|
||||
local key dir
|
||||
for key in $sopsGPGKeys; do
|
||||
_sopsAddKey "$key"
|
||||
done
|
||||
for dir in $sopsGPGKeyDirs; do
|
||||
while IFS= read -r -d '' key; do
|
||||
_sopsAddKey "$key"
|
||||
done < <(find "$dir" -type f -name '*.asc' -print0)
|
||||
done
|
||||
}
|
||||
|
||||
if [ -z "${shellHook-}" ]; then
|
||||
shellHook=sopsShellHook
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue