1{ lib
2, buildPythonPackage
3, fetchPypi
4, substituteAll
5, argcomplete
6, pyyaml
7, xmltodict
8, jq
9, pytestCheckHook
10}:
11
12buildPythonPackage rec {
13 pname = "yq";
14 version = "2.12.2";
15
16 src = fetchPypi {
17 inherit pname version;
18 sha256 = "2f156d0724b61487ac8752ed4eaa702a5737b804d5afa46fa55866951cd106d2";
19 };
20
21 patches = [
22 (substituteAll {
23 src = ./jq-path.patch;
24 jq = "${lib.getBin jq}/bin/jq";
25 })
26 ];
27
28 postPatch = ''
29 substituteInPlace test/test.py \
30 --replace "expect_exit_codes={0} if sys.stdin.isatty() else {2}" "expect_exit_codes={0}"
31 '';
32
33 propagatedBuildInputs = [
34 pyyaml
35 xmltodict
36 argcomplete
37 ];
38
39 checkInputs = [
40 pytestCheckHook
41 ];
42
43 pytestFlagsArray = [ "test/test.py" ];
44
45 pythonImportsCheck = [ "yq" ];
46
47 doInstallCheck = true;
48 installCheckPhase = ''
49 echo '{"hello":{"foo":"bar"}}' | $out/bin/yq -y . | grep 'foo: bar'
50 '';
51
52 meta = with lib; {
53 description = "Command-line YAML processor - jq wrapper for YAML documents";
54 homepage = "https://github.com/kislyuk/yq";
55 license = licenses.asl20;
56 maintainers = with maintainers; [ womfoo SuperSandro2000 ];
57 };
58}