summary refs log tree commit diff
path: root/pkgs/servers/klipper
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
committerAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
commit62614cbef7da005c1eda8c9400160f6bcd6546b8 (patch)
treec2630f69080637987b68acb1ee8676d2681fe304 /pkgs/servers/klipper
parentd9c82ed3044c72cecf01c6ea042489d30914577c (diff)
parente24069138dfec3ef94f211f1da005bb5395adc11 (diff)
downloadnixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.gz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.bz2
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.lz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.xz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.zst
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.zip
Merge branch 'nixpkgs-update' into master
Diffstat (limited to 'pkgs/servers/klipper')
-rw-r--r--pkgs/servers/klipper/default.nix58
1 files changed, 58 insertions, 0 deletions
diff --git a/pkgs/servers/klipper/default.nix b/pkgs/servers/klipper/default.nix
new file mode 100644
index 00000000000..f120454ac84
--- /dev/null
+++ b/pkgs/servers/klipper/default.nix
@@ -0,0 +1,58 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, python2
+, unstableGitUpdater
+}:
+stdenv.mkDerivation rec {
+  pname = "klipper";
+  version = "unstable-2021-07-15";
+
+  src = fetchFromGitHub {
+    owner = "KevinOConnor";
+    repo = "klipper";
+    rev = "dafb74e3aba707db364ed773bb2135084ac0fffa";
+    sha256 = "sha256-wF5I8Mo89ohhysBRDMtkCDbCW9SKWrdYdbifmxCPJBc=";
+  };
+
+  # We have no LTO on i686 since commit 22284b0
+  postPatch = lib.optional stdenv.isi686 ''
+    substituteInPlace chelper/__init__.py \
+      --replace "-flto -fwhole-program " ""
+  '';
+
+  sourceRoot = "source/klippy";
+
+  # there is currently an attempt at moving it to Python 3, but it will remain
+  # Python 2 for the foreseeable future.
+  # c.f. https://github.com/KevinOConnor/klipper/pull/3278
+  # NB: This is needed for the postBuild step
+  nativeBuildInputs = [ (python2.withPackages ( p: with p; [ cffi ] )) ];
+
+  buildInputs = [ (python2.withPackages (p: with p; [ cffi pyserial greenlet jinja2 ])) ];
+
+  # we need to run this to prebuild the chelper.
+  postBuild = "python2 ./chelper/__init__.py";
+
+  # NB: We don't move the main entry point into `/bin`, or even symlink it,
+  # because it uses relative paths to find necessary modules. We could wrap but
+  # this is used 99% of the time as a service, so it's not worth the effort.
+  installPhase = ''
+    runHook preInstall
+    mkdir -p $out/lib/klipper
+    cp -r ./* $out/lib/klipper
+
+    chmod 755 $out/lib/klipper/klippy.py
+    runHook postInstall
+  '';
+
+  passthru.updateScript = unstableGitUpdater { url = meta.homepage; };
+
+  meta = with lib; {
+    description = "The Klipper 3D printer firmware";
+    homepage = "https://github.com/KevinOConnor/klipper";
+    maintainers = with maintainers; [ lovesegfault zhaofengli ];
+    platforms = platforms.linux;
+    license = licenses.gpl3Only;
+  };
+}