From 3ecaad0e0e9670eda92fa17ddb96f23fcd4159a7 Mon Sep 17 00:00:00 2001
From: Raito Bezarius <masterancpp@gmail.com>
Date: Fri, 12 Jan 2024 03:52:39 +0100
Subject: [PATCH 1/2] nixos/networking/keepalived: do not emit `unicastPeers`
 when there are none

In the past, we emitted `unicast_peer` block even with empty unicast peers list.

This now results in:
```
Keepalived_vrrp[392762]: A unicast keyword has been specified without any unicast peers. Defaulting to multicast. This usage is deprecated - please update your configuration.
```

We do not emit it anymore to avoid this warning.
---
 nixos/modules/services/networking/keepalived/default.nix | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/nixos/modules/services/networking/keepalived/default.nix b/nixos/modules/services/networking/keepalived/default.nix
index 429a47c3962c..bf5e96f001a8 100644
--- a/nixos/modules/services/networking/keepalived/default.nix
+++ b/nixos/modules/services/networking/keepalived/default.nix
@@ -59,9 +59,11 @@ let
         ${optionalString i.vmacXmitBase "vmac_xmit_base"}
 
         ${optionalString (i.unicastSrcIp != null) "unicast_src_ip ${i.unicastSrcIp}"}
-        unicast_peer {
-          ${concatStringsSep "\n" i.unicastPeers}
-        }
+        ${optionalString (builtins.length i.unicastPeers > 0) ''
+          unicast_peer {
+            ${concatStringsSep "\n" i.unicastPeers}
+          }
+        ''}
 
         virtual_ipaddress {
           ${concatMapStringsSep "\n" virtualIpLine i.virtualIps}

From 08c95629950342c4d2185b82a59aec2226f38b96 Mon Sep 17 00:00:00 2001
From: Raito Bezarius <masterancpp@gmail.com>
Date: Mon, 22 Jan 2024 21:56:04 +0100
Subject: [PATCH 2/2] keepalived: add myself as a maintainer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

I will use this for a while, so… let's keep it tidy.
---
 nixos/modules/services/networking/keepalived/default.nix | 1 +
 nixos/tests/keepalived.nix                               | 3 ++-
 pkgs/tools/networking/keepalived/default.nix             | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/nixos/modules/services/networking/keepalived/default.nix b/nixos/modules/services/networking/keepalived/default.nix
index bf5e96f001a8..599dfd52e271 100644
--- a/nixos/modules/services/networking/keepalived/default.nix
+++ b/nixos/modules/services/networking/keepalived/default.nix
@@ -140,6 +140,7 @@ let
 
 in
 {
+  meta.maintainers = [ lib.maintainers.raitobezarius ];
 
   options = {
     services.keepalived = {
diff --git a/nixos/tests/keepalived.nix b/nixos/tests/keepalived.nix
index d0bf9d465200..ce291514591f 100644
--- a/nixos/tests/keepalived.nix
+++ b/nixos/tests/keepalived.nix
@@ -1,5 +1,6 @@
-import ./make-test-python.nix ({ pkgs, ... }: {
+import ./make-test-python.nix ({ pkgs, lib, ... }: {
   name = "keepalived";
+  maintainers = [ lib.maintainers.raitobezarius ];
 
   nodes = {
     node1 = { pkgs, ... }: {
diff --git a/pkgs/tools/networking/keepalived/default.nix b/pkgs/tools/networking/keepalived/default.nix
index 0b2371192d38..02424d92de57 100644
--- a/pkgs/tools/networking/keepalived/default.nix
+++ b/pkgs/tools/networking/keepalived/default.nix
@@ -39,5 +39,6 @@ stdenv.mkDerivation rec {
     description = "Routing software written in C";
     license = licenses.gpl2Plus;
     platforms = platforms.linux;
+    maintainers = [ maintainers.raitobezarius ];
   };
 }