From 9283b193de9a421d7fd338fb8396251da31a34aa Mon Sep 17 00:00:00 2001 From: rasmus-kirk Date: Fri, 25 Oct 2024 15:54:21 +0200 Subject: [PATCH] mainly yazi --- .../homeManagerScripts/default.nix | 20 ++++++++++-- modules/home-manager/yazi/default.nix | 8 +---- .../home-manager/yazi/plugins/mkdir/LICENSE | 21 ++++++++++++ .../home-manager/yazi/plugins/mkdir/README.md | 24 ++++++++++++++ .../home-manager/yazi/plugins/mkdir/init.lua | 32 +++++++++++++++++++ 5 files changed, 96 insertions(+), 9 deletions(-) create mode 100644 modules/home-manager/yazi/plugins/mkdir/LICENSE create mode 100644 modules/home-manager/yazi/plugins/mkdir/README.md create mode 100644 modules/home-manager/yazi/plugins/mkdir/init.lua diff --git a/modules/home-manager/homeManagerScripts/default.nix b/modules/home-manager/homeManagerScripts/default.nix index b0c83e0..de94b04 100644 --- a/modules/home-manager/homeManagerScripts/default.nix +++ b/modules/home-manager/homeManagerScripts/default.nix @@ -44,8 +44,11 @@ with lib; let hm-rebuild = pkgs.writeShellApplication { name = "hm-rebuild"; text = '' + pushd ${configDir} + git add . # Switch configuration, backing up files - home-manager switch -b backup --flake ${configDir}#${cfg.machine} + home-manager switch -b backup --flake .#${cfg.machine} + popd ''; }; @@ -78,7 +81,6 @@ in { configurations/garbage collects - `hm-rollback`: Use this command to roll back to a previous working home manager configuration. - ''; configDir = mkOption { @@ -94,11 +96,25 @@ in { machine = mkOption { type = types.nullOr types.str; + default = null; description = "**REQUIRED!** Path to the home-manager configuration."; }; + + disableNews = mkOption { + type = types.nullOr types.str; + default = true; + description = "Disable annoying home-manager news on rebuild."; + }; }; config = mkIf cfg.enable { + # Disable home manager news + news = mkIf cfg.disableNews { + display = "silent"; + json = lib.mkForce { }; + entries = lib.mkForce [ ]; + }; + home.packages = [ hm-update hm-upgrade diff --git a/modules/home-manager/yazi/default.nix b/modules/home-manager/yazi/default.nix index 5946519..f7cec04 100644 --- a/modules/home-manager/yazi/default.nix +++ b/modules/home-manager/yazi/default.nix @@ -41,12 +41,6 @@ with lib; let rev = "c204853de7a78bc99ea628e51857ce65506468db"; hash = "sha256-NBco10MINyAJk1YWHwYUzvI9mnTJl9aYyDtQSTUP3Hs="; }; - mkdir = mkYaziPluginGithub { - name = "mkdir"; - url = "https://github.com/Sonico98/mkdir.yazi"; - rev = "0c0b87a576d49001603f63d447aab166ec35363f"; - hash = "sha256-rx3B3MyljqabEjJDtCx807JhIemafduQ0i5fJvJXAzs="; - }; exifaudio = mkYaziPluginGithub { name = "exifaudio"; url = "https://github.com/Sonico98/exifaudio.yazi"; @@ -258,7 +252,7 @@ in { }; flavors.gruvbox-dark = plugins.gruvbox-dark; plugins = { - mkdir = plugins.mkdir; + mkdir = ./plugins/mkdir; exifaudio = plugins.exifaudio; full-border = mkYaziPlugin "full-border"; git = mkYaziPlugin "git"; diff --git a/modules/home-manager/yazi/plugins/mkdir/LICENSE b/modules/home-manager/yazi/plugins/mkdir/LICENSE new file mode 100644 index 0000000..78aae84 --- /dev/null +++ b/modules/home-manager/yazi/plugins/mkdir/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Sonico98 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/modules/home-manager/yazi/plugins/mkdir/README.md b/modules/home-manager/yazi/plugins/mkdir/README.md new file mode 100644 index 0000000..9b7b561 --- /dev/null +++ b/modules/home-manager/yazi/plugins/mkdir/README.md @@ -0,0 +1,24 @@ +# mkdir.yazi + +Create directories in yazi without having to type a trailing slash at the end every time. + +## Installation + +```sh +# Linux/MacOS +git clone https://github.com/Sonico98/mkdir.yazi.git ~/.config/yazi/plugins/mkdir.yazi + +# Windows +git clone https://github.com/Sonico98/mkdir.yazi.git %AppData%\yazi\config\plugins\mkdir.yazi +``` + +## Usage + +Add this to your `keymap.toml`: + +```toml +[[manager.prepend_keymap]] +on = [ "m", "k" ] +exec = "plugin mkdir" +desc = "Create a directory" +``` diff --git a/modules/home-manager/yazi/plugins/mkdir/init.lua b/modules/home-manager/yazi/plugins/mkdir/init.lua new file mode 100644 index 0000000..5954f08 --- /dev/null +++ b/modules/home-manager/yazi/plugins/mkdir/init.lua @@ -0,0 +1,32 @@ +return { + entry = function(self, _) + local dir, event = ya.input { + title = "Directory name:", + position = { "top-center", y = 2, w = 50 }, + } + + if event ~= 1 then + return + end + + local args = { "-p", dir } + if ya.target_family() == "windows" then + args = { dir } + end + + local child = Command("mkdir") + :args(args) + :stderr(Command.PIPED) + :spawn() + + local status, _ = child:wait() + if not status.success then + ya.notify { + title = "Error creating directory", + content = child:read_line(), + timeout = 5, + level = "error", + } + end + end +}