@@ -143,6 +143,11 @@ stdenv.mkDerivation {
143143 -${optionalString (buildTests == false) "no"}make tests
144144 '';
145145
146+ # PostgreSQL autodetection fails sporadically because Qt omits the "-lpq" flag
147+ # if dependency paths contain the string "pq", which can occur in the hash.
148+ # To prevent these failures, we need to override PostgreSQL detection.
149+ PSQL_LIBS = optionalString (postgresql != null) "-L${postgresql}/lib -lpq";
150+
146151 propagatedBuildInputs = [
147152 xlibs.libXcomposite libX11 libxcb libXext libXrender libXi
148153 fontconfig freetype openssl dbus.libs glib udev libxml2 libxslt pcre