-{ lib, pkgs, config, mylibs, ... }:
+{ lib, pkgs, config, myconfig, mylibs, ... }:
let
mastodon = pkgs.callPackage ./mastodon.nix {
- inherit (mylibs) fetchedGithub checkEnv;
+ inherit (mylibs) fetchedGithub;
+ env = myconfig.env.tools.mastodon;
};
cfg = config.services.myWebsites.tools.mastodon;
};
config = lib.mkIf cfg.enable {
- # FIXME: Can we use dynamic users from systemd?
- # nixos/modules/misc/ids.nix
ids.uids.mastodon = 399;
ids.gids.mastodon = 399;
uid = config.ids.uids.mastodon;
group = "mastodon";
description = "Mastodon user";
- home = "${mastodon.railsRoot}";
+ home = mastodon.railsRoot;
useDefaultShell = true;
};
after = [ "network.target" ];
environment.RAILS_ENV = "production";
+ environment.BUNDLE_PATH = "${mastodon.gems}/lib/ruby/gems/2.5.0";
+ environment.BUNDLE_GEMFILE = "${mastodon.gems.confFiles}/Gemfile";
environment.SOCKET = mastodon.railsSocket;
- path = [ pkgs.bundler ];
+ path = [ mastodon.gems mastodon.gems.ruby pkgs.file ];
preStart = ''
- bundle exec rails db:migrate
+ ./bin/bundle exec rails db:migrate
'';
script = ''
- exec bundle exec puma -C config/puma.rb
+ exec ./bin/bundle exec puma -C config/puma.rb
'';
serviceConfig = {
EnvironmentFile = mastodon.config;
PrivateTmp = true;
Restart = "always";
- TimeoutSec = 15;
+ TimeoutSec = 60;
Type = "simple";
WorkingDirectory = mastodon.railsRoot;
};
after = [ "network.target" "mastodon-web.service" ];
environment.RAILS_ENV="production";
+ environment.BUNDLE_PATH = "${mastodon.gems}/${mastodon.gems.ruby.gemPath}";
+ environment.BUNDLE_GEMFILE = "${mastodon.gems.confFiles}/Gemfile";
environment.DB_POOL="5";
- path = [ pkgs.bundler ];
+ path = [ mastodon.gems mastodon.gems.ruby pkgs.imagemagick pkgs.ffmpeg pkgs.file ];
script = ''
- exec bundle exec sidekiq -c 5 -q default -q mailers -q pull -q push
+ exec ./bin/bundle exec sidekiq -c 5 -q default -q mailers -q pull -q push
'';
serviceConfig = {
unitConfig.RequiresMountsFor = mastodon.varDir;
};
- # FIXME: initial sync
system.activationScripts.mastodon = {
deps = [ "users" ];
text = ''
install -m 0755 -o mastodon -g mastodon -d ${mastodon.socketsDir}
- install -m 0755 -o mastodon -g mastodon -d ${mastodon.varDir}
+ install -m 0755 -o mastodon -g mastodon -d ${mastodon.varDir} ${mastodon.varDir}/tmp/cache
'';
};
services.myWebsites.tools.modules = [
"headers" "proxy" "proxy_wstunnel" "proxy_http" "proxy_balancer"
- # FIXME: probably only one balancer method is needed:
"lbmethod_byrequests" "lbmethod_bytraffic" "lbmethod_bybusyness" "lbmethod_heartbeat"
];
security.acme.certs."eldiron".extraDomains."mastodon.immae.eu" = null;