at 23.11-pre 1.2 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4let 5 cfg = config.services.pacemaker; 6in 7{ 8 # interface 9 options.services.pacemaker = { 10 enable = mkEnableOption (lib.mdDoc "pacemaker"); 11 12 package = mkOption { 13 type = types.package; 14 default = pkgs.pacemaker; 15 defaultText = literalExpression "pkgs.pacemaker"; 16 description = lib.mdDoc "Package that should be used for pacemaker."; 17 }; 18 }; 19 20 # implementation 21 config = mkIf cfg.enable { 22 assertions = [ { 23 assertion = config.services.corosync.enable; 24 message = '' 25 Enabling services.pacemaker requires a services.corosync configuration. 26 ''; 27 } ]; 28 29 environment.systemPackages = [ cfg.package ]; 30 31 # required by pacemaker 32 users.users.hacluster = { 33 isSystemUser = true; 34 group = "pacemaker"; 35 home = "/var/lib/pacemaker"; 36 }; 37 users.groups.pacemaker = {}; 38 39 systemd.tmpfiles.rules = [ 40 "d /var/log/pacemaker 0700 hacluster pacemaker -" 41 ]; 42 43 systemd.packages = [ cfg.package ]; 44 systemd.services.pacemaker = { 45 wantedBy = [ "multi-user.target" ]; 46 serviceConfig = { 47 StateDirectory = "pacemaker"; 48 StateDirectoryMode = "0700"; 49 }; 50 }; 51 }; 52}