1{
2 lib,
3 buildPythonPackage,
4 python,
5 fetchFromGitHub,
6 arpeggio,
7 click,
8 callPackage,
9 flit-core,
10}:
11
12let
13 textx = buildPythonPackage rec {
14 pname = "textx";
15 version = "4.2.2";
16 pyproject = true;
17
18 src = fetchFromGitHub {
19 owner = pname;
20 repo = pname;
21 rev = version;
22 hash = "sha256-AlFXaB+D03GAsXNd2GnFOLxo2g5BjWAu6K1/GsncwLw=";
23 };
24
25 outputs = [
26 "out"
27 "testout"
28 ];
29
30 build-system = [ flit-core ];
31
32 dependencies = [ arpeggio ];
33
34 postInstall = ''
35 # FileNotFoundError: [Errno 2] No such file or directory: '$out/lib/python3.10/site-packages/textx/textx.tx
36 cp "$src/textx/textx.tx" "$out/${python.sitePackages}/${pname}/"
37
38 # Install tests as the tests output.
39 mkdir $testout
40 cp -r tests $testout/tests
41 '';
42
43 pythonImportsCheck = [ "textx" ];
44
45 # Circular dependencies, do tests in passthru.tests instead.
46 doCheck = false;
47
48 passthru.tests = {
49 textxTests = callPackage ./tests.nix {
50 inherit
51 textx-data-dsl
52 textx-example-project
53 textx-flow-codegen
54 textx-flow-dsl
55 textx-types-dsl
56 ;
57 };
58 };
59
60 meta = with lib; {
61 description = "Domain-specific languages and parsers in Python";
62 mainProgram = "textx";
63 homepage = "https://github.com/textx/textx/";
64 license = licenses.mit;
65 maintainers = with maintainers; [ ];
66 };
67 };
68
69 textx-data-dsl = buildPythonPackage rec {
70 pname = "textx-data-dsl";
71 version = "1.0.0";
72 pyproject = true;
73
74 inherit (textx) src;
75 pathToSourceRoot = "tests/functional/registration/projects/data_dsl";
76 sourceRoot = "${src.name}/" + pathToSourceRoot;
77
78 build-system = [ flit-core ];
79
80 dependencies = [
81 textx
82 textx-types-dsl
83 ];
84
85 meta = with lib; {
86 inherit (textx.meta) license maintainers;
87 description = "Sample textX language for testing";
88 homepage = textx.meta.homepage + "tree/${version}/" + pathToSourceRoot;
89 };
90 };
91
92 textx-flow-codegen = buildPythonPackage rec {
93 pname = "textx-flow-codegen";
94 version = "1.0.0";
95 pyproject = true;
96
97 inherit (textx) src;
98
99 pathToSourceRoot = "tests/functional/registration/projects/flow_codegen";
100 sourceRoot = "${src.name}/" + pathToSourceRoot;
101
102 build-system = [ flit-core ];
103 dependencies = [
104 textx
105 click
106 ];
107
108 meta = with lib; {
109 inherit (textx.meta) license maintainers;
110 description = "Sample textX language for testing";
111 homepage = textx.meta.homepage + "tree/${version}/" + pathToSourceRoot;
112 };
113 };
114
115 textx-flow-dsl = buildPythonPackage rec {
116 pname = "textx-flow-dsl";
117 version = "1.0.0";
118 pyproject = true;
119
120 inherit (textx) src;
121
122 pathToSourceRoot = "tests/functional/registration/projects/flow_dsl";
123 sourceRoot = "${src.name}/" + pathToSourceRoot;
124
125 build-system = [ flit-core ];
126 dependencies = [ textx ];
127
128 meta = with lib; {
129 inherit (textx.meta) license maintainers;
130 description = "Sample textX language for testing";
131 homepage = textx.meta.homepage + "tree/${version}/" + pathToSourceRoot;
132 };
133 };
134
135 textx-types-dsl = buildPythonPackage rec {
136 pname = "textx-types-dsl";
137 version = "1.0.0";
138 pyproject = true;
139
140 inherit (textx) src;
141
142 pathToSourceRoot = "tests/functional/registration/projects/types_dsl";
143 sourceRoot = "${src.name}/" + pathToSourceRoot;
144
145 build-system = [ flit-core ];
146 dependencies = [ textx ];
147
148 meta = with lib; {
149 inherit (textx.meta) license maintainers;
150 description = "Sample textX language for testing";
151 homepage = textx.meta.homepage + "tree/${version}/" + pathToSourceRoot;
152 };
153 };
154
155 textx-example-project = buildPythonPackage rec {
156 pname = "textx-example-project";
157 version = "1.0.0";
158 pyproject = true;
159
160 inherit (textx) src;
161
162 pathToSourceRoot = "tests/functional/subcommands/example_project";
163 sourceRoot = "${src.name}/" + pathToSourceRoot;
164
165 build-system = [ flit-core ];
166 dependencies = [ textx ];
167
168 meta = with lib; {
169 inherit (textx.meta) license maintainers;
170 description = "Sample textX sub-command for testing";
171 homepage = textx.meta.homepage + "tree/${version}/" + pathToSourceRoot;
172 };
173 };
174in
175textx