aboutsummaryrefslogtreecommitdiffstats
path: root/modules/terminal/zsh/default.nix
blob: 8b7897c0995f93fdca9dc4401e6d33639e4d05f1 (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
# Z shell, extended bash with additional features and plugins
{
  config,
  lib,
  ...
}:
{
  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 =
    let
      nixCommandWrappers = builtins.readFile ./nix-aliases.sh;
    in
    lib.mkIf config.terminal.zsh.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 config.terminal.zsh.package}";
    };
}