about summary refs log tree commit diff stats
path: root/home-manager/config/lf/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager/config/lf/default.nix')
-rw-r--r--home-manager/config/lf/default.nix258
1 files changed, 224 insertions, 34 deletions
diff --git a/home-manager/config/lf/default.nix b/home-manager/config/lf/default.nix
index 5330f39f..1eb0cd6d 100644
--- a/home-manager/config/lf/default.nix
+++ b/home-manager/config/lf/default.nix
@@ -1,16 +1,73 @@
 {
   config,
   pkgs,
+  sysLib,
   ...
 }: let
-  shell = file:
-    "\${{" + builtins.readFile "${file}" + "}}"; # closes the lf tui
-  pipe = file:
-    "%{{" + builtins.readFile "${file}" + "}}"; # runs the command in the ui,term bar
-  async = file:
-    "&{{" + builtins.readFile "${file}" + "}}"; # runs the command in the background
-  wait = file:
-    "!{{" + builtins.readFile "${file}" + "}}"; # adds a prompt after the command has run
+  shell = {
+    file,
+    dependencies,
+    ...
+  }: ''
+    ''${{
+    ${
+      builtins.readFile (sysLib.makeShellScriptWithLibrary {
+          name = "NAME_FOR_A_SHELL_SCRIPT";
+          script = file;
+          inherit dependencies;
+        }
+        + /bin/NAME_FOR_A_SHELL_SCRIPT)
+    }
+    }}
+  ''; # closes the lf tui
+  pipe = {
+    file,
+    dependencies,
+    ...
+  }: ''
+    %{{
+    ${
+      builtins.readFile (sysLib.makeShellScriptWithLibrary {
+          name = "NAME_FOR_A_SHELL_SCRIPT";
+          script = file;
+          inherit dependencies;
+        }
+        + /bin/NAME_FOR_A_SHELL_SCRIPT)
+    }
+    }}
+  ''; # runs the command in the ui/term bar
+  async = {
+    file,
+    dependencies,
+    ...
+  }: ''
+    &{{
+    ${
+      builtins.readFile (sysLib.makeShellScriptWithLibrary {
+          name = "NAME_FOR_A_SHELL_SCRIPT";
+          script = file;
+          inherit dependencies;
+        }
+        + /bin/NAME_FOR_A_SHELL_SCRIPT)
+    }
+    }}
+  ''; # runs the command in the background
+  wait = {
+    file,
+    dependencies,
+    ...
+  }: ''
+    !{{
+    ${
+      builtins.readFile (sysLib.makeShellScriptWithLibrary {
+          name = "NAME_FOR_A_SHELL_SCRIPT";
+          script = file;
+          inherit dependencies;
+        }
+        + /bin/NAME_FOR_A_SHELL_SCRIPT)
+    }
+    }}
+  ''; # adds a prompt after the command has run
 in {
   xdg.configFile."lf/icons".source = ./icons;
   xdg.configFile."lf/colors".source = ./colors;
@@ -19,32 +76,165 @@ in {
     enable = true;
 
     commands = {
-      help = shell ./cmds/help.sh;
-      open = shell ./cmds/open.sh;
-      mk_dir = pipe ./cmds/mk_dir.sh;
-      mk_scr = shell ./cmds/mk_scr.sh;
-      mk_file = shell ./cmds/mk_file.sh;
-      chmod = pipe ./cmds/chmod.sh;
-      mk_ln = shell ./cmds/mk_ln.sh; # TODO could be pipe, right?
-      sudo_mk_file = shell ./cmds/sudo_mk_file.sh;
-      set_wall_paper = pipe ./cmds/set_wall_paper.sh;
-      fzf_jump = shell ./cmds/fzf_jump.sh;
-      broot_jump = shell ./cmds/broot_jump.sh;
-      open_config = shell ./cmds/open_config.sh;
-
-      dragon = pipe ./cmds/dragon.sh;
-      dragon_stay = pipe ./cmds/dragon_stay.sh;
-      dragon_individual = pipe ./cmds/dragon_individual.sh;
-      dl_file = pipe ./cmds/dl_file.sh;
-
-      unarchive = pipe ./cmds/unarchive.sh;
-      archive = pipe ./cmds/archive.sh;
-
-      trash = pipe ./cmds/trash.sh;
-      clear_trash = pipe ./cmds/clear_trash.sh;
-      restore_trash = shell ./cmds/restore_trash.sh;
-
-      stripspace = pipe ./cmds/stripspace.sh;
+      help = shell {
+        file = ./cmds/help.sh;
+        dependencies = [];
+      };
+      open = shell {
+        file = ./cmds/open.sh;
+        dependencies = [];
+      };
+      mk_dir = pipe {
+        file = ./cmds/mk_dir.sh;
+        dependencies = [];
+      };
+      mk_scr = shell {
+        file = ./cmds/mk_scr.sh;
+        dependencies = [];
+      };
+      mk_file = shell {
+        file = ./cmds/mk_file.sh;
+        dependencies = [];
+      };
+      chmod = pipe {
+        file = ./cmds/chmod.sh;
+        dependencies = [];
+      };
+      mk_ln = pipe {
+        file = ./cmds/mk_ln.sh;
+        dependencies = [];
+      };
+      sudo_mk_file = shell {
+        file = ./cmds/sudo_mk_file.sh;
+        dependencies = [];
+      };
+      set_wall_paper = pipe {
+        file = ./cmds/set_wall_paper.sh;
+        dependencies = [];
+      };
+      fzf_jump = shell {
+        file = ./cmds/fzf_jump.sh;
+        dependencies = builtins.attrValues {
+          inherit (pkgs) fzf;
+        };
+      };
+      broot_jump = shell {
+        file = ./cmds/broot_jump.sh;
+        dependencies = builtins.attrValues {
+          inherit (pkgs) broot;
+        };
+      };
+      open_config = shell {
+        file = ./cmds/open_config.sh;
+        dependencies = builtins.attrValues {
+          #inherit
+          #(pkgs)
+          ## TODO rewrite this:  bookmenu, https://github.com/jarun/buku
+          #
+          #buku
+          #;
+        };
+      };
+
+      dragon = pipe {
+        file = ./cmds/dragon.sh;
+        dependencies = builtins.attrValues {
+          inherit
+            (pkgs)
+            xdragon
+            ;
+        };
+      };
+      dragon_stay = pipe {
+        file = ./cmds/dragon_stay.sh;
+        dependencies = builtins.attrValues {
+          inherit
+            (pkgs)
+            xdragon
+            ;
+        };
+      };
+      dragon_individual = pipe {
+        file = ./cmds/dragon_individual.sh;
+        dependencies = builtins.attrValues {
+          inherit
+            (pkgs)
+            xdragon
+            ;
+        };
+      };
+      dl_file = pipe {
+        file = ./cmds/dl_file.sh;
+        dependencies = builtins.attrValues {
+          inherit
+            (pkgs)
+            xdragon
+            curl
+            ;
+        };
+      };
+
+      unarchive = pipe {
+        file = ./cmds/unarchive.sh;
+        dependencies = builtins.attrValues {
+          inherit
+            (pkgs)
+            gnutar
+            unzip
+            # TODO this is unfree! unrar
+
+            p7zip
+            ;
+        };
+      };
+      archive = pipe {
+        file = ./cmds/archive.sh;
+        dependencies = builtins.attrValues {
+          inherit
+            (pkgs)
+            fzf
+            gnutar
+            xz
+            p7zip
+            zip
+            ;
+        };
+      };
+
+      trash = pipe {
+        file = ./cmds/trash.sh;
+        dependencies = builtins.attrValues {
+          inherit
+            (pkgs)
+            trashy
+            ;
+        };
+      };
+      clear_trash = pipe {
+        file = ./cmds/clear_trash.sh;
+        dependencies = builtins.attrValues {
+          inherit
+            (pkgs)
+            fzf
+            trashy
+            ;
+        };
+      };
+      restore_trash = shell {
+        file = ./cmds/restore_trash.sh;
+        dependencies = builtins.attrValues {
+          inherit
+            (pkgs)
+            fzf
+            trashy
+            ;
+        };
+      };
+
+      stripspace = pipe {
+        file = ./cmds/stripspace.sh;
+        dependencies = [];
+      };
     };
     keybindings = {
       # Remove some defaults