From b7f21925de63a03eec47aa42e206d0a5cdb82f2d Mon Sep 17 00:00:00 2001
From: tv <tv@krebsco.de>
Date: Sat, 5 Mar 2022 09:00:16 +0100
Subject: tv pkgs: move fzf to override

---
 tv/5pkgs/override/default.nix         |  7 -----
 tv/5pkgs/override/fzf.complete1.patch | 55 -----------------------------------
 tv/5pkgs/override/fzf/complete1.patch | 55 +++++++++++++++++++++++++++++++++++
 tv/5pkgs/override/fzf/default.nix     |  9 ++++++
 4 files changed, 64 insertions(+), 62 deletions(-)
 delete mode 100644 tv/5pkgs/override/fzf.complete1.patch
 create mode 100644 tv/5pkgs/override/fzf/complete1.patch
 create mode 100644 tv/5pkgs/override/fzf/default.nix

diff --git a/tv/5pkgs/override/default.nix b/tv/5pkgs/override/default.nix
index dc8fc5907..8a0c10872 100644
--- a/tv/5pkgs/override/default.nix
+++ b/tv/5pkgs/override/default.nix
@@ -1,12 +1,5 @@
 with import <stockholm/lib>;
 self: super: {
-  fzf = super.fzf.overrideAttrs (old: {
-    # XXX cannot use `patches` because fzf has a custom patchPhase
-    patchPhase = ''
-      patch -Np1 < ${./fzf.complete1.patch}
-      ${old.patchPhase or ""}
-    '';
-  });
   input-fonts = super.input-fonts.overrideAttrs (old: rec {
     src = self.fetchzip {
       url = "http://xu.r/~tv/mirrors/input-fonts/Input-Font-2.zip";
diff --git a/tv/5pkgs/override/fzf.complete1.patch b/tv/5pkgs/override/fzf.complete1.patch
deleted file mode 100644
index 4b2126a2c..000000000
--- a/tv/5pkgs/override/fzf.complete1.patch
+++ /dev/null
@@ -1,55 +0,0 @@
-diff --git a/src/core.go b/src/core.go
-index a18c3a1..a3d92a4 100644
---- a/src/core.go
-+++ b/src/core.go
-@@ -331,6 +331,13 @@ func Run(opts *Options, version string, revision string) {
- 							}
- 						}
- 						terminal.UpdateList(val, clearSelection())
-+						if (opts.Complete1) {
-+							count := val.Length()
-+							if count == 1 {
-+								opts.Printer(val.Get(0).item.AsString(opts.Ansi))
-+								terminal.reqBox.Set(reqClose, nil)
-+							}
-+						}
- 					}
- 				}
- 			}
-diff --git a/src/options.go b/src/options.go
-index a55dc34..7f121cd 100644
---- a/src/options.go
-+++ b/src/options.go
-@@ -92,6 +92,7 @@ const usage = `usage: fzf [options]
-     -1, --select-1        Automatically select the only match
-     -0, --exit-0          Exit immediately when there's no match
-     -f, --filter=STR      Filter mode. Do not start interactive finder.
-+    --complete-1          Exit interactive finder when there's exactly one match
-     --print-query         Print query as the first line
-     --expect=KEYS         Comma-separated list of keys to complete fzf
-     --read0               Read input delimited by ASCII NUL characters
-@@ -208,6 +209,7 @@ type Options struct {
- 	Query       string
- 	Select1     bool
- 	Exit0       bool
-+	Complete1   bool
- 	Filter      *string
- 	ToggleSort  bool
- 	Expect      map[tui.Event]string
-@@ -269,6 +271,7 @@ func defaultOptions() *Options {
- 		Query:       "",
- 		Select1:     false,
- 		Exit0:       false,
-+		Complete1:   false,
- 		Filter:      nil,
- 		ToggleSort:  false,
- 		Expect:      make(map[tui.Event]string),
-@@ -1311,6 +1314,8 @@ func parseOptions(opts *Options, allArgs []string) {
- 			opts.Exit0 = true
- 		case "+0", "--no-exit-0":
- 			opts.Exit0 = false
-+		case "--complete-1":
-+			opts.Complete1 = true
- 		case "--read0":
- 			opts.ReadZero = true
- 		case "--no-read0":
diff --git a/tv/5pkgs/override/fzf/complete1.patch b/tv/5pkgs/override/fzf/complete1.patch
new file mode 100644
index 000000000..4b2126a2c
--- /dev/null
+++ b/tv/5pkgs/override/fzf/complete1.patch
@@ -0,0 +1,55 @@
+diff --git a/src/core.go b/src/core.go
+index a18c3a1..a3d92a4 100644
+--- a/src/core.go
++++ b/src/core.go
+@@ -331,6 +331,13 @@ func Run(opts *Options, version string, revision string) {
+ 							}
+ 						}
+ 						terminal.UpdateList(val, clearSelection())
++						if (opts.Complete1) {
++							count := val.Length()
++							if count == 1 {
++								opts.Printer(val.Get(0).item.AsString(opts.Ansi))
++								terminal.reqBox.Set(reqClose, nil)
++							}
++						}
+ 					}
+ 				}
+ 			}
+diff --git a/src/options.go b/src/options.go
+index a55dc34..7f121cd 100644
+--- a/src/options.go
++++ b/src/options.go
+@@ -92,6 +92,7 @@ const usage = `usage: fzf [options]
+     -1, --select-1        Automatically select the only match
+     -0, --exit-0          Exit immediately when there's no match
+     -f, --filter=STR      Filter mode. Do not start interactive finder.
++    --complete-1          Exit interactive finder when there's exactly one match
+     --print-query         Print query as the first line
+     --expect=KEYS         Comma-separated list of keys to complete fzf
+     --read0               Read input delimited by ASCII NUL characters
+@@ -208,6 +209,7 @@ type Options struct {
+ 	Query       string
+ 	Select1     bool
+ 	Exit0       bool
++	Complete1   bool
+ 	Filter      *string
+ 	ToggleSort  bool
+ 	Expect      map[tui.Event]string
+@@ -269,6 +271,7 @@ func defaultOptions() *Options {
+ 		Query:       "",
+ 		Select1:     false,
+ 		Exit0:       false,
++		Complete1:   false,
+ 		Filter:      nil,
+ 		ToggleSort:  false,
+ 		Expect:      make(map[tui.Event]string),
+@@ -1311,6 +1314,8 @@ func parseOptions(opts *Options, allArgs []string) {
+ 			opts.Exit0 = true
+ 		case "+0", "--no-exit-0":
+ 			opts.Exit0 = false
++		case "--complete-1":
++			opts.Complete1 = true
+ 		case "--read0":
+ 			opts.ReadZero = true
+ 		case "--no-read0":
diff --git a/tv/5pkgs/override/fzf/default.nix b/tv/5pkgs/override/fzf/default.nix
new file mode 100644
index 000000000..661db0ed5
--- /dev/null
+++ b/tv/5pkgs/override/fzf/default.nix
@@ -0,0 +1,9 @@
+self: super:
+
+super.fzf.overrideAttrs (old: {
+  # XXX cannot use `patches` because fzf has a custom patchPhase
+  patchPhase = ''
+    patch -Np1 < ${./complete1.patch}
+    ${old.patchPhase or ""}
+  '';
+})
-- 
cgit v1.2.3