diff --git a/modules/programs/jq.nix b/modules/programs/jq.nix index 527dbcc8..cb2b807c 100644 --- a/modules/programs/jq.nix +++ b/modules/programs/jq.nix @@ -35,11 +35,11 @@ in programs.jq = { enable = lib.mkEnableOption "the jq command-line JSON processor"; - package = lib.mkPackageOption pkgs "jq" { }; + package = lib.mkPackageOption pkgs "jq" { nullable = true; }; colors = mkOption { 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) of the jq manual. @@ -58,30 +58,21 @@ in } ''; - default = { - null = "1;30"; - false = "0;37"; - true = "0;37"; - numbers = "0;37"; - strings = "0;32"; - arrays = "1;37"; - objects = "1;37"; - objectKeys = "1;34"; - }; + default = null; - type = colorsType; + type = types.nullOr colorsType; }; }; }; config = mkIf cfg.enable { - home.packages = [ cfg.package ]; + 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}"; }; };