about summary refs log tree commit diff
path: root/pkgs/by-name/ge/gerbolyze/package.nix
blob: 2ce40c37723423b0a5e80f1fcb89b3ed04c5f703 (plain) (blame)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{ lib
, stdenv
, python3Packages
, fetchFromGitHub
, resvg
}:

let
  version = "3.1.7";
  src = fetchFromGitHub {
    owner = "jaseg";
    repo = "gerbolyze";
    rev = "v${version}";
    hash = "sha256-0iTelSlUJUafclRowwsUAoO44nc/AXaOKXnZKfKOIaE=";
    fetchSubmodules = true;
  };

  svg-flatten = stdenv.mkDerivation rec {
    inherit version src;
    pname = "svg-flatten";

    sourceRoot = "${src.name}/svg-flatten";

    postPatch = ''
      substituteInPlace Makefile \
        --replace "$(INSTALL) $(BUILDDIR)/$(BINARY) $(PREFIX)/bin" \
        "$(INSTALL) $(BUILDDIR)/$(BINARY) $(PREFIX)/bin/svg-flatten" \
    '';

    installPhase = ''
      runHook preInstall
      mkdir -p $out/bin
      PREFIX=$out make install
      runHook postInstall
    '';

    meta = with lib; {
      description = "svg-flatten SVG downconverter";
      homepage = "https://github.com/jaseg/gerbolyze";
      license = with licenses; [ agpl3Plus ];
      maintainers = with maintainers; [ wulfsta ];
      mainProgram = "svg-flatten";
      platforms = platforms.linux;
    };
  };

  # FIXME: check if this downgrade is still required when bumping gerbolyze
  # https://github.com/jaseg/gerbolyze/issues/47
  resvg' = resvg.overrideAttrs (old: rec {
    version = "0.41.0";
    src = old.src.override {
      rev = "v${version}";
      hash = "sha256-plZiyEiBWeV2mwTsNK5Je8Axs/hcHH8aV2VpOix6QCY=";
    };
    cargoDeps = old.cargoDeps.overrideAttrs (lib.const {
      name = "${old.pname}-${version}-vendor.tar.gz";
      inherit src;
      outputHash = "sha256-U7xzb9e9wh9XbLvlYQ0ofIjH8FuSzVcrXnrehQmZgww=";
    });
  });

in python3Packages.buildPythonApplication rec {
  inherit version src;
  pname = "gerbolyze";

  format = "setuptools";

  nativeBuildInputs = [
    python3Packages.setuptools
  ];

  propagatedBuildInputs = [
    python3Packages.beautifulsoup4
    python3Packages.click
    python3Packages.numpy
    python3Packages.scipy
    python3Packages.python-slugify
    python3Packages.lxml
    python3Packages.gerbonara
    resvg'
    svg-flatten
  ];

  preConfigure = ''
    # setup.py tries to execute a call to git in a subprocess, this avoids it.
    substituteInPlace setup.py \
      --replace "version = get_version()," \
                "version = '${version}'," \

    # setup.py tries to execute a call to git in a subprocess, this avoids it.
    substituteInPlace setup.py \
      --replace "long_description=format_readme_for_pypi()," \
                "long_description='\n'.join(Path('README.rst').read_text().splitlines()),"
  '';

  pythonImportsCheck = [ "gerbolyze" ];

  nativeCheckInputs = [ python3Packages.pytestCheckHook resvg' svg-flatten ];

  meta = with lib; {
    description = "Directly render SVG overlays into Gerber and Excellon files";
    homepage = "https://github.com/jaseg/gerbolyze";
    license = with licenses; [ agpl3Plus ];
    maintainers = with maintainers; [ wulfsta ];
    mainProgram = "gerbolyze";
    platforms = platforms.linux;
  };
}