I've been on the fediverse on and off since [friendi.ca](https://friendi.ca/) started to be a thing.
I remember hosting an instance at ponk.pink that suddenly got popular and the server melted away while I was apologising to the users.
I can see someone bought the domain to host some psychedelic My Little Pony stuff, I'm all for that.
I moved to [todon.nl](https://todon.nl/) when it got started and was quite happy there - check it out if you're looking for an instance !
The itch was there though, what if I host my own small cozy place on the fediverse myself.
I knew I didn't have as much time to do server admin, so I decided to start small, with a single user instance an use the power of NixOS to help with maintenance.
Here is my full config - hosting Mastodon under the apex domain of [peninsula.industries](https://peninsula.industries/), Mastodon is running inside a systemd container and the config is using nix-sops to store the secrets.
Few things that were unexpected/of note
- I needed to create the folder structure with correct permissions so that Mastodon starts normally.
- I'm decrypting secrets on the host and making them available read-only to the container. Not sure if this is better or worse than having sops inside of the container, but I was having some trouble using sops module from there, so left it as it is for now - something to look into in the future
- I needed to change the postgres port that is running inside of the Mastodon container because I had another postgres on this host already.
- If you're gonna be playing with this a lot, you might need to remove the container and its data and start from scratch - you can do so by doing:
- remove the container definition and `nixos-rebuild switch`
- rm -fr /var/lib/nixos-containers/mastodon/ *
- to use Mastodon CLI you need to be running it as a correct user and within the Nix-changed env:
```bash
nixos-container root-login mastodon
sudo -u mastodon bash
cd
source mastodon-env
RAILS_ENV=production tootctl
```
- The below can use some refactoring, there is some weird repetition in some places still
- You can find the newest version of this and see how it's being used in context on my [code hosting site](https://git.cyplo.dev/cyplo/dotfiles/src/branch/main/nixos/boxes/vpsfree1/mastodon.nix).