1{ lib
2, pythonPackages
3, fetchFromGitHub
4, nixosTests
5}:
6
7pythonPackages.buildPythonApplication rec {
8 pname = "patroni";
9 version = "2.1.3";
10
11 src = fetchFromGitHub {
12 owner = "zalando";
13 repo = pname;
14 rev = "v${version}";
15 sha256 = "sha256-cBkiBrty/6A3rIv9A1oh8GvPjwxhHwYEKuDIsNzHw1g=";
16 };
17
18 # cdiff renamed to ydiff; remove when patroni source reflects this.
19 postPatch = ''
20 for i in requirements.txt patroni/ctl.py tests/test_ctl.py; do
21 substituteInPlace $i --replace cdiff ydiff
22 done
23 '';
24
25 propagatedBuildInputs = with pythonPackages; [
26 boto
27 click
28 consul
29 dnspython
30 kazoo
31 kubernetes
32 prettytable
33 psutil
34 psycopg2
35 pysyncobj
36 python-dateutil
37 python-etcd
38 pyyaml
39 tzlocal
40 urllib3
41 ydiff
42 ];
43
44 nativeCheckInputs = with pythonPackages; [
45 flake8
46 mock
47 pytestCheckHook
48 pytest-cov
49 requests
50 ];
51
52 # Fix tests by preventing them from writing to /homeless-shelter.
53 preCheck = "export HOME=$(mktemp -d)";
54
55 pythonImportsCheck = [ "patroni" ];
56
57 passthru.tests = {
58 patroni = nixosTests.patroni;
59 };
60
61 meta = with lib; {
62 homepage = "https://patroni.readthedocs.io/en/latest/";
63 description = "A Template for PostgreSQL HA with ZooKeeper, etcd or Consul";
64 license = licenses.mit;
65 platforms = platforms.unix;
66 maintainers = teams.deshaw.members;
67 };
68}