X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=virtual%2Fmodules%2Fwebsites%2Ftools%2Fmastodon%2Fdefault.nix;h=f1a207feb97554d305ca2d8e7fc2871705a3955d;hb=6f4574e7b57043340a2a520c4bbeb17dde72e0ea;hp=1549ca95f0ac8350908b324b6974b47bda54347a;hpb=35a397cd22e6c8dd7dec471f09416441b64deee4;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/virtual/modules/websites/tools/mastodon/default.nix b/virtual/modules/websites/tools/mastodon/default.nix index 1549ca9..f1a207f 100644 --- a/virtual/modules/websites/tools/mastodon/default.nix +++ b/virtual/modules/websites/tools/mastodon/default.nix @@ -1,7 +1,8 @@ -{ 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; @@ -11,8 +12,6 @@ in { }; 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; @@ -21,7 +20,7 @@ in { uid = config.ids.uids.mastodon; group = "mastodon"; description = "Mastodon user"; - home = "${mastodon.railsRoot}"; + home = mastodon.railsRoot; useDefaultShell = true; }; @@ -71,16 +70,18 @@ in { 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 = { @@ -88,7 +89,7 @@ in { EnvironmentFile = mastodon.config; PrivateTmp = true; Restart = "always"; - TimeoutSec = 15; + TimeoutSec = 60; Type = "simple"; WorkingDirectory = mastodon.railsRoot; }; @@ -102,12 +103,14 @@ in { 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 = { @@ -123,18 +126,16 @@ in { 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;