nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, buildPythonPackage
3, pythonOlder
4, fetchFromGitHub
5, black
6, jinja2
7, poetry-core
8, round
9, graphviz
10, inkscape
11, imagemagick
12, pytestCheckHook
13}:
14
15buildPythonPackage rec {
16 pname = "diagrams";
17 version = "0.21.1";
18 format = "pyproject";
19 disabled = pythonOlder "3.6";
20
21 src = fetchFromGitHub {
22 owner = "mingrammer";
23 repo = pname;
24 rev = "v${version}";
25 sha256 = "sha256-YoXV5ikkBCSVyGmzEqp+7JLy82d7z9sbwS+U/EN3BFk=";
26 };
27
28 postPatch = ''
29 substituteInPlace pyproject.toml \
30 --replace 'graphviz = ">=0.13.2,<0.20.0"' 'graphviz = "*"'
31 '';
32
33 preConfigure = ''
34 patchShebangs autogen.sh
35 ./autogen.sh
36 '';
37
38 patches = [
39 # The build-system section is missing
40 ./build_poetry.patch
41 ];
42
43 checkInputs = [ pytestCheckHook ];
44
45 # Despite living in 'tool.poetry.dependencies',
46 # these are only used at build time to process the image resource files
47 nativeBuildInputs = [ black inkscape imagemagick jinja2 poetry-core round ];
48
49 propagatedBuildInputs = [ graphviz ];
50
51 pythonImportsCheck = [ "diagrams" ];
52
53 meta = with lib; {
54 description = "Diagram as Code";
55 homepage = "https://diagrams.mingrammer.com/";
56 license = licenses.mit;
57 maintainers = with maintainers; [ addict3d ];
58 };
59}