Long posts in Mastodon, but now declarative !

So much to say on the Fediverse and so little characters of text per post ! Well, at least on Mastodon. But fear not - someone smarter than me figured out what files to patch to increase the limit.

As I am increasingly lazy, I dreaded the change as it would mean I would need to reapply the patch whenever I redeploy the server, which is more often than I want to admit.

Nix to the rescue !

{ pkgs, inputs, ... }:
let
  mastodonCharacterLimit = 5000;
  mastodonBase = inputs.nixpkgs-nixos-unstable.legacyPackages.${pkgs.system}.mastodon;
  package = mastodonBase.overrideAttrs (old: {
    postPatch = (old.postPatch or "") + ''
      substituteInPlace app/javascript/mastodon/features/compose/containers/compose_form_container.js \
        --replace-fail "max_characters'], 500)" "max_characters'], ${toString mastodonCharacterLimit})"

      substituteInPlace app/validators/status_length_validator.rb \
        --replace-fail "MAX_CHARS = 500" "MAX_CHARS = ${toString mastodonCharacterLimit}"
    '';
  });
in
{
  services.mastodon = {
    enable = true;
    inherit package;
  };
}

And that is all ! Doctor Doom toots as he pleases ! See you on the fedi - ping me at @cyplo@peninsula.industries !