From 0f53134dba587f883f2b3fc1cf8b9b9d7be7b8ef Mon Sep 17 00:00:00 2001 From: Joey Hafner Date: Tue, 31 Dec 2024 10:49:33 -0800 Subject: [PATCH] Script WIP --- .../desktop/scripts/init-keys.nix | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 dotfiles/home-manager/desktop/scripts/init-keys.nix diff --git a/dotfiles/home-manager/desktop/scripts/init-keys.nix b/dotfiles/home-manager/desktop/scripts/init-keys.nix new file mode 100644 index 00000000..828008df --- /dev/null +++ b/dotfiles/home-manager/desktop/scripts/init-keys.nix @@ -0,0 +1,31 @@ +{ pkgs, ... }: { + home.packages = with pkgs; [ + ( writeShellApplication { + name = "init-keys"; + runtimeInputs = [ + ssh-to-age + ]; + text = '' + #!/bin/bash + + # Asserts all keys are where they belong. + + assert() { + TEST_FILE="$1" + FILE_HASH="$2" + + if [ ! -f "$1" ]; then + echo "Error: Missing file $1" + exit 1 + fi + + TEST_HASH="$(sha256sum "$TEST_FILE" | cut -d' ' -f1)" + if [ ! "$HASH" == "$FILE_HASH" ]; then + echo "Error: File hash mismatch $1" + exit 1 + fi + } + ''; + } ) + ]; +}