1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-24 10:49:48 +01:00
home-manager/modules/programs/bat.nix

59 lines
1.4 KiB
Nix
Raw Normal View History

2019-02-11 06:57:10 +01:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.bat;
2020-02-02 00:39:17 +01:00
in {
2019-02-11 06:57:10 +01:00
meta.maintainers = [ maintainers.marsam ];
options.programs.bat = {
enable = mkEnableOption "bat, a cat clone with wings";
config = mkOption {
type = types.attrsOf types.str;
2020-02-02 00:39:17 +01:00
default = { };
2019-02-11 06:57:10 +01:00
example = {
theme = "TwoDark";
pager = "less -FR";
};
description = ''
Bat configuration.
'';
};
themes = mkOption {
type = types.attrsOf types.lines;
default = { };
example = literalExample ''
{
dracula = builtins.readFile (pkgs.fetchFromGitHub {
owner = "dracula";
repo = "sublime"; # Bat uses sublime syntax for its themes
rev = "26c57ec282abcaa76e57e055f38432bd827ac34e";
sha256 = "019hfl4zbn4vm4154hh3bwk6hm7bdxbr1hdww83nabxwjn99ndhv";
} + "/Dracula.tmTheme");
}
'';
description = ''
Additional themes to provide.
'';
};
2019-02-11 06:57:10 +01:00
};
config = mkIf cfg.enable {
home.packages = [ pkgs.bat ];
xdg.configFile = mkMerge ([{
"bat/config" = mkIf (cfg.config != { }) {
text = concatStringsSep "\n"
(mapAttrsToList (n: v: ''--${n}="${v}"'') cfg.config);
};
}] ++ flip mapAttrsToList cfg.themes
(name: body: { "bat/themes/${name}.tmTheme" = { text = body; }; }));
2019-02-11 06:57:10 +01:00
};
}