about summary refs log tree commit diff
path: root/overlays/personal
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-02-27 01:38:45 +0000
committerAlyssa Ross <hi@alyssa.is>2021-02-27 12:17:38 +0000
commitcbef58013d4ab9511dfbc78bebbf4d8b57597e55 (patch)
tree89a85bcd0252ab9929c80bd6e557c1f924622f36 /overlays/personal
parent94bd891bc69cf23eebb4cd33b44cf24fb3c29fb1 (diff)
downloadnixlib-cbef58013d4ab9511dfbc78bebbf4d8b57597e55.tar
nixlib-cbef58013d4ab9511dfbc78bebbf4d8b57597e55.tar.gz
nixlib-cbef58013d4ab9511dfbc78bebbf4d8b57597e55.tar.bz2
nixlib-cbef58013d4ab9511dfbc78bebbf4d8b57597e55.tar.lz
nixlib-cbef58013d4ab9511dfbc78bebbf4d8b57597e55.tar.xz
nixlib-cbef58013d4ab9511dfbc78bebbf4d8b57597e55.tar.zst
nixlib-cbef58013d4ab9511dfbc78bebbf4d8b57597e55.zip
overlays/personal: rename from overlays/scripts
This is a better name, because the purpose of this overlay is to
collect packages that I won't upstream to Nixpkgs because they package
software I wrote, that probably nobody else is interested in running,
whether they're scripts or not.
Diffstat (limited to 'overlays/personal')
-rw-r--r--overlays/personal/choose/choose.in20
-rw-r--r--overlays/personal/choose/choosebin.in17
-rw-r--r--overlays/personal/choose/default.nix8
-rw-r--r--overlays/personal/default.nix3
4 files changed, 48 insertions, 0 deletions
diff --git a/overlays/personal/choose/choose.in b/overlays/personal/choose/choose.in
new file mode 100644
index 000000000000..7f60b47386a3
--- /dev/null
+++ b/overlays/personal/choose/choose.in
@@ -0,0 +1,20 @@
+#! @execline@/bin/execlineb -S0
+
+define -s fzf_opts "--reverse"
+
+ifelse { importas -i _ DISPLAY }
+{
+  alacritty --class float -e
+  getpid my_pid
+  importas -i -u my_pid my_pid
+  backtick -i -n term_pid { awk "{print $4}" /proc/${my_pid}/stat }
+  importas -i -u term_pid term_pid
+  redirfd -r 0 /proc/${term_pid}/fd/0
+  redirfd -w 1 /proc/${term_pid}/fd/1
+  @fzf@/bin/fzf $fzf_opts $@
+}
+
+ifelse { importas -i _ TMUX }
+{ @fzf@/bin/fzf-tmux $fzf_opts $@ }
+
+@fzf@/bin/fzf $fzf_opts $@
diff --git a/overlays/personal/choose/choosebin.in b/overlays/personal/choose/choosebin.in
new file mode 100644
index 000000000000..7f8ea520c994
--- /dev/null
+++ b/overlays/personal/choose/choosebin.in
@@ -0,0 +1,17 @@
+#! @execline@/bin/execlineb -S0
+
+backtick -i entry_points {
+  importas PATH PATH
+  heredoc 0 $PATH
+  tr : " "
+}
+importas -s -i -u entry_points entry_points
+
+pipeline {
+  redirfd -w 2 /dev/null
+  find -L $entry_points -mindepth 1 -maxdepth 1 -executable -type f
+}
+
+pipeline { awk -F / "{print $NF}" }
+
+@out@/bin/choose --prompt "$ " $@
diff --git a/overlays/personal/choose/default.nix b/overlays/personal/choose/default.nix
new file mode 100644
index 000000000000..d4e845f8b967
--- /dev/null
+++ b/overlays/personal/choose/default.nix
@@ -0,0 +1,8 @@
+{ runCommand, makeWrapper, execline, fzf }:
+
+runCommand "choose" { inherit execline fzf; } ''
+  install -d $out/bin
+  substituteAll ${./choose.in} $out/bin/choose
+  substituteAll ${./choosebin.in} $out/bin/choosebin
+  chmod +x $out/bin/*
+''
diff --git a/overlays/personal/default.nix b/overlays/personal/default.nix
new file mode 100644
index 000000000000..983d32d867a4
--- /dev/null
+++ b/overlays/personal/default.nix
@@ -0,0 +1,3 @@
+self: super: {
+  choose = self.callPackage ./choose { };
+}