aboutsummaryrefslogtreecommitdiff
path: root/home-manager/modules/programs/bat.nix
blob: aa0df9abd45ea64e200869a5cd390baf13ed9c74 (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
{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.programs.bat;

in {
  meta.maintainers = [ maintainers.marsam ];

  options.programs.bat = {
    enable = mkEnableOption "bat, a cat clone with wings";

    config = mkOption {
      type = types.attrsOf types.str;
      default = { };
      example = {
        theme = "TwoDark";
        pager = "less -FR";
      };
      description = ''
        Bat configuration.
      '';
    };

  };

  config = mkIf cfg.enable {
    home.packages = [ pkgs.bat ];

    xdg.configFile."bat/config" = mkIf (cfg.config != { }) {
      text = concatStringsSep "\n"
        (mapAttrsToList (n: v: ''--${n}="${v}"'') cfg.config);
    };
  };
}