diff --git a/pkgs/applications/graphics/inkscape/default.nix b/pkgs/applications/graphics/inkscape/default.nix index 813db0984751..c65dfa1b6c08 100644 --- a/pkgs/applications/graphics/inkscape/default.nix +++ b/pkgs/applications/graphics/inkscape/default.nix @@ -4,6 +4,7 @@ , cairo , cmake , fetchurl +, fetchpatch , gettext , ghostscript , glib @@ -71,6 +72,15 @@ stdenv.mkDerivation rec { # e.g., those from the "Effects" menu. python3 = "${python3Env}/bin/python"; }) + + # Fix parsing paths by Python extensions. + # https://gitlab.com/inkscape/extensions/-/merge_requests/342 + (fetchpatch { + url = "https://gitlab.com/inkscape/extensions/-/commit/a82c382c610d37837c8f3f5b13224bab8fd3667e.patch"; + sha256 = "YWrgjCnQ9q6BUsxSLQojIXnDzPxM/SgrIfj1gxQ/JKM="; + stripLen = 1; + extraPrefix = "share/extensions/"; + }) ]; postPatch = '' diff --git a/pkgs/applications/graphics/inkscape/extensions.nix b/pkgs/applications/graphics/inkscape/extensions.nix index affd934e9368..63010a19f14d 100644 --- a/pkgs/applications/graphics/inkscape/extensions.nix +++ b/pkgs/applications/graphics/inkscape/extensions.nix @@ -2,9 +2,12 @@ , fetchFromGitHub , runCommand , inkcut +, callPackage }: { + applytransforms = callPackage ./extensions/applytransforms { }; + hexmap = stdenv.mkDerivation { name = "hexmap"; version = "2020-06-06"; diff --git a/pkgs/applications/graphics/inkscape/extensions/applytransforms/default.nix b/pkgs/applications/graphics/inkscape/extensions/applytransforms/default.nix new file mode 100644 index 000000000000..131daffffb9d --- /dev/null +++ b/pkgs/applications/graphics/inkscape/extensions/applytransforms/default.nix @@ -0,0 +1,42 @@ +{ lib +, stdenv +, fetchFromGitHub +, python3 +}: + +stdenv.mkDerivation { + pname = "inkscape-applytransforms"; + version = "0.0.0+unstable=2021-05-11"; + + src = fetchFromGitHub { + owner = "Klowner"; + repo = "inkscape-applytransforms"; + rev = "5b3ed4af0fb66e399e686fc2b649b56db84f6042"; + sha256 = "XWwkuw+Um/cflRWjIeIgQUxJLrk2DLDmx7K+pMWvIlI="; + }; + + checkInputs = [ + python3.pkgs.inkex + python3.pkgs.pytestCheckHook + ]; + + dontBuild = true; + + doCheck = true; + + installPhase = '' + runHook preInstall + + install -Dt "$out/share/inkscape/extensions" *.inx *.py + + runHook postInstall + ''; + + meta = with lib; { + description = "Inkscape extension which removes all matrix transforms by applying them recursively to shapes"; + homepage = "https://github.com/Klowner/inkscape-applytransforms"; + license = licenses.gpl2Only; + maintainers = with maintainers; [ jtojnar ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/applications/graphics/inkscape/with-extensions.nix b/pkgs/applications/graphics/inkscape/with-extensions.nix index c558a6bb0622..14fffadd0360 100644 --- a/pkgs/applications/graphics/inkscape/with-extensions.nix +++ b/pkgs/applications/graphics/inkscape/with-extensions.nix @@ -2,13 +2,19 @@ , inkscape , symlinkJoin , makeWrapper -, inkscapeExtensions ? [] +, inkscapeExtensions ? [ ] +, inkscape-extensions }: +let + allExtensions = lib.filter (pkg: lib.isDerivation pkg && !pkg.meta.broken or false) (lib.attrValues inkscape-extensions); + selectedExtensions = if inkscapeExtensions == null then allExtensions else inkscapeExtensions; +in + symlinkJoin { name = "inkscape-with-extensions-${lib.getVersion inkscape}"; - paths = [ inkscape ] ++ inkscapeExtensions; + paths = [ inkscape ] ++ selectedExtensions; nativeBuildInputs = [ makeWrapper ]; diff --git a/pkgs/development/python-modules/inkex/default.nix b/pkgs/development/python-modules/inkex/default.nix new file mode 100644 index 000000000000..c1c5479dfd8f --- /dev/null +++ b/pkgs/development/python-modules/inkex/default.nix @@ -0,0 +1,41 @@ +{ buildPythonPackage +, inkscape +, lxml +, python +}: + +buildPythonPackage { + pname = "inkex"; + inherit (inkscape) version; + + format = "other"; + + propagatedBuildInputs = [ + lxml + ]; + + # We just copy the files. + dontUnpack = true; + dontBuild = true; + + # No tests installed. + doCheck = false; + + installPhase = '' + runHook preInstall + + mkdir -p "$out/${python.sitePackages}" + cp -r "${inkscape}/share/inkscape/extensions/inkex" "$out/${python.sitePackages}" + + runHook postInstall + ''; + + meta = inkscape.meta // { + description = "Inkscape Extensions Library"; + longDescription = '' + This module provides support for inkscape extensions, it includes support for opening svg files and processing them. + + Standalone, it is especially useful for running tests for Inkscape extensions. + ''; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index f97c847dac53..783c75f1134d 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -3498,6 +3498,8 @@ in { injector = callPackage ../development/python-modules/injector { }; + inkex = callPackage ../development/python-modules/inkex { }; + inotify-simple = callPackage ../development/python-modules/inotify-simple { }; inquirer = callPackage ../development/python-modules/inquirer { };