Skip to content

Commit

Permalink
chore(klipper): snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
truelecter committed Aug 6, 2023
1 parent 010548b commit be31ca8
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 51 deletions.
11 changes: 11 additions & 0 deletions cells/klipper/modules/klipper.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
config,
options,
...
}: let
cfg = config.services.klipper;
in {
disabledModules = ["services/misc/klipper.nix"];

options = {};
}
104 changes: 53 additions & 51 deletions cells/klipper/packages/klipper.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,67 @@
sources,
plugins ? [],
...
}:
stdenv.mkDerivation rec {
inherit (sources.klipper) pname version src;
}: let
pluginDependencies = plugins;
in
stdenv.mkDerivation rec {
inherit (sources.klipper) pname version src;

sourceRoot = "source/klippy";
sourceRoot = "source/klippy";

# NB: This is needed for the postBuild step
nativeBuildInputs = [
(python3.withPackages (p: with p; [cffi]))
makeWrapper
];
# NB: This is needed for the postBuild step
nativeBuildInputs = [
(python3.withPackages (p: with p; [cffi]))
makeWrapper
];

buildInputs = [(python3.withPackages (p: with p; [cffi pyserial greenlet jinja2 markupsafe numpy can setuptools]))];
buildInputs = [(python3.withPackages (p: with p; [can cffi pyserial greenlet jinja2 markupsafe numpy setuptools] ++ pluginDependencies))];

# we need to run this to prebuild the chelper.
postBuild = ''
python ./chelper/__init__.py
'';
# we need to run this to prebuild the chelper.
postBuild = ''
python ./chelper/__init__.py
'';

# Python 3 is already supported but shebangs aren't updated yet
postPatch = ''
for file in klippy.py console.py parsedump.py; do
substituteInPlace $file \
--replace '/usr/bin/env python2' '/usr/bin/env python'
done
'';
# Python 3 is already supported but shebangs aren't updated yet
postPatch = ''
for file in klippy.py console.py parsedump.py; do
substituteInPlace $file \
--replace '/usr/bin/env python2' '/usr/bin/env python'
done
'';

# 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
# 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
# Moonraker expects `config_examples` and `docs` to be available
# under `klipper_path`
cp -r $src/docs $out/lib/docs
cp -r $src/config $out/lib/config
# Moonraker expects `config_examples` and `docs` to be available
# under `klipper_path`
cp -r $src/docs $out/lib/docs
cp -r $src/config $out/lib/config
mkdir -p $out/bin
chmod 755 $out/lib/klipper/klippy.py
makeWrapper $out/lib/klipper/klippy.py $out/bin/klippy --chdir $out/lib/klipper
mkdir -p $out/bin
chmod 755 $out/lib/klipper/klippy.py
makeWrapper $out/lib/klipper/klippy.py $out/bin/klippy --chdir $out/lib/klipper
${
lib.concatStringsSep "\n" (
builtins.map
(plugin: "ln -sf ${plugin}/lib/${plugin.pname}/extras/*.py $out/lib/klipper/extras/")
plugins
)
}
${
lib.concatStringsSep "\n" (
builtins.map
(plugin: "ln -sf ${plugin}/lib/${plugin.pname}/extras/*.py $out/lib/klipper/extras/")
plugins
)
}
runHook postInstall
'';
runHook postInstall
'';

meta = with lib; {
description = "The Klipper 3D printer firmware";
homepage = "https://github.com/KevinOConnor/klipper";
platforms = platforms.linux;
license = licenses.gpl3Only;
};
}
meta = with lib; {
description = "The Klipper 3D printer firmware";
homepage = "https://github.com/KevinOConnor/klipper";
platforms = platforms.linux;
license = licenses.gpl3Only;
};
}

0 comments on commit be31ca8

Please sign in to comment.