mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 12:51:34 +01:00
sops: Ensure BW_SESSION and SOPS_AGE_KEY are only fetched if not already defined
This commit is contained in:
parent
e3479f2070
commit
312036e7a7
2 changed files with 14 additions and 7 deletions
|
|
@ -37,10 +37,14 @@ _: {
|
|||
echo "$new_age_key" > "hosts/$host/keys/age.pub"
|
||||
|
||||
echo "==> Updating SOPS secrets..."
|
||||
if ! declare -px BW_SESSION >/dev/null 2>&1; then
|
||||
BW_SESSION="$(bw unlock --raw || bw login --raw)"
|
||||
export BW_SESSION
|
||||
fi
|
||||
if ! declare -px SOPS_AGE_KEY >/dev/null 2>&1; then
|
||||
SOPS_AGE_KEY="$(bw get notes 'admin age-key')"
|
||||
export SOPS_AGE_KEY
|
||||
fi
|
||||
SOPS_CONFIG="$(nix build .#sops-config --print-out-paths)"
|
||||
export SOPS_CONFIG
|
||||
sops updatekeys --yes "hosts/$host/secrets.json"
|
||||
|
|
|
|||
|
|
@ -49,11 +49,14 @@
|
|||
|
||||
nativeBuildInputs = [ pkgs.bitwarden-cli ];
|
||||
shellHook = ''
|
||||
if BW_SESSION="$(bw unlock --raw || bw login --raw)"; then
|
||||
if ! declare -px BW_SESSION >/dev/null 2>&1; then
|
||||
BW_SESSION="$(bw unlock --raw || bw login --raw)"
|
||||
export BW_SESSION
|
||||
fi
|
||||
if ! declare -px SOPS_AGE_KEY >/dev/null 2>&1; then
|
||||
SOPS_AGE_KEY="$(bw get notes 'admin age-key')"
|
||||
export SOPS_AGE_KEY
|
||||
fi
|
||||
SOPS_CONFIG="${self'.packages.sops-config}"
|
||||
export SOPS_CONFIG
|
||||
'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue