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