1{ lib
2, stdenv
3, autoconf
4, automake
5, bash
6, bzip2
7, corosync
8, dbus
9, fetchFromGitHub
10, glib
11, gnutls
12, libqb
13, libtool
14, libuuid
15, libxml2
16, libxslt
17, pam
18, pkg-config
19, python3
20, nixosTests
21
22# Pacemaker is compiled twice, once with forOCF = true to extract its
23# OCF definitions for use in the ocf-resource-agents derivation, then
24# again with forOCF = false, where the ocf-resource-agents is provided
25# as the OCF_ROOT.
26, forOCF ? false
27, ocf-resource-agents
28} :
29
30stdenv.mkDerivation rec {
31 pname = "pacemaker";
32 version = "2.1.6";
33
34 src = fetchFromGitHub {
35 owner = "ClusterLabs";
36 repo = pname;
37 rev = "Pacemaker-${version}";
38 sha256 = "sha256-3+eRQ3NqPusdFhKc0wE7UMMNKsDLRVvh+EhD6zYGoP0=";
39 };
40
41 nativeBuildInputs = [
42 autoconf
43 automake
44 libtool
45 pkg-config
46 ];
47
48 buildInputs = [
49 bash
50 bzip2
51 corosync
52 dbus.dev
53 glib
54 gnutls
55 libqb
56 libuuid
57 libxml2.dev
58 libxslt.dev
59 pam
60 python3
61 ];
62
63 preConfigure = ''
64 ./autogen.sh --prefix="$out"
65 '';
66 configureFlags = [
67 "--exec-prefix=${placeholder "out"}"
68 "--sysconfdir=/etc"
69 "--localstatedir=/var"
70 "--with-initdir=/etc/systemd/system"
71 "--with-systemdsystemunitdir=/etc/systemd/system"
72 "--with-corosync"
73 # allows Type=notify in the systemd service
74 "--enable-systemd"
75 ] ++ lib.optional (!forOCF) "--with-ocfdir=${ocf-resource-agents}/usr/lib/ocf";
76
77 installFlags = [ "DESTDIR=${placeholder "out"}" ];
78
79 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [
80 "-Wno-error=strict-prototypes"
81 ]);
82
83 enableParallelBuilding = true;
84
85 postInstall = ''
86 # pacemaker's install linking requires a weirdly nested hierarchy
87 mv $out$out/* $out
88 rm -r $out/nix
89 '';
90
91 passthru.tests = {
92 inherit (nixosTests) pacemaker;
93 };
94
95 meta = with lib; {
96 homepage = "https://clusterlabs.org/pacemaker/";
97 description = "Pacemaker is an open source, high availability resource manager suitable for both small and large clusters.";
98 license = licenses.gpl2Plus;
99 platforms = platforms.linux;
100 maintainers = with maintainers; [ ryantm astro ];
101 };
102}