diff options
author | Soispha <soispha@vhack.eu> | 2023-08-26 23:42:21 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-08-26 23:42:21 +0200 |
commit | 3f600ab07dbad3b6dd7655587ddea158b19aea71 (patch) | |
tree | 7164ccd965e1d14ade970aeb8eb188b1442a6c91 /hm/soispha/conf/lf/commands/default.nix | |
parent | Style(treewide): Format all lua-files makes lua ➛ nix easier (diff) | |
download | nixos-config-3f600ab07dbad3b6dd7655587ddea158b19aea71.zip |
Refactor(treewide): Abbreviate path names
Diffstat (limited to 'hm/soispha/conf/lf/commands/default.nix')
-rw-r--r-- | hm/soispha/conf/lf/commands/default.nix | 241 |
1 files changed, 241 insertions, 0 deletions
diff --git a/hm/soispha/conf/lf/commands/default.nix b/hm/soispha/conf/lf/commands/default.nix new file mode 100644 index 00000000..a52cb2f0 --- /dev/null +++ b/hm/soispha/conf/lf/commands/default.nix @@ -0,0 +1,241 @@ +{ + pkgs, + sysLib, + shell_library, + system, + lf_rename, + ... +}: let + functionCall = { + file, + dependencies, + replacementStrings, + ... + }: + sysLib.writeShellScriptWithLibraryAndKeepPath { + name = "${builtins.baseNameOf file}"; + src = file; + dependencies = dependencies ++ (builtins.attrValues {inherit (pkgs) dash coreutils;}); + inherit replacementStrings; + } + + "/bin/${builtins.baseNameOf file}"; + + shell = { + file, + dependencies, + replacementStrings ? null, + ... + }: '' + ''${{ + ${functionCall {inherit file dependencies replacementStrings;}} + }} + ''; # closes the lf tui + pipe = { + file, + dependencies, + replacementStrings ? null, + ... + }: '' + %{{ + ${functionCall {inherit file dependencies replacementStrings;}} + }} + ''; # runs the command in the ui/term bar + async = { + file, + dependencies, + replacementStrings ? null, + ... + }: '' + &{{ + ${functionCall {inherit file dependencies replacementStrings;}} + }} + ''; # runs the command in the background + wait = { + file, + dependencies, + replacementStrings ? null, + ... + }: '' + !{{ + ${functionCall {inherit file dependencies replacementStrings;}} + }} + ''; # adds a prompt after the command has run +in { + archive = shell { + file = ./scripts/archive; + dependencies = builtins.attrValues { + inherit + (pkgs) + fzf + gnutar + xz + p7zip + zip + ; + }; + }; + broot_jump = shell { + file = ./scripts/broot_jump; + dependencies = builtins.attrValues { + inherit (pkgs) broot; + }; + }; + chmod = pipe { + file = ./scripts/chmod; + dependencies = []; + }; + clear_trash = shell { + file = ./scripts/clear_trash; + dependencies = builtins.attrValues { + inherit + (pkgs) + fzf + trashy + ; + }; + }; + dl_file = pipe { + file = ./scripts/dl_file; + dependencies = builtins.attrValues { + inherit + (pkgs) + xdragon + curl + ; + }; + }; + dragon = pipe { + file = ./scripts/dragon; + dependencies = builtins.attrValues { + inherit + (pkgs) + xdragon + ; + }; + }; + dragon_individual = pipe { + file = ./scripts/dragon_individual; + dependencies = builtins.attrValues { + inherit + (pkgs) + xdragon + ; + }; + }; + dragon_stay = pipe { + file = ./scripts/dragon_stay; + dependencies = builtins.attrValues { + inherit + (pkgs) + xdragon + ; + }; + }; + fzf_jump = shell { + file = ./scripts/fzf_jump; + dependencies = builtins.attrValues { + inherit (pkgs) fzf lf gnused; + }; + }; + mk_dir = pipe { + file = ./scripts/mk_dir; + dependencies = []; + }; + mk_file = shell { + file = ./scripts/mk_file; + dependencies = []; + }; + mk_file_and_edit = shell { + file = ./scripts/mk_file_and_edit; + dependencies = []; + }; + mk_ln = pipe { + file = ./scripts/mk_ln; + dependencies = []; + }; + mk_scr_default = shell { + file = ./scripts/mk_scr_default; + dependencies = builtins.attrValues {}; + replacementStrings = { + SHELL_LIBRARY_TEMPLATE = "${shell_library.rawTemplate."${system}"}"; + }; + }; + mk_scr_temp = shell { + file = ./scripts/mk_scr_temp; + dependencies = builtins.attrValues {}; + replacementStrings = { + SHELL_LIBRARY_TEMPLATE = "${shell_library.rawTemplate."${system}"}"; + TO_BE_SHELL_LIBRARY_PATH = "%SHELL_LIBRARY_PATH"; # replacement is not recursive + }; + }; + open = shell { + file = ./scripts/open; + dependencies = builtins.attrValues {inherit (pkgs) file xdg-utils;}; + }; + go_project_base_directory = async { + file = ./scripts/go_project_root; + dependencies = []; + }; + open_config = shell { + file = ./scripts/open_config; + dependencies = builtins.attrValues { + #inherit + #(pkgs) + ## TODO: rewrite this: bookmenu, https://github.com/jarun/buku + # + #buku + #; + }; + }; + restore_trash = shell { + file = ./scripts/restore_trash; + dependencies = builtins.attrValues { + inherit + (pkgs) + fzf + trashy + ; + }; + }; + set_wall_paper = pipe { + file = ./scripts/set_wall_paper; + dependencies = []; + }; + /* + FIXME: + The c code fails, when stdout/-in is piped. + rename = '' + %{{ + ${lf_rename.packages."${system}".default}/bin/rename + }} + ''; + */ + stripspace = pipe { + file = ./scripts/stripspace; + dependencies = []; + }; + trash = pipe { + file = ./scripts/trash; + dependencies = builtins.attrValues { + inherit + (pkgs) + trashy + trash-cli + findutils + ; + }; + }; + unarchive = pipe { + file = ./scripts/unarchive; + dependencies = builtins.attrValues { + inherit + (pkgs) + gnutar + unzip + # TODO: this is unfree! unrar + + p7zip + ; + }; + }; +} |