summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/diagrams/default.nix
blob: bfd3c588822fbcff63eb4c9edca52e93a0e5c5f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  fetchpatch,
  graphviz,
  imagemagick,
  inkscape,
  jinja2,
  poetry-core,
  pytestCheckHook,
  round,
}:

buildPythonPackage rec {
  pname = "diagrams";
  version = "0.24.4";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "mingrammer";
    repo = "diagrams";
    tag = "v${version}";
    hash = "sha256-N4JGrtgLgGUayFR6/xTf3GZEZjtxC/4De3ZCfRZbi6M=";
  };

  patches = [
    # Add build-system, https://github.com/mingrammer/diagrams/pull/1089
    ./0001-Add-build-system-section.patch
    # Fix poetry include, https://github.com/mingrammer/diagrams/pull/1128
    ./0002-Fix-packaging-Ensure-resources-are-included.patch
    ./remove-black-requirement.patch
  ];

  pythonRemoveDeps = [ "pre-commit" ];

  pythonRelaxDeps = [ "graphviz" ];

  preConfigure = ''
    patchShebangs autogen.sh
    ./autogen.sh
  '';

  build-system = [ poetry-core ];

  # Despite living in 'tool.poetry.dependencies',
  # these are only used at build time to process the image resource files
  nativeBuildInputs = [
    inkscape
    imagemagick
    jinja2
    round
  ];

  dependencies = [ graphviz ];

  nativeCheckInputs = [ pytestCheckHook ];

  pythonImportsCheck = [ "diagrams" ];

  meta = {
    description = "Diagram as Code";
    homepage = "https://diagrams.mingrammer.com/";
    changelog = "https://github.com/mingrammer/diagrams/releases/tag/${src.tag}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ addict3d ];
  };
}