inkscape-extensions.textext: init at 1.8.1

Introduce the 'textext' extension for including LaTeX graphics in Inkscape

Test it with `nix-shell -p "inkscape-with-extensions.override {
inkscapeExtensions = [ inkscape-extensions.textext ]; }" --run inkscape`

Co-Authored-By: Jan Tojnar <jtojnar@gmail.com>

+159
+5
pkgs/applications/graphics/inkscape/extensions.nix
··· 3 3 , runCommand 4 4 , inkcut 5 5 , callPackage 6 + , texlive 6 7 }: 7 8 8 9 { ··· 43 44 mkdir -p $out/share/inkscape/extensions 44 45 cp ${inkcut}/share/inkscape/extensions/* $out/share/inkscape/extensions 45 46 ''); 47 + textext = callPackage ./extensions/textext { 48 + pdflatex = texlive.combined.scheme-basic; 49 + lualatex = texlive.combined.scheme-basic; 50 + }; 46 51 }
+125
pkgs/applications/graphics/inkscape/extensions/textext/default.nix
··· 1 + { lib 2 + , writeScript 3 + , fetchFromGitHub 4 + , substituteAll 5 + , inkscape 6 + , pdflatex 7 + , lualatex 8 + , python3 9 + , wrapGAppsHook 10 + , gobject-introspection 11 + , gtk3 12 + , gtksourceview3 13 + }: 14 + 15 + let 16 + launchScript = writeScript "launch.sh" '' 17 + cd $(dirname $0) 18 + ./__main__.py $* 19 + ''; 20 + in 21 + python3.pkgs.buildPythonApplication rec { 22 + pname = "textext"; 23 + version = "1.8.1"; 24 + 25 + src = fetchFromGitHub { 26 + owner = "textext"; 27 + repo = "textext"; 28 + rev = version; 29 + sha256 = "sha256-Qzd39X0X3DdwZ3pIIGvEbNjl6dxjDf3idzjwCkp3WRg="; 30 + }; 31 + 32 + patches = [ 33 + # Make sure we can point directly to pdflatex in the extension, 34 + # instead of relying on the PATH (which might not have it) 35 + (substituteAll { 36 + src = ./fix-paths.patch; 37 + inherit pdflatex lualatex; 38 + }) 39 + 40 + # Since we are wrapping the extension, we need to change the interpreter 41 + # from Python to Bash. 42 + ./interpreter.patch 43 + ]; 44 + 45 + nativeBuildInputs = [ 46 + wrapGAppsHook 47 + gobject-introspection 48 + ]; 49 + 50 + buildInputs = [ 51 + gtk3 52 + gtksourceview3 53 + ]; 54 + 55 + propagatedBuildInputs = [ 56 + python3.pkgs.pygobject3 57 + # lxml, cssselect and numpy are required by inkex but is not inherited from inkscape when we use custom Python interpreter: 58 + python3.pkgs.lxml 59 + python3.pkgs.cssselect 60 + python3.pkgs.numpy 61 + ]; 62 + 63 + # strictDeps do not play nicely with introspection setup hooks. 64 + # https://github.com/NixOS/nixpkgs/issues/56943 65 + strictDeps = false; 66 + 67 + # TexText doesn’t have a 'bdist_wheel' target. 68 + dontUseSetuptoolsBuild = true; 69 + 70 + # TexText doesn’t have a 'test' target. 71 + doCheck = false; 72 + 73 + # Avoid wrapping two times by just using Python’s wrapping. 74 + dontWrapGApps = true; 75 + 76 + buildPhase = '' 77 + runHook preBuild 78 + 79 + mkdir dist 80 + 81 + # source/setup.py creates a config file in HOME (that we ignore) 82 + mkdir buildhome 83 + export HOME=$(pwd)/buildhome 84 + 85 + python setup.py \ 86 + --inkscape-executable=${inkscape}/bin/inkscape \ 87 + --pdflatex-executable=${pdflatex}/bin/pdflatex \ 88 + --lualatex-executable=${lualatex}/bin/lualatex \ 89 + --inkscape-extensions-path=dist 90 + 91 + runHook postBuild 92 + ''; 93 + 94 + installPhase = '' 95 + runHook preInstall 96 + 97 + mkdir -p $out/share/inkscape/extensions 98 + cp -r dist/textext $out/share/inkscape/extensions 99 + 100 + runHook postInstall 101 + ''; 102 + 103 + preFixup = '' 104 + # Prepare for wrapping 105 + chmod +x "$out/share/inkscape/extensions/textext/__main__.py" 106 + sed -i '1i#!/usr/bin/env python3' "$out/share/inkscape/extensions/textext/__main__.py" 107 + 108 + # Include gobject-introspection typelibs in the wrapper. 109 + makeWrapperArgs+=("''${gappsWrapperArgs[@]}") 110 + ''; 111 + 112 + postFixup = '' 113 + # Wrap the project so it can find runtime dependencies. 114 + wrapPythonProgramsIn "$out/share/inkscape/extensions/textext" "$out $pythonPath" 115 + cp ${launchScript} $out/share/inkscape/extensions/textext/launch.sh 116 + ''; 117 + 118 + meta = with lib; { 119 + description = "Re-editable LaTeX graphics for Inkscape"; 120 + homepage = "https://textext.github.io/textext/"; 121 + license = licenses.bsd3; 122 + maintainers = [ maintainers.raboof ]; 123 + platforms = platforms.all; 124 + }; 125 + }
+19
pkgs/applications/graphics/inkscape/extensions/textext/fix-paths.patch
··· 1 + --- a/textext/base.py 2 + +++ b/textext/base.py 3 + @@ -95,7 +95,16 @@ class TexText(inkex.EffectExtension): 4 + def __init__(self): 5 + 6 + self.config = Settings(directory=defaults.textext_config_path) 7 + + # config.json is stored in ~/.config/inkscape/extensions/textext for 8 + + # the next invocation, but since that next invocation could be using 9 + + # a different latex derivation, make sure we overwrite the executable 10 + + # paths with updated ones: 11 + + self.config["pdflatex-executable"] = "@pdflatex@/bin/pdflatex"; 12 + + self.config["lualatex-executable"] = "@lualatex@/bin/lualatex"; 13 + self.cache = Cache(directory=defaults.textext_config_path) 14 + + if "requirements_checker" in self.cache.values: 15 + + self.cache["requirements_checker"]["available_tex_to_pdf_converters"]["pdflatex"] = "@pdflatex@/bin/pdflatex"; 16 + + self.cache["requirements_checker"]["available_tex_to_pdf_converters"]["lualatex"] = "@lualatex@/bin/lualatex"; 17 + previous_exit_code = self.cache.get("previous_exit_code", None) 18 + 19 + if previous_exit_code is None:
+10
pkgs/applications/graphics/inkscape/extensions/textext/interpreter.patch
··· 1 + --- a/textext/textext.inx 2 + +++ b/textext/textext.inx 3 + @@ -8,6 +8,6 @@ 4 + </effects-menu> 5 + </effect> 6 + <script> 7 + - <command location="inx" interpreter="python">__main__.py</command> 8 + + <command location="inx" interpreter="shell">launch.sh</command> 9 + </script> 10 + </inkscape-extension>