fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . programs . jq ; 8 9colorType = mkOption { 10type = types . str ; 11description = "ANSI color definition" ; 12example = "1;31" ; 13visible = false ; 14}; 15 16colorsType = types . submodule { 17options = { 18null = colorType ; 19false = colorType ; 20true = colorType ; 21numbers = colorType ; 22strings = colorType ; 23arrays = colorType ; 24objects = colorType ; 25}; 26}; 27 28in { 29options = { 30programs . jq = { 31enable = mkEnableOption "the jq command-line JSON processor" ; 32 33package = mkOption { 34type = types . package ; 35default = pkgs . jq ; 36defaultText = literalExpression "pkgs.jq" ; 37description = "jq package to use." ; 38}; 39 40colors = mkOption { 41description = '' 42The colors used in colored JSON output. 43 44See the [Colors section](https://jqlang.github.io/jq/manual/#Colors) 45of the jq manual. 46'' ; 47 48example = literalExpression '' 49{ 50null = "1;30"; 51false = "0;31"; 52true = "0;32"; 53numbers = "0;36"; 54strings = "0;33"; 55arrays = "1;35"; 56objects = "1;37"; 57} 58'' ; 59 60default = { 61null = "1;30" ; 62false = "0;37" ; 63true = "0;37" ; 64numbers = "0;37" ; 65strings = "0;32" ; 66arrays = "1;37" ; 67objects = "1;37" ; 68}; 69 70type = colorsType ; 71}; 72}; 73}; 74 75config = mkIf cfg . enable { 76home . packages = [ cfg . package ]; 77 78home . sessionVariables = let c = cfg . colors ; 79in { 80JQ_COLORS = 81" ${ c . null } : ${ c . false } : ${ c . true } : ${ c . numbers } : ${ c . strings } : ${ c . arrays } : ${ c . objects } " ; 82}; 83}; 84}