anchor.diff:  
   let
     cfg = config.services.matrix-synapse;
  +  pg = config.services.postgresql;
  +  usePostgresql = cfg.database_type == "psycopg2";
     logConfigFile = pkgs.writeText "log_config.yaml" cfg.logConfig;
     mkResource = r: ''{names: ${builtins.toJSON r.names}, compress: ${boolToString r.compress}}'';
     mkListener = l: ''{port: ${toString l.port}, bind_address: "${l.bind_address}", type: ${l.type}, tls: ${boolToString l.tls}, x_forwarded: ${boolToString l.x_forwarded}, resources: [${concatStringsSep "," (map mkResource l.resources)}]}'';
  
positive.code:   name: "${cfg.database_type}",
    args: {
      ${concatStringsSep ",\n    " (
        mapAttrsToList (n: v: "\"${n}\": ${v}") cfg.database_args
      )}
    }
  }
  
negative.code:           The database engine name. Can be sqlite or psycopg2.
          '';
        };
        create_local_database = mkOption {
          type = types.bool;
          default = true;
          description = ''
            Whether to create a local database automatically.
          '';
        };
        database_name = mkOption {
          type = types.str;
          default = "matrix-synapse";
          description = "Database name.";
        };
        database_user = mkOption {
          type = types.str;
          default = "matrix-synapse";
          description = "Database user name.";
        };
        database_args = mkOption {
          type = types.attrs;
          default = {
            sqlite3 = { database = "${cfg.dataDir}/homeserver.db"; };
            psycopg2 = {
              user = cfg.database_user;
              database = cfg.database_name;
            };
          }."${cfg.database_type}";
          description = ''
            Arguments to pass to the engine.
          '';
  