biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / misc / octoprint / default.nix
blob0a13013e5da2ea18196603f6ec9a57f2fdcaa7d6
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             });
42             netaddr = super.netaddr.overridePythonAttrs (oldAttrs: rec {
43               version = "0.9.0";
45               src = fetchPypi {
46                 pname = "netaddr";
47                 inherit version;
48                 hash = "sha256-e0b6mxotcf1d6eSjeE7zOXAKU6CMgEDwi69fEZTaASg=";
49               };
50             });
51           }
52         )
54         # Built-in dependency
55         (
56           self: super: {
57             octoprint-filecheck = self.buildPythonPackage rec {
58               pname = "OctoPrint-FileCheck";
59               version = "2021.2.23";
61               src = fetchFromGitHub {
62                 owner = "OctoPrint";
63                 repo = "OctoPrint-FileCheck";
64                 rev = version;
65                 sha256 = "sha256-e/QGEBa9+pjOdrZq3Zc6ifbSMClIyeTOi0Tji0YdVmI=";
66               };
67               doCheck = false;
68             };
69           }
70         )
72         # Built-in dependency
73         (
74           self: super: {
75             octoprint-firmwarecheck = self.buildPythonPackage rec {
76               pname = "OctoPrint-FirmwareCheck";
77               version = "2021.10.11";
79               src = fetchFromGitHub {
80                 owner = "OctoPrint";
81                 repo = "OctoPrint-FirmwareCheck";
82                 rev = version;
83                 hash = "sha256-wqbD82bhJDrDawJ+X9kZkoA6eqGxqJc1Z5dA0EUwgEI=";
84               };
85               doCheck = false;
86             };
87           }
88         )
90         (
91           self: super: {
92             octoprint-pisupport = self.buildPythonPackage rec {
93               pname = "OctoPrint-PiSupport";
94               version = "2023.5.24";
95               format = "setuptools";
97               src = fetchFromGitHub {
98                 owner = "OctoPrint";
99                 repo = "OctoPrint-PiSupport";
100                 rev = version;
101                 hash = "sha256-KfkZXJ2f02G2ee+J1w+YQRKz+LSWwxVIIwmdevDGhew=";
102               };
104               # requires octoprint itself during tests
105               doCheck = false;
106               postPatch = ''
107                 substituteInPlace octoprint_pi_support/__init__.py \
108                   --replace /usr/bin/vcgencmd ${self.pkgs.libraspberrypi}/bin/vcgencmd
109               '';
110             };
111           }
112         )
114         (
115           self: super: {
116             octoprint = self.buildPythonPackage rec {
117               pname = "OctoPrint";
118               version = "1.9.3";
120               src = fetchFromGitHub {
121                 owner = "OctoPrint";
122                 repo = "OctoPrint";
123                 rev = version;
124                 hash = "sha256-71uE8JvcS++xH8WSVWj5x0+9s3XIwf3A64c6YtxpSRc=";
125               };
127               propagatedBuildInputs = with self; [
128                 argon2-cffi
129                 blinker
130                 cachelib
131                 click
132                 colorlog
133                 emoji
134                 feedparser
135                 filetype
136                 flask
137                 flask-babel
138                 flask-assets
139                 flask-login
140                 flask-limiter
141                 frozendict
142                 future
143                 itsdangerous
144                 immutabledict
145                 jinja2
146                 markdown
147                 markupsafe
148                 netaddr
149                 netifaces
150                 octoprint-filecheck
151                 octoprint-firmwarecheck
152                 passlib
153                 pathvalidate
154                 pkginfo
155                 pip
156                 psutil
157                 pylru
158                 pyserial
159                 pyyaml
160                 regex
161                 requests
162                 rsa
163                 sarge
164                 semantic-version
165                 sentry-sdk
166                 setuptools
167                 tornado
168                 unidecode
169                 watchdog
170                 websocket-client
171                 werkzeug
172                 wrapt
173                 zeroconf
174                 zipstream-ng
175                 class-doc
176                 pydantic_1
177               ] ++ lib.optionals stdenv.isDarwin [
178                 py.pkgs.appdirs
179               ] ++ lib.optionals (!stdenv.isDarwin) [
180                 octoprint-pisupport
181               ];
183               nativeCheckInputs = with self; [
184                 ddt
185                 mock
186                 pytestCheckHook
187               ];
189               patches = [
190                 # substitute pip and let it find out, that it can't write anywhere
191                 (substituteAll {
192                   src = ./pip-path.patch;
193                   pip = "${self.pip}/bin/pip";
194                 })
196                 # hardcore path to ffmpeg and hide related settings
197                 (substituteAll {
198                   src = ./ffmpeg-path.patch;
199                   ffmpeg = "${pkgs.ffmpeg}/bin/ffmpeg";
200                 })
201               ];
203               postPatch =
204                 let
205                   ignoreVersionConstraints = [
206                     "cachelib"
207                     "colorlog"
208                     "emoji"
209                     "immutabledict"
210                     "PyYAML"
211                     "sarge"
212                     "sentry-sdk"
213                     "watchdog"
214                     "wrapt"
215                     "zeroconf"
216                     "Flask-Login"
217                     "werkzeug"
218                     "flask"
219                     "Flask-Limiter"
220                     "blinker"
221                   ];
222                 in
223                 ''
224                     sed -r -i \
225                       ${lib.concatStringsSep "\n" (
226                     map (
227                       e:
228                         ''-e 's@${e}[<>=]+.*@${e}",@g' \''
229                     ) ignoreVersionConstraints
230                   )}
231                       setup.py
232                 '';
234               dontUseSetuptoolsCheck = true;
236               preCheck = ''
237                 export HOME=$(mktemp -d)
238                 rm pytest.ini
239               '';
241               disabledTests = [
242                 "test_check_setup" # Why should it be able to call pip?
243               ] ++ lib.optionals stdenv.isDarwin [
244                 "test_set_external_modification"
245               ];
247               passthru = {
248                 inherit (self) python;
249                 updateScript = nix-update-script { };
250                 tests = {
251                   plugins = (callPackage ./plugins.nix { }) super self;
252                   inherit (nixosTests) octoprint;
253                 };
254               };
256               meta = with lib; {
257                 homepage = "https://octoprint.org/";
258                 description = "The snappy web interface for your 3D printer";
259                 mainProgram = "octoprint";
260                 license = licenses.agpl3Only;
261                 maintainers = with maintainers; [ abbradar gebner WhittlesJr gador ];
262               };
263             };
264           }
265         )
266         (callPackage ./plugins.nix { })
267         packageOverrides
268       ]
269     );
270   };
272 with py.pkgs; toPythonApplication octoprint