How to define an inkscape extension with python dependencies?

The various inkscape extensions currently in nixpkgs are simple python extensions with no 3rd party python dependencies of their own.

The list of python dependencies available to the inkspace python interpreter is hardcoded here.

As far as I can tell, there’s currently no “good” way of defining a new inkscape extension with its own python dependencies. What’s the best way of accomplishing this? A couple of ideas:

  1. Tweak pkgs/applications/graphics/inkscape/with-extensions.nix to pull a list of python dependencies from the given inkscapeExtensions and thread those through to inkscape itself so it can define the appropriate set of python deps.
  2. Stop hardcoding a path to Python in the inkscape derivation. Instead, let it look Python up from the PATH, and carefully wrap inkscape so it has an appropriate PATH environment variable set.
  1. is a bit unfortunate because it requires recompiling all of inkscape just when a new python dep appears.

I don’t know if there are any serious downsides to 2). Perhaps it wouldn’t play nicely with certain other types of PATH rewriting?

I wonder how hard it would be to patch inkscape (or perhaps it is already possible) to allow each extension to define its own full path to python, and then use that?

You can do it by changing extension’s interpreter to shell and then patching the extension to use python3.withPackages (...) in a shebang. You are already doing that in https://github.com/NixOS/nixpkgs/pull/121711.

1 Like

Thanks for the pointers! Doing this as a shell script makes a lot of sense. See inkscape/silhouette: init at 1.28.pre by jfly · Pull Request #239349 · NixOS/nixpkgs · GitHub =)