1{ lib, stdenv, fetchFromGitHub, postgresql, openssl, zlib, readline, libkrb5, libxcrypt }:
2
3stdenv.mkDerivation rec {
4 pname = "pg_auto_failover";
5 version = "2.0";
6
7 src = fetchFromGitHub {
8 owner = "citusdata";
9 repo = pname;
10 rev = "v${version}";
11 sha256 = "sha256-CLtLOzKRB9p6+SytMvWCYo7m7s/d+clAGOa2sWi6uZ0=";
12 };
13
14 buildInputs = [ postgresql openssl zlib readline libkrb5 ]
15 ++ lib.optionals (stdenv.isLinux && lib.versionOlder postgresql.version "13") [ libxcrypt ];
16
17 installPhase = ''
18 install -D -t $out/bin src/bin/pg_autoctl/pg_autoctl
19 install -D -t $out/lib src/monitor/pgautofailover.so
20 install -D -t $out/share/postgresql/extension src/monitor/*.sql
21 install -D -t $out/share/postgresql/extension src/monitor/pgautofailover.control
22 '';
23
24 meta = with lib; {
25 description = "PostgreSQL extension and service for automated failover and high-availability";
26 homepage = "https://github.com/citusdata/pg_auto_failover";
27 changelog = "https://github.com/citusdata/pg_auto_failover/raw/v${version}/CHANGELOG.md";
28 maintainers = [ maintainers.marsam ];
29 platforms = postgresql.meta.platforms;
30 license = licenses.postgresql;
31 broken = versionOlder postgresql.version "10";
32 };
33}