From 0b6f4a29df29c083c41418f4809f14eea3fae9b7 Mon Sep 17 00:00:00 2001 From: qubitnano <146656568+qubitnano@users.noreply.github.com> Date: Tue, 3 Dec 2024 18:03:37 -0500 Subject: [PATCH 1/3] unifi-controller: patchelf unifi's sdnotify Fixes the following in server.log: ERROR sdnotify - failed to load ubnt_sdnotify_jni java.lang.UnsatisfiedLinkError: /var/lib/unifi/lib/native/Linux/x86_64/libubnt_sdnotify_jni.so: libsystemd.so.0: cannot open shared object file: No such file or directory --- pkgs/by-name/un/unifi/package.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkgs/by-name/un/unifi/package.nix b/pkgs/by-name/un/unifi/package.nix index 6af57d380923..85c1ee1d7192 100644 --- a/pkgs/by-name/un/unifi/package.nix +++ b/pkgs/by-name/un/unifi/package.nix @@ -4,6 +4,7 @@ dpkg, fetchurl, nixosTests, + systemd, }: stdenv.mkDerivation rec { @@ -28,6 +29,18 @@ stdenv.mkDerivation rec { runHook postInstall ''; + postInstall = + if stdenv.hostPlatform.system == "x86_64-linux" then + '' + patchelf --add-needed "${systemd}/lib/libsystemd.so.0" "$out/lib/native/Linux/x86_64/libubnt_sdnotify_jni.so" + '' + else if stdenv.hostPlatform.system == "aarch64-linux" then + '' + patchelf --add-needed "${systemd}/lib/libsystemd.so.0" "$out/lib/native/Linux/aarch64/libubnt_sdnotify_jni.so" + '' + else + null; + passthru.tests = { unifi = nixosTests.unifi; }; From e5b5cf80c5d78dc7c4921dc4725cddb2c1c3b8b7 Mon Sep 17 00:00:00 2001 From: qubitnano <146656568+qubitnano@users.noreply.github.com> Date: Wed, 4 Dec 2024 00:29:49 -0500 Subject: [PATCH 2/3] nixos/unifi: enable sd_notify Let's use unifi's sd_notify now that it's patched --- nixos/modules/services/networking/unifi.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/unifi.nix b/nixos/modules/services/networking/unifi.nix index 8c5bc82ffcb1..5d302e9502b9 100644 --- a/nixos/modules/services/networking/unifi.nix +++ b/nixos/modules/services/networking/unifi.nix @@ -143,7 +143,7 @@ in restartTriggers = [ cfg.unifiPackage cfg.mongodbPackage ]; serviceConfig = { - Type = "simple"; + Type = "notify"; ExecStart = "${cmd} start"; ExecStop = "${cmd} stop"; Restart = "on-failure"; From 5d10e2bedb74e11d69acafa5823538114c346a2e Mon Sep 17 00:00:00 2001 From: qubitnano <146656568+qubitnano@users.noreply.github.com> Date: Wed, 4 Dec 2024 00:30:16 -0500 Subject: [PATCH 3/3] nixos/unifi: always restart service This allows the controller to restart when restoring from a backup --- nixos/modules/services/networking/unifi.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/unifi.nix b/nixos/modules/services/networking/unifi.nix index 5d302e9502b9..8570d0ee377d 100644 --- a/nixos/modules/services/networking/unifi.nix +++ b/nixos/modules/services/networking/unifi.nix @@ -146,7 +146,7 @@ in Type = "notify"; ExecStart = "${cmd} start"; ExecStop = "${cmd} stop"; - Restart = "on-failure"; + Restart = "always"; TimeoutSec = "5min"; User = "unifi"; UMask = "0077";