diff --git a/nixos/modules/services/networking/unifi.nix b/nixos/modules/services/networking/unifi.nix index 8c5bc82ffcb1a..8570d0ee377d9 100644 --- a/nixos/modules/services/networking/unifi.nix +++ b/nixos/modules/services/networking/unifi.nix @@ -143,10 +143,10 @@ in restartTriggers = [ cfg.unifiPackage cfg.mongodbPackage ]; serviceConfig = { - Type = "simple"; + Type = "notify"; ExecStart = "${cmd} start"; ExecStop = "${cmd} stop"; - Restart = "on-failure"; + Restart = "always"; TimeoutSec = "5min"; User = "unifi"; UMask = "0077"; diff --git a/pkgs/by-name/un/unifi/package.nix b/pkgs/by-name/un/unifi/package.nix index 6af57d380923a..85c1ee1d71920 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; };