From 1ebfd5f8cfa425d6ce8d9726b7a4ddbe2beaa8e4 Mon Sep 17 00:00:00 2001 From: Vladimir Serov Date: Wed, 17 May 2023 10:03:31 +0400 Subject: [PATCH] klipperscreen: repackage --- .../misc/klipperscreen/default.nix | 46 +++++++++++++++---- .../misc/klipperscreen/fix-paths.diff | 22 --------- pkgs/applications/misc/klipperscreen/setup.py | 11 ----- 3 files changed, 36 insertions(+), 43 deletions(-) delete mode 100644 pkgs/applications/misc/klipperscreen/fix-paths.diff delete mode 100644 pkgs/applications/misc/klipperscreen/setup.py diff --git a/pkgs/applications/misc/klipperscreen/default.nix b/pkgs/applications/misc/klipperscreen/default.nix index ef51ec96ac84..e970c2572548 100644 --- a/pkgs/applications/misc/klipperscreen/default.nix +++ b/pkgs/applications/misc/klipperscreen/default.nix @@ -1,28 +1,54 @@ -{ lib, stdenv, writeText, python3Packages, fetchFromGitHub, gtk3, gobject-introspection, gdk-pixbuf, wrapGAppsHook, librsvg }: -python3Packages.buildPythonPackage rec { +{ lib +, python3 +, fetchFromGitHub +, wrapGAppsHook +, gobject-introspection +, gitUpdater +}: python3.pkgs.buildPythonApplication rec { pname = "KlipperScreen"; version = "0.3.2"; + format = "other"; src = fetchFromGitHub { owner = "jordanruthe"; - repo = pname; + repo = "KlipperScreen"; rev = "v${version}"; hash = "sha256-LweO5EVWr3OxziHrjtQDdWyUBCVUJ17afkw7RCZWgcg="; }; - patches = [ ./fix-paths.diff ]; - buildInputs = [ gtk3 librsvg ]; - nativeBuildInputs = [ wrapGAppsHook gdk-pixbuf gobject-introspection ]; + nativeBuildInputs = [ + gobject-introspection + wrapGAppsHook + ]; - propagatedBuildInputs = with python3Packages; [ jinja2 netifaces requests websocket-client pycairo pygobject3 mpv six dbus-python numpy pycairo ]; + pythonPath = with python3.pkgs; [ + jinja2 + netifaces + requests + websocket-client + pycairo + pygobject3 + mpv + six + dbus-python + ]; - preBuild = '' - ln -s ${./setup.py} setup.py + dontWrapGApps = true; + + preFixup = '' + mkdir -p $out/bin + cp -r . $out/dist + gappsWrapperArgs+=(--set PYTHONPATH "$PYTHONPATH") + wrapGApp $out/dist/screen.py + ln -s $out/dist/screen.py $out/bin/KlipperScreen ''; + passthru.updateScript = gitUpdater { url = meta.homepage; }; + meta = with lib; { description = "Touchscreen GUI for the Klipper 3D printer firmware"; - homepage = "https://github.com/jordanruthe/${pname}"; + homepage = "https://github.com/jordanruthe/KlipperScreen"; license = licenses.agpl3; + maintainers = with maintainers; [ cab404 ]; }; } diff --git a/pkgs/applications/misc/klipperscreen/fix-paths.diff b/pkgs/applications/misc/klipperscreen/fix-paths.diff deleted file mode 100644 index 71ce60fe56e8..000000000000 --- a/pkgs/applications/misc/klipperscreen/fix-paths.diff +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/screen.py b/screen.py -index 4fd75cd..a10779a 100755 ---- a/screen.py -+++ b/screen.py -@@ -48,7 +48,7 @@ PRINTER_BASE_STATUS_OBJECTS = [ - 'exclude_object', - ] - --klipperscreendir = pathlib.Path(__file__).parent.resolve() -+klipperscreendir = pathlib.Path(functions.__file__).parent.parent.resolve() - - - def set_text_direction(lang=None): -@@ -254,7 +254,7 @@ class KlipperScreen(Gtk.Window): - def _load_panel(self, panel, *args): - if panel not in self.load_panel: - logging.debug(f"Loading panel: {panel}") -- panel_path = os.path.join(os.path.dirname(__file__), 'panels', f"{panel}.py") -+ panel_path = os.path.join(klipperscreendir, 'panels', f"{panel}.py") - logging.info(f"Panel path: {panel_path}") - if not os.path.exists(panel_path): - logging.error(f"Panel {panel} does not exist") diff --git a/pkgs/applications/misc/klipperscreen/setup.py b/pkgs/applications/misc/klipperscreen/setup.py deleted file mode 100644 index 946b517b78be..000000000000 --- a/pkgs/applications/misc/klipperscreen/setup.py +++ /dev/null @@ -1,11 +0,0 @@ -from setuptools import setup - -setup( - name='KlipperScreen', - install_requires=[], - packages=['styles', 'panels', 'ks_includes', 'ks_includes.widgets'], - package_data={'ks_includes': ['defaults.conf', 'locales/**', 'emptyCursor.xbm'], 'styles': ['**']}, - entry_points={ - 'console_scripts': ['KlipperScreen=screen:main'] - }, -)