home-manager/modules/programs/jq.nix
Emily 3228f92b90 treewide: manually convert some docs to Markdown
These files all have options that trip up the `nix-doc-munge`
conversion tool for one reason or another (syntax that clashes with
Markdown, options that were already using Markdown syntax despite not
being marked that way, output that differs slightly after conversion,
syntax too elaborate to convert with some cheap regular expressions,
...). Translate them manually and do a little copyediting to options
in the vicinity while we're at it.
2023-07-17 16:49:35 +01:00

84 lines
1.7 KiB
Nix

{ 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 = {
null = colorType;
false = colorType;
true = colorType;
numbers = colorType;
strings = colorType;
arrays = colorType;
objects = colorType;
};
};
in {
options = {
programs.jq = {
enable = mkEnableOption "the jq command-line JSON processor";
package = mkOption {
type = types.package;
default = pkgs.jq;
defaultText = literalExpression "pkgs.jq";
description = "jq package to use.";
};
colors = mkOption {
description = lib.mdDoc ''
The colors used in colored JSON output.
See the [Colors section](https://jqlang.github.io/jq/manual/#Colors)
of the jq manual.
'';
example = literalExpression ''
{
null = "1;30";
false = "0;31";
true = "0;32";
numbers = "0;36";
strings = "0;33";
arrays = "1;35";
objects = "1;37";
}
'';
default = {
null = "1;30";
false = "0;37";
true = "0;37";
numbers = "0;37";
strings = "0;32";
arrays = "1;37";
objects = "1;37";
};
type = colorsType;
};
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
home.sessionVariables = let c = cfg.colors;
in {
JQ_COLORS =
"${c.null}:${c.false}:${c.true}:${c.numbers}:${c.strings}:${c.arrays}:${c.objects}";
};
};
}