aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-02-02 18:19:45 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-02-02 18:25:44 +0100
commit14cee6e56c666f2bd2aabe380385f41572951a13 (patch)
treea3dbfcc2ffe0e044cd2c40b588edb34c1300906b /modules/by-name
parentfix(modules/locale): Remove the `us-modified` keymap (diff)
downloadnixos-config-14cee6e56c666f2bd2aabe380385f41572951a13.zip
fix(modules/zsh): Avoid having to rely on the `~/.zshenv` file
We can use the `/etc/zshenv` file.
Diffstat (limited to 'modules/by-name')
-rw-r--r--modules/by-name/zs/zsh/module.nix167
1 files changed, 89 insertions, 78 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 = [];
+ config = lib.mkIf cfg.enable {
+ environment.variables = {
+ ZDOTDIR = "${config.home-manager.users.soispha.home.homeDirectory}/${zDotDir}";
+ };
+
+ home-manager.users.soispha = {
+ home.sessionPath = lib.mkForce [];
+
+ # 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;
- programs.zsh = {
- enable = true;
- enableCompletion = true;
- autosuggestion = {
+ programs.zsh = {
enable = true;
- strategy = [];
- };
- syntaxHighlighting.enable = true;
+ enableCompletion = true;
+ autosuggestion = {
+ enable = true;
+ strategy = [];
+ };
+ syntaxHighlighting.enable = true;
- autocd = true;
+ autocd = true;
- # Must be relative to the users home directory (for whatever reason)
- # Thus no `${homeConfig.xdg.configHome}`
- dotDir = ".config/zsh";
+ # 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
- };
+ # 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
+ loginExtra =
+ # bash
+ ''
+ setopt AUTO_CD
+ setopt AUTO_PUSHD
+ setopt CHASE_DOTS
- setopt ALWAYS_TO_END
+ setopt ALWAYS_TO_END
- setopt EXTENDED_HISTORY
- setopt HIST_ALLOW_CLOBBER
- setopt HIST_VERIFY
- setopt HIST_FCNTL_LOCK
- setopt APPEND_HISTORY
+ setopt EXTENDED_HISTORY
+ setopt HIST_ALLOW_CLOBBER
+ setopt HIST_VERIFY
+ setopt HIST_FCNTL_LOCK
+ setopt APPEND_HISTORY
- setopt DVORAK
- setopt CORRECT
+ setopt DVORAK
+ setopt CORRECT
- setopt PROMPT_SUBST
- setopt TRANSIENT_RPROMPT # maybe?
+ setopt PROMPT_SUBST
+ setopt TRANSIENT_RPROMPT # maybe?
- setopt COMBINING_CHARS
- setopt VI
- '';
+ setopt COMBINING_CHARS
+ setopt VI
+ '';
- initExtraFirst =
- sourceFile ./config/zsh-init.zsh
- + ''
- SHELL_LIBRARY_VERSION="2.1.2" source ${shell_library.rawLib.${system}}
- '';
+ 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
- ];
+ 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";
- };
+ 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";
+ shellAliases = {
+ ll = ". ll";
+ lm = ". lm";
+ };
};
};
};