mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
`literalExpression` is intended just to signify code that needs to stay a string that gets represented exactly as-is for docs. It has been misused heavily and people get confused repeatedly on when or not to use it because of the rampant misuse.
78 lines
1.6 KiB
Nix
78 lines
1.6 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib) mkIf mkOption types;
|
|
|
|
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;
|
|
objectKeys = colorType;
|
|
};
|
|
};
|
|
|
|
in
|
|
{
|
|
options = {
|
|
programs.jq = {
|
|
enable = lib.mkEnableOption "the jq command-line JSON processor";
|
|
|
|
package = lib.mkPackageOption pkgs "jq" { nullable = true; };
|
|
|
|
colors = mkOption {
|
|
description = ''
|
|
The colors used in colored JSON output, or null to use the defaults.
|
|
|
|
See the [Colors section](https://jqlang.github.io/jq/manual/#Colors)
|
|
of the jq manual.
|
|
'';
|
|
|
|
example = {
|
|
null = "1;30";
|
|
false = "0;31";
|
|
true = "0;32";
|
|
numbers = "0;36";
|
|
strings = "0;33";
|
|
arrays = "1;35";
|
|
objects = "1;37";
|
|
objectKeys = "1;34";
|
|
};
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr colorsType;
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
|
|
|
home.sessionVariables =
|
|
let
|
|
c = cfg.colors;
|
|
in
|
|
lib.mkIf (c != null) {
|
|
JQ_COLORS = "${c.null}:${c.false}:${c.true}:${c.numbers}:${c.strings}:${c.arrays}:${c.objects}:${c.objectKeys}";
|
|
};
|
|
};
|
|
}
|