Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 150 lines 3.9 kB view raw
1{ 2 lib, 3 fetchPypi, 4 fetchpatch, 5 callPackage, 6 runCommand, 7 python, 8 encryptionSupport ? true, 9 sqliteSupport ? true, 10}: 11 12let 13 # save for overriding it 14 python' = python; 15in 16let 17 python = python'.override { 18 self = python; 19 packageOverrides = final: prev: { 20 # SQLAlchemy>=1,<1.4 21 # SQLAlchemy 2.0's derivation is very different, so don't override, just write it from scratch 22 # (see https://github.com/NixOS/nixpkgs/blob/65dbed73949e4c0207e75dcc7271b29f9e457670/pkgs/development/python-modules/sqlalchemy/default.nix) 23 sqlalchemy = final.buildPythonPackage rec { 24 pname = "SQLAlchemy"; 25 version = "1.3.24"; 26 format = "setuptools"; 27 28 src = fetchPypi { 29 inherit pname version; 30 sha256 = "sha256-67t3fL+TEjWbiXv4G6ANrg9ctp+6KhgmXcwYpvXvdRk="; 31 }; 32 33 postInstall = '' 34 sed -e 's:--max-worker-restart=5::g' -i setup.cfg 35 ''; 36 37 # tests are pretty annoying to set up for this version, and these dependency overrides are already long enough 38 doCheck = false; 39 }; 40 }; 41 }; 42 43 maubot = python.pkgs.buildPythonPackage rec { 44 pname = "maubot"; 45 version = "0.5.1"; 46 format = "setuptools"; 47 disabled = python.pythonOlder "3.10"; 48 49 src = fetchPypi { 50 inherit pname version; 51 hash = "sha256-0UtelZ3w0QUw825AGhSc8wfhYaL9FSYJXCvYZEefWPQ="; 52 }; 53 54 patches = [ 55 # add entry point - https://github.com/maubot/maubot/pull/146 56 (fetchpatch { 57 url = "https://github.com/maubot/maubot/commit/ef6e23eccb530187dd3447b6aac2047d4a32fb83.patch"; 58 hash = "sha256-d5fu47F93aXZmk6MiSsxTE8pHjMKNL0FUdU+ynUqY2o="; 59 }) 60 ]; 61 62 propagatedBuildInputs = 63 with python.pkgs; 64 [ 65 # requirements.txt 66 (mautrix.override { withOlm = encryptionSupport; }) 67 aiohttp 68 yarl 69 asyncpg 70 aiosqlite 71 commonmark 72 ruamel-yaml 73 attrs 74 bcrypt 75 packaging 76 click 77 colorama 78 questionary 79 jinja2 80 setuptools 81 ] 82 # optional-requirements.txt 83 ++ lib.optionals encryptionSupport [ 84 python-olm 85 pycryptodome 86 unpaddedbase64 87 ] 88 ++ lib.optionals sqliteSupport [ 89 sqlalchemy 90 ]; 91 92 # used for plugin tests 93 propagatedNativeBuildInputs = with python.pkgs; [ 94 pytest 95 pytest-asyncio 96 ]; 97 98 postInstall = '' 99 rm $out/example-config.yaml 100 ''; 101 102 pythonImportsCheck = [ 103 "maubot" 104 ]; 105 106 passthru = 107 let 108 wrapper = callPackage ./wrapper.nix { 109 unwrapped = maubot; 110 python3 = python; 111 }; 112 in 113 { 114 tests = { 115 simple = runCommand "${pname}-tests" { } '' 116 ${maubot}/bin/mbc --help > $out 117 ''; 118 }; 119 120 inherit python; 121 122 plugins = callPackage ./plugins { 123 maubot = maubot; 124 python3 = python; 125 }; 126 127 withPythonPackages = pythonPackages: wrapper { inherit pythonPackages; }; 128 129 # This adds the plugins to lib/maubot-plugins 130 withPlugins = plugins: wrapper { inherit plugins; }; 131 132 # This changes example-config.yaml in module directory 133 withBaseConfig = baseConfig: wrapper { inherit baseConfig; }; 134 }; 135 136 meta = with lib; { 137 description = "Plugin-based Matrix bot system written in Python"; 138 homepage = "https://maubot.xyz/"; 139 changelog = "https://github.com/maubot/maubot/blob/v${version}/CHANGELOG.md"; 140 license = licenses.agpl3Plus; 141 # Presumably, people running "nix run nixpkgs#maubot" will want to run the tool 142 # for interacting with Maubot rather than Maubot itself, which should be used as 143 # a NixOS module. 144 mainProgram = "mbc"; 145 maintainers = with maintainers; [ chayleaf ]; 146 }; 147 }; 148 149in 150maubot