summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/pa/pacemaker/package.nix
blob: 7d670749fe05c04493eb7bad82cb98cff793817b (plain)
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
136
137
138
139
140
141
142
143
144
145
146
147
148
{
  lib,
  stdenv,
  autoconf,
  automake,
  bash,
  bzip2,
  corosync,
  dbus,
  docbook_xsl,
  fetchFromGitHub,
  getopt,
  gettext,
  glib,
  gnutls,
  help2man,
  libqb,
  libtool,
  libuuid,
  libxml2,
  libxslt,
  pam,
  pkg-config,
  python3,
  nixosTests,
  versionCheckHook,

  # Pacemaker is compiled twice, once with forOCF = true to extract its
  # OCF definitions for use in the ocf-resource-agents derivation, then
  # again with forOCF = false, where the ocf-resource-agents is provided
  # as the OCF_ROOT.
  forOCF ? false,
  ocf-resource-agents,
  withManpages ? !forOCF,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "pacemaker";
  version = "3.0.1";

  src = fetchFromGitHub {
    owner = "ClusterLabs";
    repo = "pacemaker";
    tag = "Pacemaker-${finalAttrs.version}";
    hash = "sha256-23YkNzqiimLy/KjO+hxVQQ4rUhSEhn5Oc2jUJO/VRo0=";
  };

  outputs = [ "out" ] ++ lib.optionals withManpages [ "man" ];

  nativeBuildInputs = [
    autoconf
    automake
    gettext
    getopt
    libtool
    pkg-config
    python3
  ]
  ++ lib.optionals withManpages [
    # If we don't supply the dependencies the manpage build will be silently skipped
    help2man # for tool man pages (see mk/man.mk)
    libxml2 # for other man pages (xmllint)
    libxslt # for other man pages (xsltproc)
  ];

  buildInputs = [
    bash
    bzip2
    corosync
    dbus
    glib
    gnutls
    libqb
    libtool
    libuuid
    libxml2
    libxslt
    pam
  ];

  strictDeps = true;

  # If we do this unconditionally the build will fail because it sees a valid MANPAGE_XSLT
  # but required executables are not available.
  postPatch = lib.optionalString withManpages ''
    # Avoid the use of xmlcatalog to resolve stylesheet for manpages, but set the path directly
    substituteInPlace configure.ac \
      --replace-fail 'MANPAGE_XSLT=""' 'MANPAGE_XSLT="${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl"' \
      --replace-fail 'AS_IF([test x"''${XSLTPROC}" != x""],' 'AS_IF([false],'
  '';

  preConfigure = ''
    ./autogen.sh --prefix="$out"
  '';
  configureFlags = [
    "--exec-prefix=${placeholder "out"}"
    "--sysconfdir=/etc"
    "--localstatedir=/var"
    "--with-initdir=/etc/systemd/system"
    "--with-systemdsystemunitdir=/etc/systemd/system"
    "--with-corosync"
    # allows Type=notify in the systemd service
    "--enable-systemd"
  ]
  ++ lib.optional (!forOCF) "--with-ocfdir=${ocf-resource-agents}/usr/lib/ocf";

  installFlags = [ "DESTDIR=${placeholder "out"}" ];

  env.NIX_CFLAGS_COMPILE = toString (
    lib.optionals stdenv.cc.isGNU [
      "-Wno-error=strict-prototypes"
      "-Wno-error=deprecated-declarations"
    ]
  );

  enableParallelBuilding = true;

  # pacemaker's install linking requires a weirdly nested hierarchy
  postInstall =
    lib.optionalString withManpages ''
      mkdir -p $man
      mv $out$man/* $man
    ''
    + ''
      mv $out$out/* $out
      rm -r $out/nix
    '';

  doInstallCheck = true;
  nativeInstallCheckInputs = [ versionCheckHook ];
  versionCheckProgram = [ "${placeholder "out"}/sbin/pacemakerd" ];
  versionCheckProgramArg = "--version";

  passthru.tests = {
    inherit (nixosTests) pacemaker;
  };

  meta = {
    homepage = "https://clusterlabs.org/pacemaker/";
    description = "Open source, high availability resource manager suitable for both small and large clusters";
    license = lib.licenses.gpl2Plus;
    platforms = lib.platforms.linux;
    maintainers = with lib.maintainers; [
      ryantm
      astro
    ];
  };
})