diff --git a/pkgs/applications/misc/klipperscreen/default.nix b/pkgs/applications/misc/klipperscreen/default.nix new file mode 100644 index 000000000000..ef51ec96ac84 --- /dev/null +++ b/pkgs/applications/misc/klipperscreen/default.nix @@ -0,0 +1,28 @@ +{ lib, stdenv, writeText, python3Packages, fetchFromGitHub, gtk3, gobject-introspection, gdk-pixbuf, wrapGAppsHook, librsvg }: +python3Packages.buildPythonPackage rec { + pname = "KlipperScreen"; + version = "0.3.2"; + + src = fetchFromGitHub { + owner = "jordanruthe"; + repo = pname; + rev = "v${version}"; + hash = "sha256-LweO5EVWr3OxziHrjtQDdWyUBCVUJ17afkw7RCZWgcg="; + }; + patches = [ ./fix-paths.diff ]; + + buildInputs = [ gtk3 librsvg ]; + nativeBuildInputs = [ wrapGAppsHook gdk-pixbuf gobject-introspection ]; + + propagatedBuildInputs = with python3Packages; [ jinja2 netifaces requests websocket-client pycairo pygobject3 mpv six dbus-python numpy pycairo ]; + + preBuild = '' + ln -s ${./setup.py} setup.py + ''; + + meta = with lib; { + description = "Touchscreen GUI for the Klipper 3D printer firmware"; + homepage = "https://github.com/jordanruthe/${pname}"; + license = licenses.agpl3; + }; +} diff --git a/pkgs/applications/misc/klipperscreen/fix-paths.diff b/pkgs/applications/misc/klipperscreen/fix-paths.diff new file mode 100644 index 000000000000..71ce60fe56e8 --- /dev/null +++ b/pkgs/applications/misc/klipperscreen/fix-paths.diff @@ -0,0 +1,22 @@ +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 new file mode 100644 index 000000000000..946b517b78be --- /dev/null +++ b/pkgs/applications/misc/klipperscreen/setup.py @@ -0,0 +1,11 @@ +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'] + }, +) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9f4c8983578a..a1d1223e8858 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5222,6 +5222,8 @@ with pkgs; inherit (darwin.apple_sdk.frameworks) Security; }; + klipperscreen = callPackage ../applications/misc/klipperscreen { }; + klog = qt5.callPackage ../applications/radio/klog { }; komga = callPackage ../servers/komga { };