octoprint-plugins: use same python as octoprint, use overlays

- ensure the plugins use the same python as octoprint
- overlay of overriding plugins
- drop octoprint-plugins attribute
This commit is contained in:
Frederik Rietdijk 2020-03-14 11:02:07 +01:00
parent 610da69d28
commit 7066dc85ba
4 changed files with 312 additions and 306 deletions

View file

@ -17,9 +17,9 @@ let
cfgUpdate = pkgs.writeText "octoprint-config.yaml" (builtins.toJSON fullConfig);
pluginsEnv = pkgs.python.buildEnv.override {
extraLibs = cfg.plugins pkgs.octoprint-plugins;
};
pluginsEnv = package.python.withPackages (ps: [ps.octoprint] ++ (cfg.plugins ps));
package = pkgs.octoprint;
in
{
@ -106,7 +106,6 @@ in
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
path = [ pluginsEnv ];
environment.PYTHONPATH = makeSearchPathOutput "lib" pkgs.python.sitePackages [ pluginsEnv ];
preStart = ''
if [ -e "${cfg.stateDir}/config.yaml" ]; then
@ -119,7 +118,7 @@ in
'';
serviceConfig = {
ExecStart = "${pkgs.octoprint}/bin/octoprint serve -b ${cfg.stateDir}";
ExecStart = "${pluginsEnv}/bin/octoprint serve -b ${cfg.stateDir}";
User = cfg.user;
Group = cfg.group;
};

View file

@ -1,4 +1,7 @@
{ stdenv, lib, fetchFromGitHub, python3 }:
{ pkgs, stdenv, lib, fetchFromGitHub, python3
# To include additional plugins, pass them here as an overlay.
, packageOverrides ? self: super: {}
}:
let
mkOverride = attrname: version: sha256:
self: super: {
@ -11,6 +14,7 @@ let
};
py = python3.override {
self = py;
packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) ([
(mkOverride "flask" "0.12.5" "fac2b9d443e49f7e7358a444a3db5950bdd0324674d92ba67f8f1f15f876b14f")
(mkOverride "tornado" "4.5.3" "02jzd23l4r6fswmwxaica9ldlyc2p6q8dk6dyff7j58fmdzf853d")
@ -19,8 +23,8 @@ let
# Octoprint holds back jinja2 to 2.8.1 due to breaking changes.
# This old version does not have updated test config for pytest 4,
# and pypi tarball doesn't contain tests dir anyways.
(pself: psuper: {
jinja2 = psuper.jinja2.overridePythonAttrs (oldAttrs: rec {
(self: super: {
jinja2 = super.jinja2.overridePythonAttrs (oldAttrs: rec {
version = "2.8.1";
src = oldAttrs.src.override {
inherit version;
@ -29,23 +33,16 @@ let
doCheck = false;
});
httpretty = psuper.httpretty.overridePythonAttrs (oldAttrs: rec {
httpretty = super.httpretty.overridePythonAttrs (oldAttrs: rec {
doCheck = false;
});
celery = psuper.celery.overridePythonAttrs (oldAttrs: rec {
celery = super.celery.overridePythonAttrs (oldAttrs: rec {
doCheck = false;
});
})
]);
};
ignoreVersionConstraints = [
"sentry-sdk"
];
in
py.pkgs.buildPythonApplication rec {
(self: super: {
octoprint = self.buildPythonPackage rec {
pname = "OctoPrint";
version = "1.4.0";
@ -56,7 +53,7 @@ py.pkgs.buildPythonApplication rec {
sha256 = "1zla1ayr62lkvkr828dh3y287rzj3rv1hpij9kws44ynn4i582ga";
};
propagatedBuildInputs = with py.pkgs; [
propagatedBuildInputs = with super; [
awesome-slugify flask flask_assets rsa requests pkginfo watchdog
semantic-version werkzeug flaskbabel tornado
psutil pyserial flask_login netaddr markdown
@ -65,9 +62,13 @@ py.pkgs.buildPythonApplication rec {
frozendict cachelib sentry-sdk filetype markupsafe
] ++ lib.optionals stdenv.isDarwin [ py.pkgs.appdirs ];
checkInputs = with py.pkgs; [ pytestCheckHook mock ddt ];
checkInputs = with super; [ pytestCheckHook mock ddt ];
postPatch = ''
postPatch = let
ignoreVersionConstraints = [
"sentry-sdk"
];
in ''
sed -r -i \
${lib.concatStringsSep "\n" (map (e:
''-e 's@${e}[<>=]+.*@${e}",@g' \''
@ -94,4 +95,10 @@ py.pkgs.buildPythonApplication rec {
license = licenses.agpl3;
maintainers = with maintainers; [ abbradar gebner WhittlesJr ];
};
}
};
})
(import ./plugins.nix {inherit pkgs;})
packageOverrides
]);
};
in with py.pkgs; toPythonApplication octoprint

View file

@ -1,15 +1,17 @@
{ stdenv, fetchgit, fetchFromGitHub, octoprint, python2Packages, marlin-calc }:
{ pkgs }:
let
buildPlugin = args: python2Packages.buildPythonPackage (args // {
with pkgs;
self: super: let
buildPlugin = args: self.buildPythonPackage (args // {
pname = "OctoPrintPlugin-${args.pname}";
inherit (args) version;
propagatedBuildInputs = (args.propagatedBuildInputs or []) ++ [ octoprint ];
propagatedBuildInputs = (args.propagatedBuildInputs or []) ++ [ super.octoprint ];
# none of the following have tests
doCheck = false;
});
self = {
in {
inherit buildPlugin;
# Deprecated alias
m3d-fio = self.m33-fio; # added 2016-08-13
@ -56,7 +58,7 @@ let
sha256 = "0y1jnfplcy8mh3szrfbbvngl02j49cbdizglrfsry4fvqg50zjxd";
};
propagatedBuildInputs = with python2Packages; [ paho-mqtt ];
propagatedBuildInputs = with super; [ paho-mqtt ];
meta = with stdenv.lib; {
description = "Publish printer status MQTT";
@ -180,7 +182,7 @@ let
preConfigure = ''
# PrintTimeGenius ships with marlin-calc binaries for multiple architectures
rm */analyzers/marlin-calc*
sed 's@"{}.{}".format(binary_base_name, machine)@"${marlin-calc}/bin/marlin-calc"@' -i */analyzers/analyze_progress.py
sed 's@"{}.{}".format(binary_base_name, machine)@"${pkgs.marlin-calc}/bin/marlin-calc"@' -i */analyzers/analyze_progress.py
'';
patches = [
@ -250,6 +252,4 @@ let
maintainers = with maintainers; [ WhittlesJr ];
};
};
};
in self
}

View file

@ -20900,7 +20900,7 @@ in
octoprint = callPackage ../applications/misc/octoprint { };
octoprint-plugins = callPackage ../applications/misc/octoprint/plugins.nix { };
octoprint-plugins = throw ''octoprint-plugins are now part of the octoprint package set.'';
ocrad = callPackage ../applications/graphics/ocrad { };