home-manager/modules/programs/jq.nix
Emily 36a53d9f26 treewide: convert all option docs to Markdown
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.

To reproduce this commit, run:

  $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
    nix shell nixpkgs#coreutils \
    -c find . -name '*.nix' \
    -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
    {} +
  $ ./format

[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
2023-07-17 18:40:56 +01:00

85 lines
1.8 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.jq;
colorType = mkOption {
type = types.str;
description = lib.mdDoc "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 (lib.mdDoc "the jq command-line JSON processor");
package = mkOption {
type = types.package;
default = pkgs.jq;
defaultText = literalExpression "pkgs.jq";
description = lib.mdDoc "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}";
};
};
}