1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-15 13:31:07 +01:00

jq: make colors and package nullable

...and since according to commit
f9b5172d95 the defaults are the upstream
values, default `colors` to null.

Setting JQ_COLORS is just unnecessary environment clutter when using the
default colors.

Although the module now does nothing besides (optionally) installing
`jq` when `colors` is left at its default value, that is still useful:
from a flake with multiple home-manager configurations, some of which
have `jq` provided through other means, setting/forcing
`programs.jq.package` to null is more convenient than conditionally
adding `jq` to `home.packages`.
This commit is contained in:
Marien Zwart 2025-08-31 23:36:32 +10:00 committed by Austin Horstman
parent b4b5f008d7
commit a48dd228d9

View file

@ -35,11 +35,11 @@ in
programs.jq = { programs.jq = {
enable = lib.mkEnableOption "the jq command-line JSON processor"; enable = lib.mkEnableOption "the jq command-line JSON processor";
package = lib.mkPackageOption pkgs "jq" { }; package = lib.mkPackageOption pkgs "jq" { nullable = true; };
colors = mkOption { colors = mkOption {
description = '' description = ''
The colors used in colored JSON output. The colors used in colored JSON output, or null to use the defaults.
See the [Colors section](https://jqlang.github.io/jq/manual/#Colors) See the [Colors section](https://jqlang.github.io/jq/manual/#Colors)
of the jq manual. of the jq manual.
@ -58,30 +58,21 @@ in
} }
''; '';
default = { default = null;
null = "1;30";
false = "0;37";
true = "0;37";
numbers = "0;37";
strings = "0;32";
arrays = "1;37";
objects = "1;37";
objectKeys = "1;34";
};
type = colorsType; type = types.nullOr colorsType;
}; };
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = [ cfg.package ]; home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
home.sessionVariables = home.sessionVariables =
let let
c = cfg.colors; c = cfg.colors;
in in
{ lib.mkIf (c != null) {
JQ_COLORS = "${c.null}:${c.false}:${c.true}:${c.numbers}:${c.strings}:${c.arrays}:${c.objects}:${c.objectKeys}"; JQ_COLORS = "${c.null}:${c.false}:${c.true}:${c.numbers}:${c.strings}:${c.arrays}:${c.objects}:${c.objectKeys}";
}; };
}; };