pkgs/clerie-sops: Add clerie-sops-edit for working with multiline string attributes in json
This commit is contained in:
parent
3371f47f68
commit
2970a7d892
@ -16,6 +16,7 @@
|
|||||||
colmena
|
colmena
|
||||||
agenix
|
agenix
|
||||||
clerie-sops
|
clerie-sops
|
||||||
|
clerie-sops-edit
|
||||||
sops
|
sops
|
||||||
|
|
||||||
# Debugging
|
# Debugging
|
||||||
|
@ -132,6 +132,7 @@
|
|||||||
clerie-update-nixfiles
|
clerie-update-nixfiles
|
||||||
clerie-sops
|
clerie-sops
|
||||||
clerie-sops-config
|
clerie-sops-config
|
||||||
|
clerie-sops-edit
|
||||||
chromium-incognito
|
chromium-incognito
|
||||||
iot-data
|
iot-data
|
||||||
nix-remove-result-links
|
nix-remove-result-links
|
||||||
|
10
pkgs/clerie-sops/clerie-sops-edit.nix
Normal file
10
pkgs/clerie-sops/clerie-sops-edit.nix
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "clerie-sops-edit";
|
||||||
|
text = builtins.readFile ./clerie-sops-edit.sh;
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
clerie-sops
|
||||||
|
jq
|
||||||
|
];
|
||||||
|
}
|
25
pkgs/clerie-sops/clerie-sops-edit.sh
Executable file
25
pkgs/clerie-sops/clerie-sops-edit.sh
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Edit a single attribute of a sops json file
|
||||||
|
# Helps working with multiline strings in json
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SECRETS_FILE="$1"
|
||||||
|
KEY="$2"
|
||||||
|
|
||||||
|
if [[ -n $EDITOR ]]; then
|
||||||
|
EDITOR=vim
|
||||||
|
fi
|
||||||
|
|
||||||
|
TMP_FILE="$(mktemp)"
|
||||||
|
|
||||||
|
clerie-sops --decrypt --extract "[\"${KEY}\"]" "${SECRETS_FILE}" > "${TMP_FILE}"
|
||||||
|
|
||||||
|
vim "${TMP_FILE}"
|
||||||
|
|
||||||
|
JSON_QUOTED_SECRET="$(jq -Rs '.' "${TMP_FILE}")"
|
||||||
|
|
||||||
|
rm "${TMP_FILE}"
|
||||||
|
|
||||||
|
clerie-sops --set "[\"${KEY}\"] ${JSON_QUOTED_SECRET}" "${SECRETS_FILE}"
|
@ -4,6 +4,7 @@ final: prev: {
|
|||||||
clerie-merge-nixfiles-update = final.callPackage ./clerie-update-nixfiles/clerie-merge-nixfiles-update.nix {};
|
clerie-merge-nixfiles-update = final.callPackage ./clerie-update-nixfiles/clerie-merge-nixfiles-update.nix {};
|
||||||
clerie-sops = final.callPackage ./clerie-sops/clerie-sops.nix {};
|
clerie-sops = final.callPackage ./clerie-sops/clerie-sops.nix {};
|
||||||
clerie-sops-config = final.callPackage ./clerie-sops/clerie-sops-config.nix {};
|
clerie-sops-config = final.callPackage ./clerie-sops/clerie-sops-config.nix {};
|
||||||
|
clerie-sops-edit = final.callPackage ./clerie-sops/clerie-sops-edit.nix {};
|
||||||
clerie-update-nixfiles = final.callPackage ./clerie-update-nixfiles/clerie-update-nixfiles.nix {};
|
clerie-update-nixfiles = final.callPackage ./clerie-update-nixfiles/clerie-update-nixfiles.nix {};
|
||||||
chromium-incognito = final.callPackage ./chromium-incognito {};
|
chromium-incognito = final.callPackage ./chromium-incognito {};
|
||||||
iot-data = final.python3.pkgs.callPackage ./iot-data {};
|
iot-data = final.python3.pkgs.callPackage ./iot-data {};
|
||||||
|
Loading…
Reference in New Issue
Block a user