about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/misc/archivy/default.nix
blob: fd58ea48e5545b2a0faa85e6dcf2c275391b1f21 (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
{ lib, stdenv, python3, fetchPypi }:

let
  defaultOverrides = [
    (self: super: {
      flask = super.flask.overridePythonAttrs (oldAttrs: rec {
        version = "1.1.2";
        pname = "Flask";

        src = super.fetchPypi {
          inherit pname version;
          sha256 = "sha256-Tvoa4tfJhlr0iYbeiuuFBL8yx/PW/ck1PTSyH0sScGA=";
        };

        checkInputs = [ self.pytest ];
        propagatedBuildInputs = with self; [ itsdangerous click werkzeug jinja2 ];

        doCheck = false;
      });
    })

    (self: super: {
      flask_login = super.flask_login.overridePythonAttrs (oldAttrs: rec {
        pname = "Flask";
        version = "0.5.0";

        src = fetchPypi {
          inherit pname version;
          sha256 = "6d33aef15b5bcead780acc339464aae8a6e28f13c90d8b1cf9de8b549d1c0b4b";
        };
        doCheck = false;
      });
    })
  ];

  mkOverride = attrname: version: sha256:
    self: super: {
      ${attrname} = super.${attrname}.overridePythonAttrs (oldAttrs: {
        inherit version;
        src = oldAttrs.src.override {
          inherit version sha256;
        };
      });
    };

  py = python3.override {
    # Put packageOverrides at the start so they are applied after defaultOverrides
    packageOverrides = lib.foldr lib.composeExtensions (self: super: { }) (defaultOverrides);
  };

in
with py.pkgs;

buildPythonApplication rec {
  pname = "archivy";
  version = "1.4.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "sha256-wQuR7cltDLr2u8BQ851MSjKmeLW8mQ/3bdEF5c9nxL0=";
  };

  # Relax some dependencies
  postPatch = ''
    substituteInPlace requirements.txt \
      --replace 'WTForms ==' 'WTForms >=' \
      --replace 'attrs == 20.2.0' 'attrs' \
      --replace 'elasticsearch ==' 'elasticsearch >=' \
      --replace 'python_dotenv ==' 'python_dotenv >=' \
      --replace 'python_frontmatter == 0.5.0' 'python_frontmatter' \
      --replace 'requests ==' 'requests >=' \
      --replace 'validators ==' 'validators >=' \
      --replace 'tinydb ==' 'tinydb >=' \
      --replace 'Flask_WTF == 0.14.3' 'Flask_WTF' \
      --replace 'Werkzeug ==' 'Werkzeug >='
  '';

  propagatedBuildInputs = [
    appdirs
    attrs
    beautifulsoup4
    click-plugins
    elasticsearch
    flask-compress
    flask_login
    flask_wtf
    html2text
    python-dotenv
    python-frontmatter
    requests
    setuptools
    tinydb
    validators
    werkzeug
    wtforms
  ];

  # __init__.py attempts to mkdir in read-only file system
  doCheck = false;

  meta = with lib; {
    description = "Self-hosted knowledge repository";
    homepage = "https://archivy.github.io";
    license = licenses.mit;
    maintainers = with maintainers; [ siraben ];
    platforms = platforms.unix;
  };
}