nixos/tests/acme: explicitly start the targets we wait for
[NixPkgs.git] / pkgs / by-name / rs / rspamd-trainer / package.nix
blobe00bddcbfbceaf8598da65433089c5b216797f77
1 { lib
2 , python3
3 , python3Packages
4 , fetchFromGitLab
5 , fetchpatch
6 , rspamd
7 , nixosTests
8 }:
10 python3Packages.buildPythonApplication {
11   pname = "rspamd-trainer";
12   version = "unstable-2023-11-27";
13   format = "pyproject";
15   src = fetchFromGitLab {
16     owner = "onlime";
17     repo = "rspamd-trainer";
18     rev = "eb6639a78a019ade6781f3a8418eddc030f8fa14";
19     hash = "sha256-Me6WZhQ6SvDGGBQQtSA/7bIfKtsz6D5rvQeU12sVzgY=";
20   };
22   patches = [
23     # Refactor pyproject.toml
24     # https://gitlab.com/onlime/rspamd-trainer/-/merge_requests/2
25     (fetchpatch {
26       url = "https://gitlab.com/onlime/rspamd-trainer/-/commit/8824bfb9a9826988a90a401b8e51c20f5366ed70.patch";
27       hash = "sha256-qiXfwMUfM/iV+fHba8xdwQD92RQz627+HdUTgwgRZdc=";
28       name = "refactor_pyproject.patch";
29     })
30   ];
32   postPatch = ''
33     # Fix module path not applied by patch
34     mv helper src/
35     touch src/helper/__init__.py
36     mv settings.py src/rspamd_trainer/
37     sed -i 's/from settings/from .settings/' src/rspamd_trainer/run.py
39     # Fix rspamc path
40     sed -i "s|/usr/bin/rspamc|${rspamd}/bin/rspamc|" src/rspamd_trainer/run.py
41   '';
43   nativeBuildInputs = with python3.pkgs; [
44     setuptools-scm
45   ];
47   propagatedBuildInputs = with python3.pkgs; [
48     python-dotenv
49     imapclient
50   ];
52   passthru.tests = { inherit (nixosTests) rspamd-trainer; };
54   meta = {
55     homepage = "https://gitlab.com/onlime/rspamd-trainer";
56     description = "Grabs messages from a spam mailbox via IMAP and feeds them to Rspamd for training";
57     mainProgram = "rspamd-trainer";
58     license = lib.licenses.gpl3Only;
59     maintainers = with lib.maintainers; [ onny ];
60   };