mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
jq: add module
This commit is contained in:
parent
93b10bcf3c
commit
dc72aa2305
3 changed files with 84 additions and 0 deletions
|
@ -895,6 +895,13 @@ in
|
|||
to your configuration.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2018-12-12T21:02:05+00:00";
|
||||
message = ''
|
||||
A new module is available: 'programs.jq'.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ let
|
|||
./programs/home-manager.nix
|
||||
./programs/htop.nix
|
||||
./programs/info.nix
|
||||
./programs/jq.nix
|
||||
./programs/lesspipe.nix
|
||||
./programs/man.nix
|
||||
./programs/mbsync.nix
|
||||
|
|
76
modules/programs/jq.nix
Normal file
76
modules/programs/jq.nix
Normal file
|
@ -0,0 +1,76 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
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;
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
programs.jq = {
|
||||
enable = mkEnableOption "the jq command-line JSON processor";
|
||||
|
||||
colors = mkOption {
|
||||
description = ''
|
||||
The colors used in colored JSON output.</para>
|
||||
|
||||
<para>See <link xlink:href="https://stedolan.github.io/jq/manual/#Colors"/>.
|
||||
'';
|
||||
|
||||
example = literalExample ''
|
||||
{
|
||||
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;39";
|
||||
true = "0;39";
|
||||
numbers = "0;39";
|
||||
strings = "0;32";
|
||||
arrays = "1;39";
|
||||
objects = "1;39";
|
||||
};
|
||||
|
||||
type = colorsType;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ pkgs.jq ];
|
||||
|
||||
home.sessionVariables = let c = cfg.colors; in {
|
||||
JQ_COLORS = "${c.null}:${c.false}:${c.true}:${c.numbers}:${c.strings}:${c.arrays}:${c.objects}";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue