diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4a847d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d545218 --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1713254108, + "narHash": "sha256-0TZIsfDbHG5zibtlw6x0yOp3jkInIGaJ35B7Y4G8Pec=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2fd19c8be2551a61c1ddc3d9f86d748f4db94f00", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d0123f1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,20 @@ +{ + outputs = { self, nixpkgs }: { + packages.aarch64-darwin = let + pkgs = import nixpkgs { system = "aarch64-darwin"; }; + in { + default = pkgs.stdenv.mkDerivation { + name = "ssh-askpass-pinentry"; + src = ./.; + + inherit (pkgs) pinentry_mac; + + installPhase = '' + mkdir -p $out/libexec + substitute ./ssh-askpass $out/libexec/ssh-askpass --subst-var pinentry_mac + chmod +x $out/libexec/ssh-askpass + ''; + }; + }; + }; +} diff --git a/ssh-askpass b/ssh-askpass new file mode 100644 index 0000000..3b8d6c5 --- /dev/null +++ b/ssh-askpass @@ -0,0 +1,21 @@ +#!/bin/zsh + +PINENTRY=@pinentry_mac@/Applications/pinentry-mac.app/Contents/MacOS/pinentry-mac + +coproc $PINENTRY +PINENTRY_PID=$! +trap "kill -TERM $PINENTRY_PID" INT TERM +read -p + +print -p SETDESC $@ +read -p + +print -p SETOK Hide +read -p + +print -p CONFIRM --one-button +read -p + +# Close the coproc +coproc : +exit 1