Has anyone ran Mastodon on NixOS?

Did anyone managed to host a mastodon instance on NixOS ?


People have tried, but I don’t know of anybody who’s managed.


Well, there was some effort to provide a NixOS module for that task, but
without success yet.

Forgot the link: Mastodon · Issue #24600 · NixOS/nixpkgs · GitHub

Thanks for the issue link, it’s a shame the user who tried to port it disappeared.

I just want to throw out there that you could use something like docker to run a mastodon instance. It’s not as good as having a nix package but it’d work. I’m honestly still using CoreOS/Docker on my server since I haven’t quite gotten a good grasp on nix expressions, and I’m still getting a feel for the nix community.

I’m not sure why the nix package the person on that github issue wrote stopped working. I use ruby and nodejs for my work, and I’ve gotten my critical packages to build with nix expressions without too much pain. I’d love to offer to help with this issue of running a mastodon instance, but I don’t really have the time for it right now, I want to say that I think it’d be great if it was in Nix though.

It’s possible that you mentioned my approach on mastodon. I don’t think
it is hard in general, but at that time both Nixpkgs and Mastodon moved
to fast for me, so I got eventually frustrated with catching up. Also
I’m don’t have much knowledge about webapps yet.

I just rebased my approach to current Nixpkgs master and managed to
build it: GitHub - erictapen/nixpkgs at mastodon
This is not functional in any way.

Next step could be to bump Mastodon to a recent version. I also have no
time at the moment, but maybe somebody else can take some useful hints


I would also be really interested in a “works-out-of-the-box-on-nixos”
service/module as I’m planning to move all my stuff to a bare-metal
server or VPS mid-2019 - and a mastodon instance for myself would be

(because I was on mastodon.fun and had ~1400 toots and then it
suddenly vanished :’-((( )

Have fun:

Sample configuration:

  services.mastodon = {
    enable = true;
    localDomain = "social.pbb.lc";
    smtpServer = "mail.pbb.lc";
    smtpFromAddress = "notifications@pbb.lc";
    vapidPublicKey = "BJHy26DZSzPBB1zQTdX_bEKCvXeRL9uIjKOuFvQun_VPYUIwEJLIDe2t5cqU_wTOBBfAAZLQZoklO0t_7Dl4VcY=";
    dbUser = "mastodon";
    smtpLogin = "mastodon@pbb.lc";
    secretKeyBaseFile = "/etc/nixos/secrets/mastodon/secretKeyBase";
    otpSecretFile = "/etc/nixos/secrets/mastodon/otpSecret";
    vapidPrivateKeyFile = "/etc/nixos/secrets/mastodon/vapidPrivateKey";
    dbPassFile = "/etc/nixos/secrets/mastodon/dbPass";
    smtpPasswordFile = "/etc/nixos/secrets/mastodon/smtpPassword";

  services.nginx.virtualHosts."social.pbb.lc" = {
    enableACME = true;
    forceSSL = true;

awesome, thank you. What about redis, do I need an instance of it?

Yes, services.redis.enable = true; should be sufficient, localhost is used by default in the mastodon module.

1 Like

Similar, but different.

I’ve had great success with the pleroma module running on a digital ocean VPS