From f36388e25a5dab8ff04f177e8c10e2359aab33bf Mon Sep 17 00:00:00 2001 From: Nico Felbinger Date: Thu, 19 Dec 2024 19:13:57 +0100 Subject: [PATCH 1/6] inkscape-extensions.inkstitch: fix editor opening Co-authored-by: tropf <29873239+tropf@users.noreply.github.com> --- .../inkstitch/0001-force-frozen-true.patch | 27 +++++++++++++++ ...tion-use-python-script-as-entrypoint.patch | 34 +++++++++++++++++++ .../inkscape/extensions/inkstitch/default.nix | 20 +++++++++-- 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 pkgs/applications/graphics/inkscape/extensions/inkstitch/0001-force-frozen-true.patch create mode 100644 pkgs/applications/graphics/inkscape/extensions/inkstitch/0002-plugin-invocation-use-python-script-as-entrypoint.patch diff --git a/pkgs/applications/graphics/inkscape/extensions/inkstitch/0001-force-frozen-true.patch b/pkgs/applications/graphics/inkscape/extensions/inkstitch/0001-force-frozen-true.patch new file mode 100644 index 000000000000..ef345bb0aeb0 --- /dev/null +++ b/pkgs/applications/graphics/inkscape/extensions/inkstitch/0001-force-frozen-true.patch @@ -0,0 +1,27 @@ +From af541a4f8ddda287f74687327e4ed89b79557777 Mon Sep 17 00:00:00 2001 +From: tropf +Date: Mon, 5 Aug 2024 21:25:33 +0200 +Subject: [PATCH 1/3] force frozen=true + +Enforce installation in frozen mode, i.e. as a packaged version where +source can not be modified. +--- + inkstitch.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/inkstitch.py b/inkstitch.py +index 50f33d19..398465ca 100644 +--- a/inkstitch.py ++++ b/inkstitch.py +@@ -40,7 +40,7 @@ else: + ini = {} + # -------------------------------------------------------------------------------------------- + +-running_as_frozen = getattr(sys, 'frozen', None) is not None # check if running from pyinstaller bundle ++running_as_frozen = True + + if not running_as_frozen: # override running_as_frozen from DEBUG.toml - for testing + if safe_get(ini, "DEBUG", "force_frozen", default=False): +-- +2.36.0 + diff --git a/pkgs/applications/graphics/inkscape/extensions/inkstitch/0002-plugin-invocation-use-python-script-as-entrypoint.patch b/pkgs/applications/graphics/inkscape/extensions/inkstitch/0002-plugin-invocation-use-python-script-as-entrypoint.patch new file mode 100644 index 000000000000..3db643c9f07b --- /dev/null +++ b/pkgs/applications/graphics/inkscape/extensions/inkstitch/0002-plugin-invocation-use-python-script-as-entrypoint.patch @@ -0,0 +1,34 @@ +From a86412c57833c24743214c9d3abb76093365769f Mon Sep 17 00:00:00 2001 +From: tropf +Date: Mon, 5 Aug 2024 21:26:13 +0200 +Subject: [PATCH 2/3] plugin invocation: use python script as entrypoint + +Ink/Stitch is invoked by calling a script with command line parameters. +Depending on the distribution format, this is bundled into a standalone +binary -- at least for vanilla Ink/Stitch. For the nix version, we +follow manual install, which does *not* bundle the file. Hence, the +generation is patched to treat this packaged install as manual install, +and to still refer to the python file. + +To keep the patchset small, only an if statement is changed, with the +intent of only using the else path. +--- + lib/inx/utils.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/inx/utils.py b/lib/inx/utils.py +index 9168f2a2..00313639 100755 +--- a/lib/inx/utils.py ++++ b/lib/inx/utils.py +@@ -21,7 +21,7 @@ def build_environment(): + extensions=['jinja2.ext.i18n'] + ) + +- if "BUILD" in os.environ: ++ if False: + # building a ZIP release, with inkstitch packaged as a binary + # Command tag and icons path + if sys.platform == "win32": +-- +2.36.0 + diff --git a/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix index 0b07ee67a5f0..f3141c689d3b 100644 --- a/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix +++ b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix @@ -7,7 +7,7 @@ let version = "3.1.0"; in -python3.pkgs.buildPythonApplication { +python3.pkgs.buildPythonApplication rec { pname = "inkstitch"; inherit version; pyproject = false; # Uses a Makefile (yikes) @@ -54,11 +54,27 @@ python3.pkgs.buildPythonApplication { runHook preInstall mkdir -p $out/share/inkscape/extensions - cp -a inx $out/share/inkscape/extensions/inkstitch + 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 = + let + pyEnv = python3.withPackages (_: dependencies); + in + '' + # 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 python3.pkgs; [ pytestCheckHook ]; From 7f57cfed98eb27513269c087c29e70dc2e596d20 Mon Sep 17 00:00:00 2001 From: tropf Date: Fri, 20 Dec 2024 12:41:17 +0100 Subject: [PATCH 2/6] maintainer: add tropf --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 294df339e0d2..199bbfe6dff8 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -23058,6 +23058,12 @@ githubId = 504580; name = "Thibaut Robert"; }; + tropf = { + name = "tropf"; + matrix = "@tropf:matrix.org"; + github = "tropf"; + githubId = 29873239; + }; troydm = { email = "d.geurkov@gmail.com"; github = "troydm"; From 40cd3e0ddca0a58a9e2a2acbd3dc6049881e5750 Mon Sep 17 00:00:00 2001 From: tropf Date: Fri, 20 Dec 2024 12:42:33 +0100 Subject: [PATCH 3/6] inkscape-extensions.inkstitch: add tropf as maintainer --- .../graphics/inkscape/extensions/inkstitch/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix index f3141c689d3b..c6e2b023480c 100644 --- a/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix +++ b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix @@ -83,6 +83,9 @@ python3.pkgs.buildPythonApplication rec { description = "Inkscape extension for machine embroidery design"; homepage = "https://inkstitch.org/"; license = with lib.licenses; [ gpl3Plus ]; - maintainers = with lib.maintainers; [ pluiedev ]; + maintainers = with lib.maintainers; [ + tropf + pluiedev + ]; }; } From 3773a1f21685f4abbda3b886149dd76a95896591 Mon Sep 17 00:00:00 2001 From: tropf Date: Fri, 20 Dec 2024 11:00:35 +0100 Subject: [PATCH 4/6] inkscape-extensions.inkstitch: add implicit dependencies in build Inkstitch assumes its runtime python environment to be present during build, so provide it. --- .../inkscape/extensions/inkstitch/default.nix | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix index c6e2b023480c..5b55b6f76f3e 100644 --- a/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix +++ b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix @@ -6,23 +6,6 @@ }: let version = "3.1.0"; -in -python3.pkgs.buildPythonApplication rec { - pname = "inkstitch"; - inherit version; - pyproject = false; # Uses a Makefile (yikes) - - src = fetchFromGitHub { - owner = "inkstitch"; - repo = "inkstitch"; - rev = "refs/tags/v${version}"; - hash = "sha256-CGhJsDRhElgemNv2BXqZr6Vi5EyBArFak7Duz545ivY="; - }; - - nativeBuildInputs = [ - gettext - ]; - dependencies = with python3.pkgs; [ @@ -47,6 +30,26 @@ python3.pkgs.buildPythonApplication rec { ] # Inkstitch uses the builtin tomllib instead when Python >=3.11 ++ lib.optional (pythonOlder "3.11") tomli; + pyEnv = python3.withPackages (_: dependencies); +in +python3.pkgs.buildPythonApplication { + pname = "inkstitch"; + inherit version; + pyproject = false; # Uses a Makefile (yikes) + + src = fetchFromGitHub { + owner = "inkstitch"; + repo = "inkstitch"; + rev = "refs/tags/v${version}"; + hash = "sha256-CGhJsDRhElgemNv2BXqZr6Vi5EyBArFak7Duz545ivY="; + }; + + nativeBuildInputs = [ + gettext + pyEnv + ]; + + inherit dependencies; makeFlags = [ "manual" ]; @@ -64,16 +67,12 @@ python3.pkgs.buildPythonApplication rec { ./0002-plugin-invocation-use-python-script-as-entrypoint.patch ]; - postPatch = - let - pyEnv = python3.withPackages (_: dependencies); - in - '' - # 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 - ''; + 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 python3.pkgs; [ pytestCheckHook From e74bd37a8c15f1c96e8f9c8e5728438dafcce4c2 Mon Sep 17 00:00:00 2001 From: tropf Date: Fri, 20 Dec 2024 11:03:02 +0100 Subject: [PATCH 5/6] inkscape-extensions.inkstitch: provide version number Overwrite the version number shown in inkstitch's about dialog. Without this option, only 'manual' (without a version number) is shown. --- .../graphics/inkscape/extensions/inkstitch/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix index 5b55b6f76f3e..298be459e3f6 100644 --- a/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix +++ b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix @@ -51,6 +51,11 @@ python3.pkgs.buildPythonApplication { inherit dependencies; + env = { + # to overwrite version string + GITHUB_REF = version; + BUILD = "nixpkgs"; + }; makeFlags = [ "manual" ]; installPhase = '' From cd87669d6f040611e6e28bfd56c5d5772c40c560 Mon Sep 17 00:00:00 2001 From: tropf Date: Mon, 23 Dec 2024 05:06:54 +0100 Subject: [PATCH 6/6] inkscape-extensions.inkstitch: simplify fetchFromGitHub --- .../graphics/inkscape/extensions/inkstitch/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix index 298be459e3f6..ae6862d9bfd3 100644 --- a/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix +++ b/pkgs/applications/graphics/inkscape/extensions/inkstitch/default.nix @@ -40,7 +40,7 @@ python3.pkgs.buildPythonApplication { src = fetchFromGitHub { owner = "inkstitch"; repo = "inkstitch"; - rev = "refs/tags/v${version}"; + tag = "v${version}"; hash = "sha256-CGhJsDRhElgemNv2BXqZr6Vi5EyBArFak7Duz545ivY="; };