pkgs/pacemaker: init at 2.0.5

This commit is contained in:
Astro 2021-11-20 17:51:32 +01:00
parent 7ac993f61e
commit 8a90239a96
5 changed files with 298 additions and 0 deletions

View File

@ -91,9 +91,35 @@ let
subnetplans = import ./subnetplans.nix {
inherit self nixpkgs system;
};
drbd-utils = pkgs.callPackage ./drbd-utils.nix {
inherit ocf-resource-agents;
};
drbd-utilsForOCF = pkgs.callPackage ./drbd-utils.nix {
inherit ocf-resource-agents;
forOCF = true;
};
resource-agents = pkgs.callPackage ./resource-agents.nix {};
ocf-resource-agents = pkgs.callPackage ./ocf-resource-agents.nix {
inherit resource-agents
drbd-utilsForOCF
pacemakerForOCF
;
};
pacemakerForOCF = pkgs.callPackage ./pacemaker.nix {
inherit ocf-resource-agents;
forOCF = true;
};
pacemaker = pkgs.callPackage ./pacemaker.nix {
inherit ocf-resource-agents;
};
in
rootfs-packages // vm-packages // device-templates // network-graphs // starlink // subnetplans // {
inherit all-rootfs export-openwrt-models export-config dns-slaves
encrypt-secrets decrypt-secrets switch-to-production
pacemaker
;
}

128
nix/pkgs/drbd-utils.nix Normal file
View File

@ -0,0 +1,128 @@
{ lib
, stdenv
, docbook_xml_dtd_44
, docbook_xml_dtd_45
, docbook_xsl
, asciidoctor
, fetchurl
, flex
, kmod
, libxslt
, nixosTests
, perl
, systemd
# drbd-utils are 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
}:
stdenv.mkDerivation rec {
pname = "drbd-utils";
version = "9.19.1";
src = fetchurl {
url = "https://pkg.linbit.com/downloads/drbd/utils/${pname}-${version}.tar.gz";
sha256 = "1l99kcrb0j85wxxmrdihpx9bk1a4sdi7wlp5m1x5l24k8ck1m5cf";
};
nativeBuildInputs = [
flex
libxslt
docbook_xsl
asciidoctor
];
buildInputs = [
perl
# perlPackages.Po4a used by ja documentation
];
configureFlags = [
"--libdir=${placeholder "out"}/lib"
"--sbindir=${placeholder "out"}/bin"
"--localstatedir=/var"
"--sysconfdir=/etc"
"--without-distro"
];
makeFlags = [
"SOURCE_DATE_EPOCH=1"
"WANT_DRBD_REPRODUCIBLE_BUILD=1"
] ++ lib.optional (!forOCF) "OCF_ROOT=${ocf-resource-agents}/usr/lib/ocf}";
installFlags = [
"prefix="
"DESTDIR=${placeholder "out"}"
"localstatedir=/var"
"DRBD_LIB_DIR=/var/lib"
"INITDIR=/etc/init.d"
"udevrulesdir=/lib"
"sysconfdir=/etc"
"sbindir=/bin"
"datadir="
"LIBDIR=/lib/drbd"
"mandir=/share/man"
];
postPatch = ''
patchShebangs .
substituteInPlace user/v84/drbdadm_usage_cnt.c \
--replace '"/lib/drbd");' \
'"${placeholder "out"}/lib/drbd");'
substituteInPlace user/v9/drbdsetup_linux.c \
--replace 'ret = system("/sbin/modprobe drbd");' \
'ret = system("${kmod}/bin/modprobe drbd");'
substituteInPlace user/v84/drbdsetup.c \
--replace 'system("/sbin/modprobe drbd")' \
'system("${kmod}/bin/modprobe drbd")'
substituteInPlace documentation/ra2refentry.xsl \
--replace "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" \
"${docbook_xml_dtd_44}/xml/dtd/docbook/docbookx.dtd"
function patch_docbook45() {
substituteInPlace $1 \
--replace "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" \
"${docbook_xml_dtd_45}/xml/dtd/docbook/docbookx.dtd"
}
patch_docbook45 documentation/v9/drbd.conf.xml.in
patch_docbook45 documentation/v9/drbdsetup.xml.in
patch_docbook45 documentation/v84/drbdsetup.xml
patch_docbook45 documentation/v84/drbd.conf.xml
# The ja documentation is disabled because:
# make[1]: Entering directory '/build/drbd-utils-9.16.0/documentation/ja/v84'
# /nix/store/wyx2nn2pjcn50lc95c6qgsgm606rn0x2-perl5.32.1-po4a-0.62/bin/po4a-translate -f docbook -M utf-8 -L utf-8 -keep 0 -m ../../v84/drbdsetup.xml -p drbdsetup.xml.po -l drbdsetup.xml
# Use of uninitialized value $args[1] in sprintf at /nix/store/wyx2nn2pjcn50lc95c6qgsgm606rn0x2-perl5.32.1-po4a-0.62/lib/perl5/site_perl/Locale/Po4a/Common.pm line 134.
# Invalid po file drbdsetup.xml.po:
substituteInPlace Makefile.in \
--replace 'DOC_DIRS := documentation/v9 documentation/ja/v9' \
'DOC_DIRS := documentation/v9' \
--replace 'DOC_DIRS += documentation/v84 documentation/ja/v84' \
'DOC_DIRS += documentation/v84' \
--replace '$(MAKE) -C documentation/ja/v9 doc' \
"" \
--replace '$(MAKE) -C documentation/ja/v84 doc' \
""
substituteInPlace user/v9/drbdtool_common.c \
--replace 'add_component_to_path("/lib/drbd");' \
'add_component_to_path("${placeholder "out"}/lib/drbd");'
'';
preConfigure = ''
export PATH=${systemd}/sbin:$PATH
'';
enableParallelBuilding = true;
passthru.tests.drbd = nixosTests.drbd;
meta = with lib; {
homepage = "https://linbit.com/drbd/";
description = "DRBD userspace utilities";
license = licenses.gpl2Plus;
platforms = platforms.linux;
maintainers = with maintainers; [ ryantm ];
};
}

