anchor.diff:          preStart = ''
             mkdir -p ${cfg.statePath}/{data,config,logs}
             ln -sf ${cfg.package}/{bin,fonts,i18n,templates,client} ${cfg.statePath}
  +        '' + lib.optionalString (mattermostPlugins != null) ''
  +          mkdir -p ${cfg.statePath}/plugins/{client,server}
  +          rm -rf "${cfg.statePath}/data/plugins"
  +          ln -sf ${mattermostPlugins}/data/plugins ${cfg.statePath}/data
           '' + lib.optionalString (!cfg.mutableConfig) ''
             rm -f ${cfg.statePath}/config/config.json
             ${pkgs.jq}/bin/jq -s '.[0] * .[1]' ${cfg.package}/config/config.json ${mattermostConfJSON} > ${cfg.statePath}/config/config.json
  
positive.code:         PluginSettings = {
            Enable = true;
            EnableUploads = false;
            Directory = "${mattermostPlugins}/server";
            ClientDirectory = "${mattermostPlugins}/client";
          };
        }
      );
  
negative.code:     localDatabaseName ? cfg.localDatabaseName,
      useSudo ? true
    }: ''
      if ! test -e ${escapeShellArg "${statePath}/.db-created"}; then
        ${lib.optionalString useSudo "${pkgs.sudo}/bin/sudo -u ${escapeShellArg config.services.postgresql.superUser} \\"}
          ${postgresPackage}/bin/psql postgres -c \
            "CREATE ROLE ${localDatabaseUser} WITH LOGIN NOCREATEDB NOCREATEROLE ENCRYPTED PASSWORD '${localDatabasePassword}'"
        ${lib.optionalString useSudo "${pkgs.sudo}/bin/sudo -u ${escapeShellArg config.services.postgresql.superUser} \\"}
          ${postgresPackage}/bin/createdb \
            --owner ${escapeShellArg localDatabaseUser} ${escapeShellArg localDatabaseName}
        touch ${escapeShellArg "${statePath}/.db-created"}
      fi
    '';
  
  