corosync-qnetd package and service module working

This commit is contained in:
Kabbone 2025-09-09 22:45:23 +02:00
parent 9bf0ad396f
commit 583dd62731
Signed by: Kabbone
SSH Key Fingerprint: SHA256:A5zPB5I6u5V78V51c362BBdCwhDhfDUVbt7NfKdjWBY
3 changed files with 113 additions and 35 deletions

View File

@ -0,0 +1,65 @@
{
lib,
config,
pkgs,
pkgs-kabbone,
...
}:
let
cfg = config.services.corosync-qnetd;
in
{
# interface
options.services.corosync-qnetd = {
enable = lib.mkEnableOption "corosync-qnetd";
package = lib.mkPackageOption pkgs-kabbone "corosync-qdevice" { };
extraOptions = lib.mkOption {
type = with lib.types; listOf str;
default = [ ];
description = "Additional options with which to start corosync-qnetd.";
};
};
# implementation
# implementation
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
# environment.etc."corosync/corosync-qnetd.conf".text = ''
# totem {
# version: 2
# secauth: on
# cluster_name: ${cfg.clusterName}
# transport: knet
# }
# logging {
# to_syslog: yes
# }
# '';
systemd.packages = [ cfg.package ];
systemd.services.corosync-qnetd = {
serviceConfig = {
User = "coroqnetd";
StateDirectory = "corosync-qnetd";
StateDirectoryMode = "0700";
};
};
environment.etc."sysconfig/corosync-qnetd".text = lib.optionalString (cfg.extraOptions != [ ]) ''
COROSYNC-QNETD_OPTIONS="${lib.escapeShellArgs cfg.extraOptions}"
'';
};
meta = {
#buildDocsInSandbox = false;
#doc = ./mautrix-whatsapp.md;
maintainers = with lib.maintainers; [
kabbone
];
};
}

View File

@ -1,7 +1,10 @@
#{ stdenv, fetchgit, corosync, nss } :
{ pkgs ? import <nixpkgs> {} }:
pkgs.stdenv.mkDerivation rec {
name = "corosync-qdevice";
{
lib,
pkgs,
stdenv
} :
stdenv.mkDerivation rec {
pname = "corosync-qdevice";
version = "3.0.3";
src = pkgs.fetchFromGitHub {
owner = "corosync";
@ -12,19 +15,18 @@ pkgs.stdenv.mkDerivation rec {
enableParallelBuilding = true;
nativeBuildInputs = with pkgs; [
nss
autoconf
automake
libtool
pkg-config
libqb
corosync
systemd
];
# buildInputs = with pkgs; [
# corosync
# ];
buildInputs = with pkgs; [
corosync
nss
];
configurePhase = ''
./autogen.sh
@ -37,4 +39,11 @@ pkgs.stdenv.mkDerivation rec {
buildPhase = ''
make
'';
meta = {
description = "daemon for quorum on clusters";
homepage = "https://github.com/corosync/corosync-qdevice";
platforms = lib.platforms.linux;
license = lib.licenses.gpl3;
};
}

4
packages/default.nix Normal file
View File

@ -0,0 +1,4 @@
{ pkgs, ... }:
{
corosync-qdevice = pkgs.callPackage ./corosync-qdevice.nix {};
}