2020-10-12 00:22:58 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.bat;
|
|
|
|
|
2021-11-04 16:42:44 +00:00
|
|
|
toConfigFile = generators.toKeyValue {
|
|
|
|
mkKeyValue = k: v: "--${k}=${lib.escapeShellArg v}";
|
|
|
|
listsAsDuplicateKeys = true;
|
|
|
|
};
|
|
|
|
|
2020-10-12 00:22:58 +00:00
|
|
|
in {
|
|
|
|
meta.maintainers = [ maintainers.marsam ];
|
|
|
|
|
|
|
|
options.programs.bat = {
|
|
|
|
enable = mkEnableOption "bat, a cat clone with wings";
|
|
|
|
|
|
|
|
config = mkOption {
|
2021-11-04 16:42:44 +00:00
|
|
|
type = with types; attrsOf (either str (listOf str));
|
2020-10-12 00:22:58 +00:00
|
|
|
default = { };
|
|
|
|
example = {
|
|
|
|
theme = "TwoDark";
|
|
|
|
pager = "less -FR";
|
2021-11-04 16:42:44 +00:00
|
|
|
map-syntax = [ "*.jenkinsfile:Groovy" "*.props:Java Properties" ];
|
2020-10-12 00:22:58 +00:00
|
|
|
};
|
|
|
|
description = ''
|
|
|
|
Bat configuration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
themes = mkOption {
|
|
|
|
type = types.attrsOf types.lines;
|
|
|
|
default = { };
|
2021-11-04 16:42:44 +00:00
|
|
|
example = literalExpression ''
|
2020-10-12 00:22:58 +00:00
|
|
|
{
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [ pkgs.bat ];
|
|
|
|
|
|
|
|
xdg.configFile = mkMerge ([{
|
2021-11-04 16:42:44 +00:00
|
|
|
"bat/config" =
|
|
|
|
mkIf (cfg.config != { }) { text = toConfigFile cfg.config; };
|
2020-10-12 00:22:58 +00:00
|
|
|
}] ++ flip mapAttrsToList cfg.themes
|
|
|
|
(name: body: { "bat/themes/${name}.tmTheme" = { text = body; }; }));
|
|
|
|
};
|
|
|
|
}
|