View File

@ -0,0 +1,17 @@
# This combines together OCF definitions from other derivations.
# https://github.com/ClusterLabs/resource-agents/blob/master/doc/dev-guides/ra-dev-guide.asc
{ stdenv
, lib
, runCommand
, lndir
, resource-agents
, drbd-utilsForOCF
, pacemakerForOCF
} :
runCommand "ocf-resource-agents" {} ''
mkdir -p $out/usr/lib/ocf
${lndir}/bin/lndir -silent "${resource-agents}/lib/ocf/" $out/usr/lib/ocf
${lndir}/bin/lndir -silent "${drbd-utilsForOCF}/usr/lib/ocf/" $out/usr/lib/ocf
${lndir}/bin/lndir -silent "${pacemakerForOCF}/usr/lib/ocf/" $out/usr/lib/ocf
''

90
nix/pkgs/pacemaker.nix Normal file
View File

@ -0,0 +1,90 @@
{ lib
, stdenv
, autoreconfHook
, bash
, bzip2
, corosync
, dbus
, fetchFromGitHub
, glib
, gnutls
, libqb
, libtool
, libuuid
, libxml2
, libxslt
, pam
, pkg-config
, python3
# 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
} :
stdenv.mkDerivation rec {
pname = "pacemaker";
version = "2.0.5";
src = fetchFromGitHub {
owner = "ClusterLabs";
repo = pname;
rev = "Pacemaker-${version}";
sha256 = "1wrdqdxbdl506ry6i5zqwmf66ms96hx2h6rn4jzpi5w13wg8sbm4";
};
nativeBuildInputs = [
autoreconfHook
libtool
pkg-config
];
buildInputs = [
bash
bzip2
corosync
dbus.dev
glib
gnutls
libqb
libuuid
libxml2.dev
libxslt.dev
pam
python3
];
configureFlags = [
"--exec-prefix=${placeholder "out"}"
"--sysconfdir=/etc"
"--datadir=/var/lib"
"--localstatedir=/var"
"--enable-systemd"
"--with-systemdsystemunitdir=/etc/systemd/system"
"--with-corosync"
] ++ lib.optional (!forOCF) "--with-ocfdir=${ocf-resource-agents}/usr/lib/ocf";
installFlags = [ "DESTDIR=${placeholder "out"}" ];
NIX_CFLAGS_COMPILE = lib.optionals stdenv.cc.isGNU [
"-Wno-error=strict-prototypes"
];
enableParallelBuilding = true;
postInstall = ''
mv $out$out/* $out
rm -r $out/nix
ln -sf /var/lib/pacemaker/cib $out/var/lib/pacemaker/cib
'';
meta = with lib; {
homepage = "https://clusterlabs.org/pacemaker/";
description = "Pacemaker is an open source, high availability resource manager suitable for both small and large clusters.";
license = licenses.gpl2Plus;
platforms = platforms.linux;
maintainers = with maintainers; [ ryantm ];
};
}

View File

@ -0,0 +1,37 @@
{ lib, stdenv
, fetchFromGitHub
, autoreconfHook
, pkg-config
, python3
, glib
}:
stdenv.mkDerivation rec {
pname = "resource-agents";
version = "4.8.0";
src = fetchFromGitHub {
owner = "ClusterLabs";
repo = pname;
rev = "v${version}";
sha256 = "sha256:1mdrwr3yqdqaifh3ynnhzdc59yfn4x00iygxqvh33p53jgf7cqir";
};
nativeBuildInputs = [
autoreconfHook
pkg-config
];
buildInputs = [
glib
python3
];
meta = with lib; {
homepage = "https://github.com/ClusterLabs/resource-agents";
description = "Combined repository of OCF agents from the RHCS and Linux-HA projects";
license = licenses.gpl2Plus;
platforms = platforms.linux;
maintainers = with maintainers; [ ryantm ];
};
}