From c8d5411462257fa751e99808ee813fbc5a932bbc Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 7 Jun 2023 07:02:34 +0000 Subject: [PATCH] sane-scripts: port sane-secrets-* to nix-shell --- pkgs/additional/sane-scripts/default.nix | 17 +++++++++++++++-- .../sane-scripts/src/sane-secrets-dump | 3 ++- .../sane-scripts/src/sane-secrets-unlock | 3 ++- .../sane-scripts/src/sane-secrets-update-keys | 3 ++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pkgs/additional/sane-scripts/default.nix b/pkgs/additional/sane-scripts/default.nix index 1d0f83fe..6c3327c9 100644 --- a/pkgs/additional/sane-scripts/default.nix +++ b/pkgs/additional/sane-scripts/default.nix @@ -35,7 +35,6 @@ let inetutils iwd jq - oath-toolkit openssh openssl nix-shell-scripts.ip-check @@ -77,7 +76,6 @@ let "cannot:${gocryptfs}/bin/gocryptfs" "cannot:${ifuse}/bin/ifuse" "cannot:${iwd}/bin/iwctl" - "cannot:${oath-toolkit}/bin/oathtool" "cannot:${openssh}/bin/ssh-keygen" "cannot:${rmlint}/bin/rmlint" "cannot:${rsync}/bin/rsync" @@ -238,6 +236,21 @@ let pname = "sane-reclaim-boot-space"; src = ./src; }; + secrets-dump = static-nix-shell.mkBash { + pname = "sane-secrets-dump"; + src = ./src; + pkgs = [ "gnugrep" "sops" "oath-toolkit" ]; + }; + secrets-unlock = static-nix-shell.mkBash { + pname = "sane-secrets-unlock"; + src = ./src; + pkgs = [ "coreutils-full" "openssh" "ssh-to-age" ]; + }; + secrets-update-keys = static-nix-shell.mkBash { + pname = "sane-secrets-update-keys"; + src = ./src; + pkgs = [ "coreutils-full" "findutils" "sops" ]; + }; }; in symlinkJoin { diff --git a/pkgs/additional/sane-scripts/src/sane-secrets-dump b/pkgs/additional/sane-scripts/src/sane-secrets-dump index cb696e7b..d19f9021 100755 --- a/pkgs/additional/sane-scripts/src/sane-secrets-dump +++ b/pkgs/additional/sane-scripts/src/sane-secrets-dump @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p gnugrep -p oath-toolkit -p sops # use: `sane-dump-secret /path/to/accounts/website.yaml` # dumps relevant information about the account, include a OTP code if present secrets=$(sops -d --output-type dotenv $1) diff --git a/pkgs/additional/sane-scripts/src/sane-secrets-unlock b/pkgs/additional/sane-scripts/src/sane-secrets-unlock index a767a346..efdbfaf0 100755 --- a/pkgs/additional/sane-scripts/src/sane-secrets-unlock +++ b/pkgs/additional/sane-scripts/src/sane-secrets-unlock @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p coreutils-full -p openssh -p ssh-to-age # unlocks the SOPS store (i.e. populate a SOPS key from the user's SSH key) set -ex diff --git a/pkgs/additional/sane-scripts/src/sane-secrets-update-keys b/pkgs/additional/sane-scripts/src/sane-secrets-update-keys index 390438b9..7d0938b4 100755 --- a/pkgs/additional/sane-scripts/src/sane-secrets-update-keys +++ b/pkgs/additional/sane-scripts/src/sane-secrets-update-keys @@ -1,4 +1,5 @@ -#!/usr/bin/env bash +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p coreutils-full -p findutils -p sops # after modifying .sops.yaml, run this to re-encode all secrets to the new keys # pass the base directory (under which *everything* is a secret) as argument for i in $(find "$1" -print)