1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-24 03:59:46 +01:00
home-manager/modules/programs/jq.nix

77 lines
1.5 KiB
Nix
Raw Normal View History

2018-12-09 14:36:21 +01:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.jq;
colorType = mkOption {
type = types.str;
description = "ANSI color definition";
example = "1;31";
visible = false;
};
colorsType = types.submodule {
options = {
2020-02-02 00:39:17 +01:00
null = colorType;
false = colorType;
true = colorType;
2018-12-09 14:36:21 +01:00
numbers = colorType;
strings = colorType;
2020-02-02 00:39:17 +01:00
arrays = colorType;
2018-12-09 14:36:21 +01:00
objects = colorType;
};
};
2020-02-02 00:39:17 +01:00
in {
2018-12-09 14:36:21 +01:00
options = {
programs.jq = {
enable = mkEnableOption "the jq command-line JSON processor";
colors = mkOption {
description = ''
The colors used in colored JSON output.</para>
<para>See <link xlink:href="https://stedolan.github.io/jq/manual/#Colors"/>.
'';
example = literalExample ''
{
null = "1;30";
false = "0;31";
true = "0;32";
numbers = "0;36";
strings = "0;33";
arrays = "1;35";
objects = "1;37";
}
'';
default = {
2020-02-02 00:39:17 +01:00
null = "1;30";
false = "0;39";
true = "0;39";
2018-12-09 14:36:21 +01:00
numbers = "0;39";
strings = "0;32";
2020-02-02 00:39:17 +01:00
arrays = "1;39";
2018-12-09 14:36:21 +01:00
objects = "1;39";
};
type = colorsType;
};
};
};
config = mkIf cfg.enable {
home.packages = [ pkgs.jq ];
2020-02-02 00:39:17 +01:00
home.sessionVariables = let c = cfg.colors;
in {
JQ_COLORS =
"${c.null}:${c.false}:${c.true}:${c.numbers}:${c.strings}:${c.arrays}:${c.objects}";
2018-12-09 14:36:21 +01:00
};
};
}