Configuring mimetype in Nextcloud

According to the Nextcloud documentation:

Mimetype mapping

Nextcloud allows administrators to specify the mapping of a file extension to a mimetype. For example files ending in mp3 map to audio/mpeg. Which then in turn allows Nextcloud to show the audio icon.

By default Nextcloud comes with mimetypemapping.dist.json. This is a simple json array. Administrators should not update this file as it will get replaced on upgrades of Nextcloud. Instead the file mimetypemapping.json should be created and modified, this file has precedence over the shipped file.

I would like to add my own mimetype. For the moment I have done it manually on NixOS as follow

  • by creating the file /data/nextcloud/mimetypemapping.json manually (copied from mimetypemapping.dist.json)
  • and then running nextcloud-occ maintenance:mimetype:update-js
  • and nextcloud-occ maintenance:mimetype:update-db --repair-filecache (this is not documented at the right place in the nextcloud doc but is necessary).

Now I would like to do all these steps but with Nix. How can I?