aboutsummaryrefslogtreecommitdiff
path: root/services/lazylibrarian/package.nix
blob: 0df6845caeeffa50ec25ec0de899a4fb36226884 (plain) (blame)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# https://github.com/NixOS/nixpkgs/pull/423722/files
{
  calibre,
  fetchFromGitLab,
  fetchPypi,
  ffmpeg-headless,
  lib,
  nix-update-script,
  python3Packages,
  calibreSupport ? true,
  ffmpegSupport ? true,
}:
let
  ez_setup = python3Packages.buildPythonPackage rec {
    pname = "ez_setup";
    version = "0.9";
    pyproject = true;

    src = fetchPypi {
      inherit pname version;
      hash = "sha256-MDxbF9VS0eP7BQXYBUn4V59VfhPY3JDl7O88B9f1hkI=";
    };

    build-system = with python3Packages; [
      distutils
      setuptools
      wheel
    ];

    pythonImportsCheck = [
      "ez_setup"
    ];
  };

  slskd-api = python3Packages.buildPythonPackage rec {
    pname = "slskd-api";
    version = "0.1.5";
    pyproject = true;

    src = fetchPypi {
      inherit pname version;
      hash = "sha256-LmWP7bnK5IVid255qS2NGOmyKzGpUl3xsO5vi5uJI88=";
    };

    build-system = with python3Packages; [
      setuptools
      setuptools-git-versioning
      wheel
    ];

    dependencies = with python3Packages; [
      requests
    ];

    pythonImportsCheck = [
      "slskd_api"
    ];
  };
in
python3Packages.buildPythonApplication rec {
  pname = "lazylibrarian";
  version = "2025.01.09-unstable-2025-07-08";
  pyproject = true;

  src = fetchFromGitLab {
    owner = "LazyLibrarian";
    repo = "LazyLibrarian";
    rev = "d88acba6332ebcc517b1d071a27a0b5afe522c0f";
    hash = "sha256-HMoV9pLCdgppmSHJfJcpEWiogTJys1qIjeHvXpT+3fo=";
  };

  patches = [
    ./fix-setup.diff
  ];

  postPatch = ''
    mkdir -p src
    mv LazyLibrarian.py lazylibrarian lib data src
  '';

  build-system = with python3Packages; [
    ez_setup
    setuptools
  ];

  dependencies =
    with python3Packages;
    [
      apprise
      apscheduler
      beautifulsoup4
      cherrypy
      cherrypy-cors
      deluge-client
      html5lib
      httpagentparser
      httplib2
      irc
      mako
      pillow
      pyopenssl
      pyparsing
      pypdf
      python-magic
      rapidfuzz
      requests
      tzdata
      urllib3
      webencodings
    ]
    ++ [ slskd-api ]
    ++ lib.optional calibreSupport [ calibre ]
    ++ lib.optional ffmpegSupport [ ffmpeg-headless ];

  pythonImportsCheck = [
    "lazylibrarian"
  ];

  makeWrapperArgs = [
    # Avoid automatic updates.
    "--set DOCKER 1"
    # Avoid `datadir` being on `/nix/store` by default.
    "--add-flags --datadir=\\$XDG_DATA_HOME/${meta.mainProgram}"
  ];

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Usenet/BitTorrent ebook, audiobook and magazine downloader";
    homepage = "https://lazylibrarian.gitlab.io/";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ xelden ];
    mainProgram = "lazylibrarian";
  };
}