diff options
Diffstat (limited to 'modules/by-name/zs')
-rw-r--r-- | modules/by-name/zs/zsh/module.nix | 191 |
1 files changed, 101 insertions, 90 deletions
diff --git a/modules/by-name/zs/zsh/module.nix b/modules/by-name/zs/zsh/module.nix index 833da126..cb1bb086 100644 --- a/modules/by-name/zs/zsh/module.nix +++ b/modules/by-name/zs/zsh/module.nix @@ -6,7 +6,8 @@ ... }: let cfg = config.soispha.programs.zsh; - homeConfig = config.home-manager.users.soispha; + + zDotDir = ".config/zsh"; sourceFile = path: "source ${path}\n"; in { @@ -14,98 +15,108 @@ in { enable = lib.mkEnableOption "zsh"; }; - config.home-manager.users.soispha = lib.mkIf cfg.enable { - home.sessionPath = []; - - programs.zsh = { - enable = true; - enableCompletion = true; - autosuggestion = { - enable = true; - strategy = []; - }; - syntaxHighlighting.enable = true; - - autocd = true; + config = lib.mkIf cfg.enable { + environment.variables = { + ZDOTDIR = "${config.home-manager.users.soispha.home.homeDirectory}/${zDotDir}"; + }; - # Must be relative to the users home directory (for whatever reason) - # Thus no `${homeConfig.xdg.configHome}` - dotDir = ".config/zsh"; + home-manager.users.soispha = { + home.sessionPath = lib.mkForce []; - # TODO: Remove the whole history and replace it completely with `atuin` <2024-10-21> - history = { - path = "/dev/null"; - # save = 0; # number of lines to save - # size = 0; # number of lines to keep - # share = false; # share between sessions - }; + # This just includes a `source ~/.config/zsh/.zshenv`, because home-manger by-default + # can't access the root `/etc/zshenv`. We can and thus, we can remove this file. + home.file.".zshenv".enable = false; - loginExtra = - # bash - '' - setopt AUTO_CD - setopt AUTO_PUSHD - setopt CHASE_DOTS - - setopt ALWAYS_TO_END - - setopt EXTENDED_HISTORY - setopt HIST_ALLOW_CLOBBER - setopt HIST_VERIFY - setopt HIST_FCNTL_LOCK - setopt APPEND_HISTORY - - setopt DVORAK - setopt CORRECT - - setopt PROMPT_SUBST - setopt TRANSIENT_RPROMPT # maybe? - - setopt COMBINING_CHARS - setopt VI - ''; - - initExtraFirst = - sourceFile ./config/zsh-init.zsh - + '' - SHELL_LIBRARY_VERSION="2.1.2" source ${shell_library.rawLib.${system}} - ''; - - initExtra = let - start = lib.modules.mkBefore ( - # NOTE: This must be before the insult, as we otherwise override the previous handler <2024-02-28> - sourceFile ./config/command_not_found/command_not_found.sh - + sourceFile ./config/command_not_found/command_not_found_insult.sh - + sourceFile ./config/custom_cursor.zsh - + sourceFile ./config/edit_command_line.zsh - + sourceFile ./plugins/zsh-history-substring-search.zsh - ); - end = lib.modules.mkAfter ( - sourceFile ./config/keymaps_start.zsh - + sourceFile ./config/keymaps/command.zsh - + sourceFile ./config/keymaps/emacs.zsh - + sourceFile ./config/keymaps/isearch.zsh - + sourceFile ./config/keymaps/vicmd.zsh - + sourceFile ./config/keymaps/viins.zsh - + sourceFile ./config/keymaps/viopp.zsh - + sourceFile ./config/keymaps/visual.zsh - + sourceFile ./config/keymaps_end.zsh - ); - in - lib.modules.mkMerge - [ - start - end - ]; - - localVariables = { - HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND = "bg=cyan,fg=white"; - HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND = "fg=red,underline,standout,bold"; - }; - - shellAliases = { - ll = ". ll"; - lm = ". lm"; + programs.zsh = { + enable = true; + enableCompletion = true; + autosuggestion = { + enable = true; + strategy = []; + }; + syntaxHighlighting.enable = true; + + autocd = true; + + # Must be relative to the users home directory (for whatever reason) + # Thus no `${homeConfig.xdg.configHome}` + dotDir = zDotDir; + + # TODO: Remove the whole history and replace it completely with `atuin` <2024-10-21> + history = { + path = "/dev/null"; + # save = 0; # number of lines to save + # size = 0; # number of lines to keep + # share = false; # share between sessions + }; + + loginExtra = + # bash + '' + setopt AUTO_CD + setopt AUTO_PUSHD + setopt CHASE_DOTS + + setopt ALWAYS_TO_END + + setopt EXTENDED_HISTORY + setopt HIST_ALLOW_CLOBBER + setopt HIST_VERIFY + setopt HIST_FCNTL_LOCK + setopt APPEND_HISTORY + + setopt DVORAK + setopt CORRECT + + setopt PROMPT_SUBST + setopt TRANSIENT_RPROMPT # maybe? + + setopt COMBINING_CHARS + setopt VI + ''; + + initExtraFirst = + sourceFile ./config/zsh-init.zsh + + '' + SHELL_LIBRARY_VERSION="2.1.2" source ${shell_library.rawLib.${system}} + ''; + + initExtra = let + start = lib.modules.mkBefore ( + # NOTE: This must be before the insult, as we otherwise override the previous handler <2024-02-28> + sourceFile ./config/command_not_found/command_not_found.sh + + sourceFile ./config/command_not_found/command_not_found_insult.sh + + sourceFile ./config/custom_cursor.zsh + + sourceFile ./config/edit_command_line.zsh + + sourceFile ./plugins/zsh-history-substring-search.zsh + ); + end = lib.modules.mkAfter ( + sourceFile ./config/keymaps_start.zsh + + sourceFile ./config/keymaps/command.zsh + + sourceFile ./config/keymaps/emacs.zsh + + sourceFile ./config/keymaps/isearch.zsh + + sourceFile ./config/keymaps/vicmd.zsh + + sourceFile ./config/keymaps/viins.zsh + + sourceFile ./config/keymaps/viopp.zsh + + sourceFile ./config/keymaps/visual.zsh + + sourceFile ./config/keymaps_end.zsh + ); + in + lib.modules.mkMerge + [ + start + end + ]; + + localVariables = { + HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND = "bg=cyan,fg=white"; + HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND = "fg=red,underline,standout,bold"; + }; + + shellAliases = { + ll = ". ll"; + lm = ". lm"; + }; }; }; }; |