This is a Nix flake containing the package pcs and a module for it that allows you to manage a Pacemaker cluster declaratively in nix code.
You can read about the options this module exposes here: https://matt1432.github.io/nixos-pcsd/all/
In your flake.nix
inputs:
...
pcsd = {
# This way of declaring inputs is way cleaner IMO
type = "github";
owner = "matt1432";
repo = "nixos-pcsd";
# Here is the classic one
# url = "github:matt1432/nixos-pcsd";
};
...
Before enabling this module, it is very important to know that it will manage
services.pacemaker
and services.corosync
for you. Any of their settings
could be replaced by the ones you declare in services.pcsd
.
In your server config, this would be the most barebones settings:
{pcsd, ...}: {
imports = [pcsd.nixosModules.default];
services.pcsd = {
enable = true;
enableBinaryCache = true;
# I highly recommend using sops-nix or agenix for these settings
corosyncKeyFile = builtins.toFile "keyfile" "some128charLongText";
clusterUserPasswordFile = builtins.toFile "password" "somePassword";
nodes = [
{
name = "this Machine's Hostname";
nodeid = 1;
ring_addrs = [
# This is where your machine's local ips go
"192.168.0.255"
];
}
# the other nodes of your cluster go here
];
};
}
You can also take a look at my pcsd setup to see more options and a real world example.
- ClusterLabs for the software used to configure the cluster:
- Mitchty for sharing the only method I've found to manage pacemaker on NixOS: