summaryrefslogtreecommitdiffstats
path: root/tv/5pkgs/simple
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2021-01-18 21:13:46 +0100
committerlassulus <lassulus@lassul.us>2021-01-18 21:13:46 +0100
commitc39fea09607ec693055e0981c1a4b81a6c48ae83 (patch)
tree6bf9b971dfec7fc48f177f39c840bf8d2879f4ca /tv/5pkgs/simple
parent5b91fd162e20c054075f4535f69b6e51a8bdb952 (diff)
parent455ad96eca5d7c30b6115aeb81cc1c9b6f1321c8 (diff)
Merge remote-tracking branch 'ni/master'
Diffstat (limited to 'tv/5pkgs/simple')
-rw-r--r--tv/5pkgs/simple/pinentry-urxvt/default.nix56
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 0000000..65b76c0
--- /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
+ ''} \
+ "$@"
+ '';
+ }