summary refs log tree commit diff
path: root/pkgs/applications/misc/k40-whisperer/default.nix
blob: a6059ae44f88fac48b19ef3ea22b9fa358d03969 (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
{ stdenv
, makeWrapper
, writeText
, python3
, fetchzip
, inkscape
, lib
, udevGroup ? "k40"
}:

let
  pythonEnv = python3.withPackages (ps: with ps; [
    lxml
    pyusb
    pillow
    pyclipper
    tkinter
  ]);

  udevRule = writeText "k40-whisperer.rules" ''
    SUBSYSTEM=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="5512", ENV{DEVTYPE}=="usb_device", MODE="0664", GROUP="${udevGroup}"
  '';

in stdenv.mkDerivation rec {
  pname = "k40-whisperer";
  version = "0.67";

  src = fetchzip {
    url = "https://www.scorchworks.com/K40whisperer/K40_Whisperer-${version}_src.zip";
    stripRoot = true;
    sha256 = "sha256-jyny5uNZ5eL4AV47uAgOhBe4Zqg8GK3e86Z9gZbC68s=";
  };

  nativeBuildInputs = [ makeWrapper ];

  patchPhase = ''
    substituteInPlace svg_reader.py \
      --replace '"/usr/bin/inkscape"' '"${inkscape}/bin/inkscape"'
  '';

  buildPhase = "";

  installPhase = ''
    mkdir -p $out
    cp -p * $out

    mkdir -p $out/bin
    mkdir -p $out/lib/udev/rules.d

    ln -s ${udevRule} $out/lib/udev/rules.d/97-k40-whisperer.rules

    makeWrapper '${pythonEnv.interpreter}' $out/bin/k40-whisperer \
      --add-flags $out/k40_whisperer.py \
      --prefix PYTHONPATH : $out
  '';

  meta = with lib; {
    description = ''
      Control software for the stock K40 Laser controller
    '';
    mainProgram = "k40-whisperer";
    longDescription = ''
      K40 Whisperer is an alternative to the the Laser Draw (LaserDRW) program that comes with the cheap Chinese laser cutters available on E-Bay and Amazon.
      K40 Whisperer reads SVG and DXF files, interprets the data and sends commands to the K40 controller to move the laser head and control the laser accordingly.
      K40 Whisperer does not require a USB key (dongle) to function.
    '';
    homepage = "https://www.scorchworks.com/K40whisperer/k40whisperer.html";
    downloadPage = "https://www.scorchworks.com/K40whisperer/k40whisperer.html#download";
    license = licenses.gpl3;
    maintainers = with maintainers; [ fooker ];
    platforms = platforms.all;
  };
}