1{
2 fetchFromGitHub,
3 lib,
4 gettext,
5 python3,
6 udevCheckHook,
7 umockdev,
8 writeScript,
9}:
10
11let
12 # We need these simple wrapper shell scripts because Inkscape extensions with
13 # interpreter="shell" always get invoked with the `sh` command [0], regardless of
14 # the shebang at the top of the script.
15 # [0]: https://gitlab.com/inkscape/inkscape/-/blob/d61d917afb94721c92a650b2c4b116b0a4826f41/src/extension/implementation/script.cpp#L93
16 launch-sendto_silhouette = writeScript "sendto_silhouette.sh" ''
17 cd $(dirname $0)
18 ./sendto_silhouette.py "$@"
19 '';
20 launch-silhouette_multi = writeScript "silhouette_multi.sh" ''
21 cd $(dirname $0)
22 ./silhouette_multi.py "$@"
23 '';
24in
25python3.pkgs.buildPythonApplication rec {
26 pname = "inkscape-silhouette";
27 version = "1.29";
28 format = "setuptools";
29
30 src = fetchFromGitHub {
31 owner = "fablabnbg";
32 repo = pname;
33 tag = "v${version}";
34 sha256 = "sha256-MfR88BuaAx6n5XRIjslpIk4PnDf6TLU9AsmHxKkcFS0=";
35 };
36
37 patches = [
38 ./interpreter.patch
39 ./use-prefix-for-udev.patch
40 ];
41
42 propagatedBuildInputs = [
43 python3.pkgs.pyusb
44 python3.pkgs.lxml
45 python3.pkgs.inkex
46 python3.pkgs.matplotlib
47 python3.pkgs.wxpython
48 python3.pkgs.xmltodict
49 ];
50
51 nativeBuildInputs = [
52 gettext # msgfmt
53 ];
54
55 nativeCheckInputs = [
56 python3.pkgs.pytestCheckHook
57 udevCheckHook
58 umockdev
59 ];
60
61 enabledTestPaths = [
62 "test"
63 ];
64
65 doCheck = true;
66 doInstallCheck = true;
67
68 installPhase = ''
69 runHook preInstall
70 make install PREFIX=$out
71 runHook postInstall
72 '';
73
74 postInstall = ''
75 # Unmark read_dump.py as executable so wrapPythonProgramsIn won't turn it
76 # into a shell script (thereby making it impossible to import as a Python
77 # module).
78 chmod -x $out/share/inkscape/extensions/silhouette/read_dump.py
79 cp ${launch-sendto_silhouette} $out/share/inkscape/extensions/sendto_silhouette.sh
80 cp ${launch-silhouette_multi} $out/share/inkscape/extensions/silhouette_multi.sh
81 '';
82
83 postFixup = ''
84 wrapPythonProgramsIn "$out/share/inkscape/extensions/" "$out $pythonPath"
85 '';
86
87 meta = with lib; {
88 description = "Extension to drive Silhouette vinyl cutters (e.g. Cameo, Portrait, Curio series) from within Inkscape";
89 homepage = "https://github.com/fablabnbg/inkscape-silhouette";
90 license = licenses.gpl2Only;
91 maintainers = with maintainers; [ jfly ];
92 platforms = platforms.all;
93 };
94}