about summary refs log tree commit diff
path: root/pkgs/applications/misc/printrun/default.nix
blob: 884ce49dd8347ea6bde0b92004fd9b7aef0a28f6 (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
{ lib, python3Packages, fetchFromGitHub, glib, wrapGAppsHook3 }:

python3Packages.buildPythonApplication rec {
  pname = "printrun";
  version = "2.0.1";

  src = fetchFromGitHub {
    owner = "kliment";
    repo = "Printrun";
    rev = "refs/tags/printrun-${version}";
    hash = "sha256-GmTA/C45MuptN/Y0KjpFjaLV3sWoM4rHz8AMfV9sf4U=";
  };

  postPatch = ''
    substituteInPlace requirements.txt \
      --replace "pyglet >= 1.1, < 2.0" "pyglet" \
      --replace "cairosvg >= 1.0.9, < 2.6.0" "cairosvg"
    sed -i -r "s|/usr(/local)?/share/|$out/share/|g" printrun/utils.py
  '';

  nativeBuildInputs = [ glib wrapGAppsHook3 ];

  propagatedBuildInputs = with python3Packages; [
    appdirs cython dbus-python numpy six wxpython psutil pyglet pyopengl pyserial cffi cairosvg lxml
  ];

  # pyglet.canvas.xlib.NoSuchDisplayException: Cannot connect to "None"
  doCheck = false;

  setupPyBuildFlags = ["-i"];

  postInstall = ''
    for f in $out/share/applications/*.desktop; do
      sed -i -e "s|/usr/|$out/|g" "$f"
    done
  '';

  dontWrapGApps = true;

  preFixup = ''
    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
  '';

  meta = with lib; {
    description = "Pronterface, Pronsole, and Printcore - Pure Python 3d printing host software";
    homepage = "https://github.com/kliment/Printrun";
    license = licenses.gpl3Plus;
    platforms = platforms.linux;
  };
}