forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / applications / version-management / sourcehut / default.nix
blob147257dc3d5d0492d252d369d25caf5361a5eb06
1 { lib
2 , python3
3 , callPackage
4 , recurseIntoAttrs
5 , nixosTests
6 , config
7 , fetchPypi
8 , fetchpatch
9 }:
11 # To expose the *srht modules, they have to be a python module so we use `buildPythonModule`
12 # Then we expose them through all-packages.nix as an application through `toPythonApplication`
13 # https://github.com/NixOS/nixpkgs/pull/54425#discussion_r250688781
14 let
15   python = python3.override {
16     self = python;
17     packageOverrides = self: super: {
18       srht = self.callPackage ./core.nix { };
20       buildsrht = self.callPackage ./builds.nix { };
21       gitsrht = self.callPackage ./git.nix { };
22       hgsrht = self.callPackage ./hg.nix { };
23       hubsrht = self.callPackage ./hub.nix { };
24       listssrht = self.callPackage ./lists.nix { };
25       mansrht = self.callPackage ./man.nix { };
26       metasrht = self.callPackage ./meta.nix { };
27       pastesrht = self.callPackage ./paste.nix { };
28       todosrht = self.callPackage ./todo.nix { };
30       scmsrht = self.callPackage ./scm.nix { };
32       # sourcehut is not (yet) compatible with SQLAlchemy 2.x
33       sqlalchemy = super.sqlalchemy_1_4;
35       # sourcehut is not (yet) compatible with flask-sqlalchemy 3.x
36       flask-sqlalchemy = super.flask-sqlalchemy.overridePythonAttrs (oldAttrs: rec {
37         version = "2.5.1";
38         format = "setuptools";
39         src = fetchPypi {
40           pname = "Flask-SQLAlchemy";
41           inherit version;
42           hash = "sha256-K9pEtD58rLFdTgX/PMH4vJeTbMRkYjQkECv8LDXpWRI=";
43         };
44         propagatedBuildInputs = with self; [
45           flask
46           sqlalchemy
47         ];
48       });
50       # flask-sqlalchemy 2.x requires flask 2.x
51       flask = super.flask.overridePythonAttrs (oldAttrs: rec {
52         version = "2.3.3";
53         src = fetchPypi {
54           inherit (oldAttrs) pname;
55           inherit version;
56           hash = "sha256-CcNHqSqn/0qOfzIGeV8w2CZlS684uHPQdEzVccpgnvw=";
57         };
58       });
60       # flask 2.x requires werkzeug 2.x
61       werkzeug = super.werkzeug.overridePythonAttrs (oldAttrs: rec {
62         version = "2.3.8";
63         src = fetchPypi {
64           inherit (oldAttrs) pname;
65           inherit version;
66           hash = "sha256-VUslfHS763oNJUFgpPj/4YUkP1KlIDUGC3Ycpi2XfwM=";
67         };
68         # Fixes a test failure with Pytest 8
69         patches = (oldAttrs.patches or []) ++ [
70           (fetchpatch {
71             url = "https://github.com/pallets/werkzeug/commit/4e5bdca7f8227d10cae828f8064fb98190ace4aa.patch";
72             hash = "sha256-83doVvfdpymlAB0EbfrHmuoKE5B2LJbFq+AY2xGpnl4=";
73           })
74         ];
75       });
77       # sourcehut is not (yet) compatible with factory-boy 3.x
78       factory-boy = super.factory-boy.overridePythonAttrs (oldAttrs: rec {
79         version = "2.12.0";
80         src = fetchPypi {
81           pname = "factory_boy";
82           inherit version;
83           hash = "sha256-+vSNYIoXNfDQo8nL9TbWT5EytUfa57pFLE2Zp56Eo3A=";
84         };
85         nativeCheckInputs = (with super; [
86           django
87           mongoengine
88           pytestCheckHook
89         ]) ++ (with self; [
90           sqlalchemy
91           flask
92           flask-sqlalchemy
93         ]);
94         postPatch = "";
95       });
96     };
97   };
99 with python.pkgs; recurseIntoAttrs ({
100   inherit python;
101   coresrht = toPythonApplication srht;
102   buildsrht = toPythonApplication buildsrht;
103   gitsrht = toPythonApplication gitsrht;
104   hgsrht = toPythonApplication hgsrht;
105   hubsrht = toPythonApplication hubsrht;
106   listssrht = toPythonApplication listssrht;
107   mansrht = toPythonApplication mansrht;
108   metasrht = toPythonApplication metasrht;
109   pagessrht = callPackage ./pages.nix { };
110   pastesrht = toPythonApplication pastesrht;
111   todosrht = toPythonApplication todosrht;
112   passthru.tests = {
113     nixos-sourcehut = nixosTests.sourcehut;
114   };
115 } // lib.optionalAttrs config.allowAliases {
116   # Added 2022-10-29
117   dispatchsrht = throw "dispatch is deprecated. See https://sourcehut.org/blog/2022-08-01-dispatch-deprecation-plans/ for more information.";