Skip to content

Commit

Permalink
nixos/services.corosync: remove with lib;
Browse files Browse the repository at this point in the history
  • Loading branch information
Stunkymonkey committed Dec 8, 2024
1 parent 5c7e172 commit ddcd8d5
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions nixos/modules/services/cluster/corosync/default.nix
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
{ config, lib, pkgs, ... }:

with lib;
let
cfg = config.services.corosync;
in
{
# interface
options.services.corosync = {
enable = mkEnableOption "corosync";
enable = lib.mkEnableOption "corosync";

package = mkPackageOption pkgs "corosync" { };
package = lib.mkPackageOption pkgs "corosync" { };

clusterName = mkOption {
type = types.str;
clusterName = lib.mkOption {
type = lib.types.str;
default = "nixcluster";
description = "Name of the corosync cluster.";
};

extraOptions = mkOption {
type = with types; listOf str;
extraOptions = lib.mkOption {
type = with lib.types; listOf str;
default = [];
description = "Additional options with which to start corosync.";
};

nodelist = mkOption {
nodelist = lib.mkOption {
description = "Corosync nodelist: all cluster members.";
default = [];
type = with types; listOf (submodule {
type = with lib.types; listOf (submodule {
options = {
nodeid = mkOption {
nodeid = lib.mkOption {
type = int;
description = "Node ID number";
};
name = mkOption {
name = lib.mkOption {
type = str;
description = "Node name";
};
ring_addrs = mkOption {
ring_addrs = lib.mkOption {
type = listOf str;
description = "List of addresses, one for each ring.";
};
Expand All @@ -46,7 +44,7 @@ in
};

# implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];

environment.etc."corosync/corosync.conf".text = ''
Expand All @@ -58,11 +56,11 @@ in
}
nodelist {
${concatMapStrings ({ nodeid, name, ring_addrs }: ''
${lib.concatMapStrings ({ nodeid, name, ring_addrs }: ''
node {
nodeid: ${toString nodeid}
name: ${name}
${concatStrings (imap0 (i: addr: ''
${lib.concatStrings (lib.imap0 (i: addr: ''
ring${toString i}_addr: ${addr}
'') ring_addrs)}
}
Expand All @@ -73,7 +71,7 @@ in
# only corosync_votequorum is supported
provider: corosync_votequorum
wait_for_all: 0
${optionalString (builtins.length cfg.nodelist < 3) ''
${lib.optionalString (builtins.length cfg.nodelist < 3) ''
two_node: 1
''}
}
Expand Down

0 comments on commit ddcd8d5

Please sign in to comment.