diff --git a/configurations/home-manager/pi/home.nix b/configurations/home-manager/pi/home.nix index eccb35a..feeec1c 100644 --- a/configurations/home-manager/pi/home.nix +++ b/configurations/home-manager/pi/home.nix @@ -26,7 +26,7 @@ in { enable = true; autoSortDownloads = true; }; - joshuto.enable = true; + yazi.enable = true; kakoune.enable = true; ssh = { enable = true; diff --git a/configurations/home-manager/work/home.nix b/configurations/home-manager/work/home.nix index d541257..78c80b0 100644 --- a/configurations/home-manager/work/home.nix +++ b/configurations/home-manager/work/home.nix @@ -26,7 +26,7 @@ in { }; jiten.enable = true; scripts.enable = true; - joshuto.enable = true; + yazi.enable = true; joshuto.enableZshIntegration = false; kakoune.enable = true; ssh = { @@ -78,178 +78,6 @@ in { initExtra = "exec zsh"; }; - programs.yazi = let - mkYaziPlugin = name: - pkgs.stdenv.mkDerivation { - name = name; - phases = ["unpackPhase" "buildPhase"]; - buildPhase = '' - mkdir -p "$out" - cp -r "${name}".yazi/* "$out" - ''; - src = pkgs.fetchgit { - rev = "5e65389d1308188e5a990059c06729e2edb18f8a"; - url = "https://github.com/yazi-rs/plugins.git"; - hash = "sha256-XHaQjudV9YSMm4vF7PQrKGJ078oVF1U1Du10zXEJ9I0="; - }; - }; - gruvbox-dark = pkgs.stdenv.mkDerivation { - name = "gruvbox-dark"; - phases = ["unpackPhase" "buildPhase"]; - buildPhase = "mkdir -p $out ; cp -r . $out"; - src = pkgs.fetchgit { - url = "https://github.com/bennyyip/gruvbox-dark.yazi.git"; - rev = "c204853de7a78bc99ea628e51857ce65506468db"; - hash = "sha256-NBco10MINyAJk1YWHwYUzvI9mnTJl9aYyDtQSTUP3Hs="; - }; - }; - in { - enable = true; - enableZshIntegration = true; - shellWrapperName = "j"; - initLua = '' - require("full-border"):setup() - require("git"):setup() - ''; - keymap = { - manager.prepend_keymap = [ - { - on = "e"; - run = "shell --interactive --block $EDITOR $0"; - desc = "Edit file"; - } - # Selection - { - on = ";"; - run = "escape --select"; - desc = "Deselect all files"; - } - { - on = "?"; - run = "help"; - desc = "View help"; - } - { - on = "%"; - run = "select_all --state=true"; - desc = "Select all files"; - } - { - on = "J"; - run = ["select --state=none" "arrow 1"]; - desc = "Select down"; - } - { - on = "K"; - run = ["select --state=none" "arrow -1"]; - desc = "Select up"; - } - # Plugins - { - on = "'"; - run = "plugin smart-filter"; - desc = "Smart filter"; - } - { - on = ["c" "m"]; - run = "plugin chmod"; - desc = "Chmod on selected files"; - } - { - on = "t"; - run = "plugin --sync hide-preview"; - desc = "Hide or show preview"; - } - { - on = "T"; - run = "plugin --sync max-preview"; - desc = "Maximize or restore preview"; - } - # Goto - { - on = ["g" "~"]; - run = "cd ~"; - desc = "Goto home dir"; - } - { - on = ["g" "`"]; - run = "cd /"; - desc = "Goto root directory"; - } - { - on = ["g" "e"]; - run = "arrow 99999999999"; - desc = "Move cursor to bottom"; - } - # Bookmarks - { - on = ["b" "u"]; - run = "cd $XDG_DOWNLOAD_DIR"; - desc = "Goto bookmarked download directory"; - } - { - on = ["b" "b"]; - run = "cd ~/media/books"; - desc = "Goto bookmarked books directory"; - } - { - on = ["b" "p"]; - run = "cd ~/media/documents/programming"; - desc = "Goto bookmarked programming directory"; - } - { - on = ["b" "a"]; - run = "cd ~/media/audio"; - desc = "Goto bookmarked audio directory"; - } - { - on = ["b" "a"]; - run = "cd $XDG_VIDEOS_DIR"; - desc = "Goto bookmarked videos directory"; - } - { - on = ["b" "d"]; - run = "cd $XDG_DOCUMENTS_DIR"; - desc = "Goto bookmarked download directory"; - } - { - on = ["b" "s"]; - run = "cd ~/media/documents/study"; - desc = "Goto bookmarked study directory"; - } - { - on = ["b" "i"]; - run = "cd $XDG_PICTURES_DIR"; - desc = "Goto bookmarked images directory"; - } - ]; - }; - settings = { - plugin.prepend_fetchers = [ - { - id = "git"; - name = "*/"; - run = "git"; - } - { - id = "git"; - name = "*"; - run = "git"; - } - ]; - }; - flavors.gruvbox-dark = gruvbox-dark; - plugins = { - full-border = mkYaziPlugin "full-border"; - git = mkYaziPlugin "git"; - smart-filter = mkYaziPlugin "smart-filter"; - chmod = mkYaziPlugin "chmod"; - hide-preview = mkYaziPlugin "hide-preview"; - max-preview = mkYaziPlugin "max-preview"; - }; - theme.flavor.use = "gruvbox-dark"; - }; - programs.emacs = { enable = true; extraConfig = '' diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index d775fdc..b9d1113 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -12,6 +12,7 @@ ./joshuto ./kakoune ./ssh + ./yazi ./terminalTools ./userDirs ./zathura diff --git a/modules/home-manager/yazi/default.nix b/modules/home-manager/yazi/default.nix index 16f6726..8434679 100644 --- a/modules/home-manager/yazi/default.nix +++ b/modules/home-manager/yazi/default.nix @@ -5,36 +5,31 @@ ... }: with lib; let - cfg = config.kirk.joshuto; - yaziPkgs = { - full-border = stdenv.mkDerivation { - name = "full-border"; - src = fetchgit { + cfg = config.kirk.yazi; + mkYaziPlugin = name: + pkgs.stdenv.mkDerivation { + name = name; + phases = ["unpackPhase" "buildPhase"]; + buildPhase = '' + mkdir -p "$out" + cp -r "${name}".yazi/* "$out" + ''; + src = pkgs.fetchgit { + rev = "5e65389d1308188e5a990059c06729e2edb18f8a"; url = "https://github.com/yazi-rs/plugins.git"; - sparseCheckout = ["full-border.yazi"]; - hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; + hash = "sha256-XHaQjudV9YSMm4vF7PQrKGJ078oVF1U1Du10zXEJ9I0="; }; }; - gruvbox-dark = stdenv.mkDerivation { - name = "gruvbox-dark"; - src = fetchgit { - url = "https://github.com/bennyyip/gruvbox-dark.yazi.git"; - hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; - }; + gruvbox-dark = stdenv.mkDerivation { + name = "gruvbox-dark"; + src = fetchgit { + url = "https://github.com/bennyyip/gruvbox-dark.yazi.git"; + hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; }; }; in { - options.kirk.joshuto = { + options.kirk.yazi = { enable = mkEnableOption "yazi file manager"; - - enableZshIntegration = mkOption { - type = types.bool; - default = true; - - description = '' - Adds the auto-cd `j` command to zsh. - ''; - }; }; config = mkIf cfg.enable { @@ -50,11 +45,148 @@ in { ]; programs.yazi = { - enable = true; - enableZshIntegration = cfg.enableZshIntegration; - flavors.gruvbox-dark = yaziPkgs.gruvbox-dark; + enable = cfg.enable; + enableZshIntegration = true; + shellWrapperName = "j"; + initLua = '' + require("full-border"):setup() + require("git"):setup() + ''; + keymap = { + manager.prepend_keymap = [ + { + on = "e"; + run = "shell --interactive --block $EDITOR $0"; + desc = "Edit file"; + } + # Selection + { + on = ";"; + run = "escape --select"; + desc = "Deselect all files"; + } + { + on = "?"; + run = "help"; + desc = "View help"; + } + { + on = "%"; + run = "select_all --state=true"; + desc = "Select all files"; + } + { + on = "J"; + run = ["select --state=none" "arrow 1"]; + desc = "Select down"; + } + { + on = "K"; + run = ["select --state=none" "arrow -1"]; + desc = "Select up"; + } + # Plugins + { + on = "'"; + run = "plugin smart-filter"; + desc = "Smart filter"; + } + { + on = ["c" "m"]; + run = "plugin chmod"; + desc = "Chmod on selected files"; + } + { + on = "t"; + run = "plugin --sync hide-preview"; + desc = "Hide or show preview"; + } + { + on = "T"; + run = "plugin --sync max-preview"; + desc = "Maximize or restore preview"; + } + # Goto + { + on = ["g" "~"]; + run = "cd ~"; + desc = "Goto home dir"; + } + { + on = ["g" "`"]; + run = "cd /"; + desc = "Goto root directory"; + } + { + on = ["g" "e"]; + run = "arrow 99999999999"; + desc = "Move cursor to bottom"; + } + # Bookmarks + { + on = ["b" "u"]; + run = "cd $XDG_DOWNLOAD_DIR"; + desc = "Goto bookmarked download directory"; + } + { + on = ["b" "b"]; + run = "cd ~/media/books"; + desc = "Goto bookmarked books directory"; + } + { + on = ["b" "p"]; + run = "cd ~/media/documents/programming"; + desc = "Goto bookmarked programming directory"; + } + { + on = ["b" "a"]; + run = "cd ~/media/audio"; + desc = "Goto bookmarked audio directory"; + } + { + on = ["b" "a"]; + run = "cd $XDG_VIDEOS_DIR"; + desc = "Goto bookmarked videos directory"; + } + { + on = ["b" "d"]; + run = "cd $XDG_DOCUMENTS_DIR"; + desc = "Goto bookmarked download directory"; + } + { + on = ["b" "s"]; + run = "cd ~/media/documents/study"; + desc = "Goto bookmarked study directory"; + } + { + on = ["b" "i"]; + run = "cd $XDG_PICTURES_DIR"; + desc = "Goto bookmarked images directory"; + } + ]; + }; + settings = { + plugin.prepend_fetchers = [ + { + id = "git"; + name = "*/"; + run = "git"; + } + { + id = "git"; + name = "*"; + run = "git"; + } + ]; + }; + flavors.gruvbox-dark = gruvbox-dark; plugins = { - full-border = yaziPkgs.full-border; + full-border = mkYaziPlugin "full-border"; + git = mkYaziPlugin "git"; + smart-filter = mkYaziPlugin "smart-filter"; + chmod = mkYaziPlugin "chmod"; + hide-preview = mkYaziPlugin "hide-preview"; + max-preview = mkYaziPlugin "max-preview"; }; theme.flavor.use = "gruvbox-dark"; }; diff --git a/modules/nixos/nixosScripts/default.nix b/modules/nixos/nixosScripts/default.nix index 78617b6..c8d5325 100644 --- a/modules/nixos/nixosScripts/default.nix +++ b/modules/nixos/nixosScripts/default.nix @@ -17,6 +17,11 @@ with lib; let nos-upgrade = pkgs.writeShellApplication { name = "nos-upgrade"; text = '' + if [ "$EUID" -ne 0 ]; then + echo "Please run as root" + exit + fi + # Update, switch to new config, and cleanup ${nos-update}/bin/nos-update && ${nos-rebuild}/bin/nos-rebuild && @@ -41,9 +46,12 @@ with lib; let nos-rebuild = pkgs.writeShellApplication { name = "nos-rebuild"; text = '' + if [ "$EUID" -ne 0 ]; then + echo "Please run as root" + exit + fi + nix flake update nixarr --flake ${cfg.configDir} - # Update the inputs of this repo on every rebuild - nix flake update kirk-modules --flake ${cfg.configDir} && # Switch configuration, backing up files # impure is a little disgusting, but will cause issues otherwise nixos-rebuild switch --flake ${cfg.configDir}#${cfg.machine} --show-trace --impure