aboutsummaryrefslogtreecommitdiffstats
path: root/modules/terminal/zsh/default.nix
blob: 47646181db806e4b08e608eeef10e5f597d7b05f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Z shell, extended bash with additional features and plugins
{
  config,
  lib,
  pkgs,
  ...
}:
let
  cfg = config.terminal.zsh;

  nixCommandWrappers = builtins.readFile ./nix-aliases.sh;
in
{
  options.terminal.zsh = {
    enable = lib.mkEnableOption "Enables zsh.";
    package = lib.mkOption {
      type = lib.types.package;
      readOnly = true;
      default = config.programs.zsh.package;
      description = "The zsh package to use.";
    };
  };

  config = lib.mkIf cfg.enable {
    programs.zsh = {
      enable = true;
      dotDir = "${config.xdg.configHome}/zsh";
      history.path = "${config.xdg.cacheHome}/zsh/history";
      enableCompletion = true;
      initContent = builtins.replaceStrings [ "@@NIX_COMMAND_WRAPPERS@@" ] [ nixCommandWrappers ] (
        builtins.readFile ./init.sh
      );
    };

    home.sessionVariables.SHELL = "${lib.getExe cfg.package}";
  };
}