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); cfgUpdate = pkgs.writeText "octoprint-config.yaml" (builtins.toJSON fullConfig);
pluginsEnv = pkgs.python.buildEnv.override { pluginsEnv = package.python.withPackages (ps: [ps.octoprint] ++ (cfg.plugins ps));
extraLibs = cfg.plugins pkgs.octoprint-plugins;
}; package = pkgs.octoprint;
in in
{ {
@ -106,7 +106,6 @@ in
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "network.target" ]; after = [ "network.target" ];
path = [ pluginsEnv ]; path = [ pluginsEnv ];
environment.PYTHONPATH = makeSearchPathOutput "lib" pkgs.python.sitePackages [ pluginsEnv ];
preStart = '' preStart = ''
if [ -e "${cfg.stateDir}/config.yaml" ]; then if [ -e "${cfg.stateDir}/config.yaml" ]; then
@ -119,7 +118,7 @@ in
''; '';
serviceConfig = { serviceConfig = {
ExecStart = "${pkgs.octoprint}/bin/octoprint serve -b ${cfg.stateDir}"; ExecStart = "${pluginsEnv}/bin/octoprint serve -b ${cfg.stateDir}";
User = cfg.user; User = cfg.user;
Group = cfg.group; 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 let
mkOverride = attrname: version: sha256: mkOverride = attrname: version: sha256:
self: super: { self: super: {
@ -11,6 +14,7 @@ let
}; };
py = python3.override { py = python3.override {
self = py;
packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) ([ packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) ([
(mkOverride "flask" "0.12.5" "fac2b9d443e49f7e7358a444a3db5950bdd0324674d92ba67f8f1f15f876b14f") (mkOverride "flask" "0.12.5" "fac2b9d443e49f7e7358a444a3db5950bdd0324674d92ba67f8f1f15f876b14f")
(mkOverride "tornado" "4.5.3" "02jzd23l4r6fswmwxaica9ldlyc2p6q8dk6dyff7j58fmdzf853d") (mkOverride "tornado" "4.5.3" "02jzd23l4r6fswmwxaica9ldlyc2p6q8dk6dyff7j58fmdzf853d")
@ -19,8 +23,8 @@ let
# Octoprint holds back jinja2 to 2.8.1 due to breaking changes. # Octoprint holds back jinja2 to 2.8.1 due to breaking changes.
# This old version does not have updated test config for pytest 4, # This old version does not have updated test config for pytest 4,
# and pypi tarball doesn't contain tests dir anyways. # and pypi tarball doesn't contain tests dir anyways.
(pself: psuper: { (self: super: {
jinja2 = psuper.jinja2.overridePythonAttrs (oldAttrs: rec { jinja2 = super.jinja2.overridePythonAttrs (oldAttrs: rec {
version = "2.8.1"; version = "2.8.1";
src = oldAttrs.src.override { src = oldAttrs.src.override {
inherit version; inherit version;
@ -29,23 +33,16 @@ let
doCheck = false; doCheck = false;
}); });
httpretty = psuper.httpretty.overridePythonAttrs (oldAttrs: rec { httpretty = super.httpretty.overridePythonAttrs (oldAttrs: rec {
doCheck = false; doCheck = false;
}); });
celery = psuper.celery.overridePythonAttrs (oldAttrs: rec { celery = super.celery.overridePythonAttrs (oldAttrs: rec {
doCheck = false; doCheck = false;
}); });
}) })
]); (self: super: {
}; octoprint = self.buildPythonPackage rec {
ignoreVersionConstraints = [
"sentry-sdk"
];
in
py.pkgs.buildPythonApplication rec {
pname = "OctoPrint"; pname = "OctoPrint";
version = "1.4.0"; version = "1.4.0";
@ -56,7 +53,7 @@ py.pkgs.buildPythonApplication rec {
sha256 = "1zla1ayr62lkvkr828dh3y287rzj3rv1hpij9kws44ynn4i582ga"; sha256 = "1zla1ayr62lkvkr828dh3y287rzj3rv1hpij9kws44ynn4i582ga";
}; };
propagatedBuildInputs = with py.pkgs; [ propagatedBuildInputs = with super; [
awesome-slugify flask flask_assets rsa requests pkginfo watchdog awesome-slugify flask flask_assets rsa requests pkginfo watchdog
semantic-version werkzeug flaskbabel tornado semantic-version werkzeug flaskbabel tornado
psutil pyserial flask_login netaddr markdown psutil pyserial flask_login netaddr markdown
@ -65,9 +62,13 @@ py.pkgs.buildPythonApplication rec {
frozendict cachelib sentry-sdk filetype markupsafe frozendict cachelib sentry-sdk filetype markupsafe
] ++ lib.optionals stdenv.isDarwin [ py.pkgs.appdirs ]; ] ++ 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 \ sed -r -i \
${lib.concatStringsSep "\n" (map (e: ${lib.concatStringsSep "\n" (map (e:
''-e 's@${e}[<>=]+.*@${e}",@g' \'' ''-e 's@${e}[<>=]+.*@${e}",@g' \''
@ -94,4 +95,10 @@ py.pkgs.buildPythonApplication rec {
license = licenses.agpl3; license = licenses.agpl3;
maintainers = with maintainers; [ abbradar gebner WhittlesJr ]; 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 with pkgs;
buildPlugin = args: python2Packages.buildPythonPackage (args // {
self: super: let
buildPlugin = args: self.buildPythonPackage (args // {
pname = "OctoPrintPlugin-${args.pname}"; pname = "OctoPrintPlugin-${args.pname}";
inherit (args) version; inherit (args) version;
propagatedBuildInputs = (args.propagatedBuildInputs or []) ++ [ octoprint ]; propagatedBuildInputs = (args.propagatedBuildInputs or []) ++ [ super.octoprint ];
# none of the following have tests # none of the following have tests
doCheck = false; doCheck = false;
}); });
in {
self = { inherit buildPlugin;
# Deprecated alias # Deprecated alias
m3d-fio = self.m33-fio; # added 2016-08-13 m3d-fio = self.m33-fio; # added 2016-08-13
@ -56,7 +58,7 @@ let
sha256 = "0y1jnfplcy8mh3szrfbbvngl02j49cbdizglrfsry4fvqg50zjxd"; sha256 = "0y1jnfplcy8mh3szrfbbvngl02j49cbdizglrfsry4fvqg50zjxd";
}; };
propagatedBuildInputs = with python2Packages; [ paho-mqtt ]; propagatedBuildInputs = with super; [ paho-mqtt ];
meta = with stdenv.lib; { meta = with stdenv.lib; {
description = "Publish printer status MQTT"; description = "Publish printer status MQTT";
@ -180,7 +182,7 @@ let
preConfigure = '' preConfigure = ''
# PrintTimeGenius ships with marlin-calc binaries for multiple architectures # PrintTimeGenius ships with marlin-calc binaries for multiple architectures
rm */analyzers/marlin-calc* 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 = [ patches = [
@ -250,6 +252,4 @@ let
maintainers = with maintainers; [ WhittlesJr ]; maintainers = with maintainers; [ WhittlesJr ];
}; };
}; };
}; }
in self

View File

@ -20900,7 +20900,7 @@ in
octoprint = callPackage ../applications/misc/octoprint { }; 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 { }; ocrad = callPackage ../applications/graphics/ocrad { };