anchor.diff:            environment = {
               # NixOS specific option to avoid that it's trying to write into its store-path.
               # See also https://github.com/lau/tzdata#data-directory-and-releases
  -            TZDATA_DIR = "/var/lib/plausible/elixir_tzdata";
  +            STORAGE_DIR = "/var/lib/plausible/elixir_tzdata";
   
               # Configuration options from
               # https://plausible.io/docs/self-hosting-configuration
  
positive.code:       enable = true;
      };
  
      systemd.services = mkMerge [
        {
          plausible = {
            inherit (pkgs.plausible.meta) description;
            documentation = [ "https://plausible.io/docs/self-hosting" ];
            wantedBy = [ "multi-user.target" ];
            after = optional cfg.database.postgres.setup "plausible-postgres.service";
            requires = optional cfg.database.clickhouse.setup "clickhouse.service"
              ++ optionals cfg.database.postgres.setup [
                "postgresql.service"
  
negative.code:         # `plausible' requires the `citext'-extension.
          plausible-postgres = {
            after = [ "postgresql.service" ];
            partOf = [ "plausible.service" ];
            serviceConfig = {
              Type = "oneshot";
              User = config.services.postgresql.superUser;
              RemainAfterExit = true;
            };
            script = with cfg.database.postgres; ''
              PSQL() {
                ${config.services.postgresql.package}/bin/psql --port=5432 "$@"
              }
              # check if the database already exists
              if ! PSQL -lqt | ${pkgs.coreutils}/bin/cut -d \| -f 1 | ${pkgs.gnugrep}/bin/grep -qw ${dbname} ; then
                PSQL -tAc "CREATE ROLE plausible WITH LOGIN;"
                PSQL -tAc "CREATE DATABASE ${dbname} WITH OWNER plausible;"
                PSQL -d ${dbname} -tAc "CREATE EXTENSION IF NOT EXISTS citext;"
              fi
            '';
          };
        })
  