about summary refs log tree commit diff
path: root/home/modules/programs/zellij/default.nix
blob: cd048f8f976023099c62c2f3a09ecb265db2fb84 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.programs.zellij;
  yamlFormat = pkgs.formats.yaml { };

in
{
  meta.maintainers = with lib.maintainers; [ boppyt ];

  options.programs.zellij = {
    enable = mkEnableOption "Zellij, A terminal workspace with batteries included.";

    package = mkOption {
      type = types.package;
      default = pkgs.zellij;
      defaultText = literalExpression "pkgs.zellij";
      description = "The zellij package to install";
    };

    settings = mkOption {
      type = with types;
        let
          prim = oneOf [ bool int str ];
          primOrPrimAttrs = either prim (attrsOf prim);
          entry = either prim (listOf primOrPrimAttrs);
          entryOrAttrsOf = t: either entry (attrsOf t);
          entries = entryOrAttrsOf (entryOrAttrsOf entry);
        in
        attrsOf entries // { description = "zellij configuration"; };
      default = { };
      description = ''
        Configuration written to
        <filename>$XDG_CONFIG_HOME/zellij/config.yaml</filename>. See <link
        xlink:href="https://zellij.dev/documentation/configuration.html"/>
        for a list of available options.
      '';
      example = literalExample ''
        {
          default-mode = "normal";
          simplified-ui = true;
        }
      '';
    };
  };

  config = mkIf cfg.enable {

    home.packages = [ cfg.package ];

    xdg.configFile."zellij/config.yaml" = mkIf (cfg.settings != { }) {
      source = yamlFormat.generate "zellij-config" cfg.settings;
    };
  };
}