summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/rs/rss2email/package.nix
blob: 19677fff4678fe5a5cc9ddd3d8590f691ccfbc29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{
  lib,
  python3Packages,
  fetchPypi,
  fetchpatch2,
  nixosTests,
}:

python3Packages.buildPythonApplication (finalAttrs: {
  pname = "rss2email";
  version = "3.14";
  pyproject = true;

  src = fetchPypi {
    inherit (finalAttrs) pname version;
    hash = "sha256-RwORS2PHquxBZLNKqCJtR5XX4SHqPCb/Fn+Y68dfI/g=";
  };

  patches = [
    (fetchpatch2 {
      name = "html2text-2024.2.25-compat.patch";
      url = "https://github.com/rss2email/rss2email/commit/b5c0e78006c2db6929b5ff50e8529de58a00412a.patch";
      hash = "sha256-edmsi3I0acx5iF9xoAS9deSexqW2UtWZR/L7CgeZs/M=";
    })
    # https://github.com/rss2email/rss2email/pull/279
    ./html2text-2025.4.15-compat.patch
    (fetchpatch2 {
      name = "use-poetry-core.patch";
      url = "https://github.com/rss2email/rss2email/commit/183a17aefe4eb66f898cf088519b1e845559f2bd.patch";
      hash = "sha256-SoWahlOJ7KkaHMwOrKIBgwEz8zJQrSXVD1w2wiV1phE=";
    })
  ];

  outputs = [
    "out"
    "man"
    "doc"
  ];

  postPatch = ''
    # sendmail executable is called from PATH instead of sbin by default
    substituteInPlace  rss2email/config.py \
      --replace-fail '/usr/sbin/sendmail' 'sendmail'
  '';

  build-system = with python3Packages; [
    poetry-core
  ];

  dependencies = with python3Packages; [
    feedparser
    html2text
  ];

  postInstall = ''
    install -Dm 644 r2e.1 $man/share/man/man1/r2e.1
    # an alias for better finding the manpage
    ln -s -T r2e.1 $man/share/man/man1/rss2email.1

    # copy documentation
    mkdir -p $doc/share/doc/rss2email
    cp AUTHORS COPYING CHANGELOG README.rst $doc/share/doc/rss2email/
  '';

  nativeCheckInputs = [
    python3Packages.unittestCheckHook
  ];

  unittestFlagsArray = [
    "-s"
    "test"
  ];

  meta = {
    description = "Tool that converts RSS/Atom newsfeeds to email";
    homepage = "https://pypi.org/project/rss2email/";
    license = lib.licenses.gpl2;
    mainProgram = "r2e";
  };
  passthru.tests = {
    smoke-test = nixosTests.rss2email;
  };
})