You have a couple of options
-
systemd.services.unifi.wantedBy = mkForce [];should do the trick - allocate less memory
services.unifi.maximumJavaHeapSize = 256; - run it in a container with
autoStart = false;
The unifi controller will easily run with less memory allocated so that can be done no matter what.
I use postgres and mariadb (mariadb far less) togther with redis so those are running in containers. This also allows multiple different versions which is very convenient.