diff options
author | tv <tv@krebsco.de> | 2021-01-13 04:54:29 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2021-01-13 04:54:29 +0100 |
commit | e7116bc68ea2e15d67f3ece21ff3bccafc5b58b4 (patch) | |
tree | 84b3f5ff0e59eabecbc6366f5e6288fd75a1dcde /tv | |
parent | 2aab7aea07d469f60fdfb662b75f707dc70c86a8 (diff) |
tv pinentry-urxvt: init
Diffstat (limited to 'tv')
-rw-r--r-- | tv/5pkgs/simple/pinentry-urxvt/default.nix | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tv/5pkgs/simple/pinentry-urxvt/default.nix b/tv/5pkgs/simple/pinentry-urxvt/default.nix new file mode 100644 index 000000000..65b76c077 --- /dev/null +++ b/tv/5pkgs/simple/pinentry-urxvt/default.nix @@ -0,0 +1,56 @@ +{ pkgs, ... }@args: + +let + lib = import <stockholm/lib>; + + # config cannot be declared in the input attribute set because that would + # cause callPackage to inject the wrong config. Instead, get it from ... + # via args. + config = args.config or {}; + + cfg = eval.config; + + eval = lib.evalModules { + modules = lib.singleton { + _file = toString ./default.nix; + imports = lib.singleton config; + options = { + appName = lib.mkOption { + default = "pinentry-urxvt"; + type = lib.types.str; + }; + display = lib.mkOption { + default = ":0"; + type = lib.types.str; + }; + }; + }; + }; + + +in + + pkgs.write "pinentry-urxvt" { + "/bin/pinentry".link = pkgs.writeDash "pinentry-urxvt-wrapper" '' + set -efu + exec 3<&0 4>&1 5>&2 + export DISPLAY=${lib.shell.escape cfg.display} + exec ${pkgs.rxvt_unicode}/bin/urxvt \ + -name ${lib.shell.escape cfg.appName} \ + -e ${pkgs.writeDash "pinentry-urxvt-tty" '' + set -efu + exec 2>&5 + TTY=$(${pkgs.coreutils}/bin/tty) + while read -r line <&3; do + case $line in + 'OPTION ttyname='*) + echo "OPTION ttyname=$TTY" + ;; + *) + echo "$line" + esac + done | ${pkgs.pinentry.tty}/bin/pinentry-tty "$@" >&4 + ''} \ + "$@" + ''; + } |