diff --git a/common/zsh/default.nix b/common/zsh/default.nix new file mode 100644 index 0000000..c5a3659 --- /dev/null +++ b/common/zsh/default.nix @@ -0,0 +1,25 @@ +{ + pkgs, + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + cfg = config.my.zsh; +in { + options.my.zsh = { + enable = mkEnableOption "zsh"; + }; + + config = mkIf cfg.enable { + hm.my.zsh.enable = true; + + programs.zsh = { + enable = true; + }; + + environment.variables.EDITOR = "nvim"; + + users.users."${config.my.user}".shell = pkgs.zsh; + }; +} diff --git a/common/zsh/home.nix b/common/zsh/home.nix new file mode 100644 index 0000000..c700871 --- /dev/null +++ b/common/zsh/home.nix @@ -0,0 +1,64 @@ +{ + pkgs, + lib, + config, + ... +}: let + inherit (lib) mkEnableOption mkIf; + cfg = config.my.zsh; +in { + options.my.zsh = { + enable = mkEnableOption "zsh"; + }; + + config = mkIf cfg.enable { + programs.zsh = { + enable = true; + + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + historySubstringSearch.enable = true; + autocd = true; + enableCompletion = true; + + # Enable pure prompt + initExtra = '' + fpath+=${pkgs.pure-prompt}/share/zsh/site-functions + autoload -U promptinit; + promptinit + prompt pure + ''; + + envExtra = '' + # Do not load global configuration + setopt no_global_rcs + ''; + + loginExtra = '' + setopt correct + ''; + + sessionVariables = { + # Make ls colorful on MacOS + CLICOLOR = 1; + }; + + plugins = [ + { + name = "zsh-nix-shell"; + file = "nix-shell.plugin.zsh"; + src = pkgs.fetchFromGitHub { + owner = "chisui"; + repo = "zsh-nix-shell"; + rev = "v0.8.0"; + sha256 = "1lzrn0n4fxfcgg65v0qhnj7wnybybqzs4adz7xsrkgmcsr0ii8b7"; + }; + } + ]; + }; + + programs.zoxide = { + enable = true; + }; + }; +} diff --git a/user/environments/mac/home.nix b/user/environments/mac/home.nix index cb09df3..b70203b 100644 --- a/user/environments/mac/home.nix +++ b/user/environments/mac/home.nix @@ -3,7 +3,6 @@ ../../modules/applications/alacritty.nix ../../modules/applications/sioyek.nix - ../../modules/zsh.nix ../../modules/zellij ../../modules/dev.nix ../../modules/git.nix @@ -19,6 +18,7 @@ nvim-custom ]; + my.zsh.enable = true; programs.zsh = { # Needed for nix-shell to have the correct bash version profileExtra = '' diff --git a/user/environments/nixos-server/home.nix b/user/environments/nixos-server/home.nix index 8d0e95c..d579c08 100644 --- a/user/environments/nixos-server/home.nix +++ b/user/environments/nixos-server/home.nix @@ -1,9 +1,10 @@ {pkgs, ...}: { imports = [ ../../modules/git.nix - ../../modules/zsh.nix ]; + my.zsh.enable = true; + home.packages = with pkgs; [ lazygit nvim-custom diff --git a/user/environments/nixos/home.nix b/user/environments/nixos/home.nix index f3250d6..fe20a64 100644 --- a/user/environments/nixos/home.nix +++ b/user/environments/nixos/home.nix @@ -8,9 +8,10 @@ ../../modules/git_nixos.nix ../../modules/vscode.nix ../../modules/zellij - ../../modules/zsh.nix ]; + my.zsh.enable = true; + home.packages = with pkgs; [nvim-custom]; # Let Home Manager install and manage itself. diff --git a/user/modules/zsh.nix b/user/modules/zsh.nix deleted file mode 100644 index 4f96824..0000000 --- a/user/modules/zsh.nix +++ /dev/null @@ -1,50 +0,0 @@ -{pkgs, ...}: { - programs.zsh = { - enable = true; - - autosuggestion.enable = true; - syntaxHighlighting.enable = true; - historySubstringSearch.enable = true; - autocd = true; - enableCompletion = true; - - # Enable pure prompt - initExtra = '' - fpath+=${pkgs.pure-prompt}/share/zsh/site-functions - autoload -U promptinit; - promptinit - prompt pure - ''; - - envExtra = '' - # Do not load global configuration - setopt no_global_rcs - ''; - - loginExtra = '' - setopt correct - ''; - - sessionVariables = { - # Make ls colorful on MacOS - CLICOLOR = 1; - }; - - plugins = [ - { - name = "zsh-nix-shell"; - file = "nix-shell.plugin.zsh"; - src = pkgs.fetchFromGitHub { - owner = "chisui"; - repo = "zsh-nix-shell"; - rev = "v0.8.0"; - sha256 = "1lzrn0n4fxfcgg65v0qhnj7wnybybqzs4adz7xsrkgmcsr0ii8b7"; - }; - } - ]; - }; - - programs.zoxide = { - enable = true; - }; -}