1{ lib
2, stdenv
3, buildPackages
4, buildPythonPackage
5, fetchFromGitHub
6, installShellFiles
7, ruamel-yaml
8, xmltodict
9, pygments
10, pytestCheckHook
11, pythonOlder
12}:
13
14buildPythonPackage rec {
15 pname = "jc";
16 version = "1.23.6";
17 disabled = pythonOlder "3.6";
18
19 src = fetchFromGitHub {
20 owner = "kellyjonbrazil";
21 repo = pname;
22 rev = "refs/tags/v${version}";
23 hash = "sha256-vAPWMv5vYFl45ZTl+p4HHAXeZ/10VSvubKINoyGPRq4=";
24 };
25
26 propagatedBuildInputs = [ ruamel-yaml xmltodict pygments ];
27
28 nativeBuildInputs = [ installShellFiles ];
29
30 postInstall = let emulator = stdenv.hostPlatform.emulator buildPackages; in ''
31 installShellCompletion --cmd jc \
32 --bash <(${emulator} $out/bin/jc --bash-comp) \
33 --zsh <(${emulator} $out/bin/jc --zsh-comp)
34 '';
35
36 nativeCheckInputs = [ pytestCheckHook ];
37
38 pythonImportsCheck = [ "jc" ];
39
40 # tests require timezone to set America/Los_Angeles
41 doCheck = false;
42
43 meta = with lib; {
44 description = "This tool serializes the output of popular command line tools and filetypes to structured JSON output";
45 homepage = "https://github.com/kellyjonbrazil/jc";
46 license = licenses.mit;
47 maintainers = with maintainers; [ atemu ];
48 changelog = "https://github.com/kellyjonbrazil/jc/blob/v${version}/CHANGELOG";
49 mainProgram = "jc";
50 };
51}