Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / misc / octoprint / default.nix
blobe7daa60198d11b82d07a640866b4bb16c4d301b1
1 { pkgs
2 , stdenv
3 , callPackage
4 , lib
5 , fetchFromGitHub
6 , fetchPypi
7 , python3
8 , substituteAll
9 , nix-update-script
10 , nixosTests
11   # To include additional plugins, pass them here as an overlay.
12 , packageOverrides ? self: super: { }
14 let
16   py = python3.override {
17     self = py;
18     packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) (
19       [
20         (
21           # Due to flask > 2.3 the login will not work
22           self: super: {
23             werkzeug = super.werkzeug.overridePythonAttrs (oldAttrs: rec {
24               version = "2.2.3";
25               format = "setuptools";
26               src = fetchPypi {
27                 pname = "Werkzeug";
28                 inherit version;
29                 hash = "sha256-LhzMlBfU2jWLnebxdOOsCUOR6h1PvvLWZ4ZdgZ39Cv4=";
30               };
31             });
32             flask = super.flask.overridePythonAttrs (oldAttrs: rec {
33               version = "2.2.5";
34               format = "setuptools";
35               src = fetchPypi {
36                 pname = "Flask";
37                 inherit version;
38                 hash = "sha256-7e6bCn/yZiG9WowQ/0hK4oc3okENmbC7mmhQx/uXeqA=";
39               };
40             });
41           }
42         )
44         # Built-in dependency
45         (
46           self: super: {
47             octoprint-filecheck = self.buildPythonPackage rec {
48               pname = "OctoPrint-FileCheck";
49               version = "2021.2.23";
51               src = fetchFromGitHub {
52                 owner = "OctoPrint";
53                 repo = "OctoPrint-FileCheck";
54                 rev = version;
55                 sha256 = "sha256-e/QGEBa9+pjOdrZq3Zc6ifbSMClIyeTOi0Tji0YdVmI=";
56               };
57               doCheck = false;
58             };
59           }
60         )
62         # Built-in dependency
63         (
64           self: super: {
65             octoprint-firmwarecheck = self.buildPythonPackage rec {
66               pname = "OctoPrint-FirmwareCheck";
67               version = "2021.10.11";
69               src = fetchFromGitHub {
70                 owner = "OctoPrint";
71                 repo = "OctoPrint-FirmwareCheck";
72                 rev = version;
73                 hash = "sha256-wqbD82bhJDrDawJ+X9kZkoA6eqGxqJc1Z5dA0EUwgEI=";
74               };
75               doCheck = false;
76             };
77           }
78         )
80         (
81           self: super: {
82             octoprint-pisupport = self.buildPythonPackage rec {
83               pname = "OctoPrint-PiSupport";
84               version = "2023.5.24";
85               format = "setuptools";
87               src = fetchFromGitHub {
88                 owner = "OctoPrint";
89                 repo = "OctoPrint-PiSupport";
90                 rev = version;
91                 hash = "sha256-KfkZXJ2f02G2ee+J1w+YQRKz+LSWwxVIIwmdevDGhew=";
92               };
94               # requires octoprint itself during tests
95               doCheck = false;
96               postPatch = ''
97                 substituteInPlace octoprint_pi_support/__init__.py \
98                   --replace /usr/bin/vcgencmd ${self.pkgs.libraspberrypi}/bin/vcgencmd
99               '';
100             };
101           }
102         )
104         (
105           self: super: {
106             octoprint = self.buildPythonPackage rec {
107               pname = "OctoPrint";
108               version = "1.9.3";
110               src = fetchFromGitHub {
111                 owner = "OctoPrint";
112                 repo = "OctoPrint";
113                 rev = version;
114                 hash = "sha256-71uE8JvcS++xH8WSVWj5x0+9s3XIwf3A64c6YtxpSRc=";
115               };
117               propagatedBuildInputs = with self; [
118                 argon2-cffi
119                 blinker
120                 cachelib
121                 click
122                 colorlog
123                 emoji
124                 feedparser
125                 filetype
126                 flask
127                 flask-babel
128                 flask-assets
129                 flask-login
130                 flask-limiter
131                 frozendict
132                 future
133                 itsdangerous
134                 immutabledict
135                 jinja2
136                 markdown
137                 markupsafe
138                 netaddr
139                 netifaces
140                 octoprint-filecheck
141                 octoprint-firmwarecheck
142                 passlib
143                 pathvalidate
144                 pkginfo
145                 pip
146                 psutil
147                 pylru
148                 pyserial
149                 pyyaml
150                 regex
151                 requests
152                 rsa
153                 sarge
154                 semantic-version
155                 sentry-sdk
156                 setuptools
157                 tornado
158                 unidecode
159                 watchdog
160                 websocket-client
161                 werkzeug
162                 wrapt
163                 zeroconf
164                 zipstream-ng
165                 class-doc
166                 pydantic
167               ] ++ lib.optionals stdenv.isDarwin [
168                 py.pkgs.appdirs
169               ] ++ lib.optionals (!stdenv.isDarwin) [
170                 octoprint-pisupport
171               ];
173               nativeCheckInputs = with self; [
174                 ddt
175                 mock
176                 pytestCheckHook
177               ];
179               patches = [
180                 # substitute pip and let it find out, that it can't write anywhere
181                 (substituteAll {
182                   src = ./pip-path.patch;
183                   pip = "${self.pip}/bin/pip";
184                 })
186                 # hardcore path to ffmpeg and hide related settings
187                 (substituteAll {
188                   src = ./ffmpeg-path.patch;
189                   ffmpeg = "${pkgs.ffmpeg}/bin/ffmpeg";
190                 })
191               ];
193               postPatch =
194                 let
195                   ignoreVersionConstraints = [
196                     "cachelib"
197                     "colorlog"
198                     "emoji"
199                     "immutabledict"
200                     "PyYAML"
201                     "sarge"
202                     "sentry-sdk"
203                     "watchdog"
204                     "wrapt"
205                     "zeroconf"
206                     "Flask-Login"
207                     "werkzeug"
208                     "flask"
209                     "Flask-Limiter"
210                     "blinker"
211                   ];
212                 in
213                 ''
214                     sed -r -i \
215                       ${lib.concatStringsSep "\n" (
216                     map (
217                       e:
218                         ''-e 's@${e}[<>=]+.*@${e}",@g' \''
219                     ) ignoreVersionConstraints
220                   )}
221                       setup.py
222                 '';
224               dontUseSetuptoolsCheck = true;
226               preCheck = ''
227                 export HOME=$(mktemp -d)
228                 rm pytest.ini
229               '';
231               disabledTests = [
232                 "test_check_setup" # Why should it be able to call pip?
233               ] ++ lib.optionals stdenv.isDarwin [
234                 "test_set_external_modification"
235               ];
237               passthru = {
238                 inherit (self) python;
239                 updateScript = nix-update-script { };
240                 tests = {
241                   plugins = (callPackage ./plugins.nix { }) super self;
242                   inherit (nixosTests) octoprint;
243                 };
244               };
246               meta = with lib; {
247                 homepage = "https://octoprint.org/";
248                 description = "The snappy web interface for your 3D printer";
249                 license = licenses.agpl3Only;
250                 maintainers = with maintainers; [ abbradar gebner WhittlesJr gador ];
251               };
252             };
253           }
254         )
255         (callPackage ./plugins.nix { })
256         packageOverrides
257       ]
258     );
259   };
261 with py.pkgs; toPythonApplication octoprint