{ pkgs ? import {}, }: let version = "git"; dependencies = with pkgs.python3.pkgs; [ (callPackage ./pystitch.nix {}) inkex wxpython networkx shapely lxml platformdirs numpy jinja2 requests colormath2 flask fonttools trimesh scipy diskcache flask-cors ] # Inkstitch uses the builtin tomllib instead when Python >=3.11 ++ lib.optional (pythonOlder "3.11") tomli; pyEnv = pkgs.python3.withPackages (_: dependencies); in pkgs.python3.pkgs.buildPythonApplication { pname = "inkstitch"; inherit version; pyproject = false; # Uses a Makefile (yikes) src = pkgs.nix-gitignore.gitignoreSource [] ./.; nativeBuildInputs = [ pkgs.gettext pkgs.pyenv ]; inherit dependencies; env = { # to overwrite version string GITHUB_REF = version; BUILD = "nixpkgs"; }; makeFlags = [ "manual" ]; installPhase = '' runHook preInstall mkdir -p $out/share/inkscape/extensions cp -a . $out/share/inkscape/extensions/inkstitch runHook postInstall ''; patches = [ ./0001-force-frozen-true.patch ./0002-plugin-invocation-use-python-script-as-entrypoint.patch ]; postPatch = '' # Add shebang with python dependencies substituteInPlace lib/inx/utils.py --replace-fail ' interpreter="python"' "" sed -i -e '1i#!${pyEnv.interpreter}' inkstitch.py chmod a+x inkstitch.py ''; nativeCheckInputs = with pkgs.python3.pkgs; [ pytestCheckHook ]; meta = { description = "Inkscape extension for machine embroidery design"; homepage = "https://inkstitch.org/"; license = with pkgs.lib.licenses; [ gpl3Plus ]; maintainers = with pkgs.lib.maintainers; [ tropf pluiedev ]; }; }