anchor.diff:  let
     cfg = config.services.roundcube;
     fpm = config.services.phpfpm.pools.roundcube;
  +  localDB = cfg.database.host == "localhost";
  +  user = cfg.database.username;
   in
   {
     options.services.roundcube = {
  
positive.code:   };
  
    config = mkIf cfg.enable {
      environment.etc."roundcube/config.inc.php".text = ''
        <?php
  
        $config = array();
        $config['db_dsnw'] = 'pgsql://${cfg.database.username}:${cfg.database.password}@${cfg.database.host}/${cfg.database.dbname}';
        $config['log_driver'] = 'syslog';
        $config['max_message_size'] = '25M';
        $config['plugins'] = [${concatMapStringsSep "," (p: "'${p}'") cfg.plugins}];
  
negative.code:       })
        {
          wantedBy = [ "multi-user.target" ];
          script = let
            psql = "${lib.optionalString (!localDB) "PGPASSFILE=${cfg.database.passwordFile}"} ${pkgs.postgresql}/bin/psql ${lib.optionalString (!localDB) "-h ${cfg.database.host} -U ${cfg.database.username} "} ${cfg.database.dbname}";
          in
          ''
            version="$(${psql} -t <<< "select value from system where name = 'roundcube-version';" || true)"
            if ! (grep -E '[a-zA-Z0-9]' <<< "$version"); then
              ${psql} -f ${cfg.package}/SQL/postgres.initial.sql
            fi
  
            ${pkgs.php}/bin/php ${cfg.package}/bin/update.sh
          '';
          serviceConfig = {
            Type = "oneshot";
            StateDirectory = "roundcube";
            User = if localDB then user else "nginx";
          };
        }
      ];
    };
  