]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - virtual/modules/websites/tools/mastodon/mastodon.nix
Remove unused dependencies for diaspora
[perso/Immae/Config/Nix.git] / virtual / modules / websites / tools / mastodon / mastodon.nix
CommitLineData
9d90e7e2 1{ env, fetchedGithub, stdenv, writeText, pkgs, cacert }:
35a397cd
IB
2let
3 varDir = "/var/lib/mastodon_immae";
4 socketsDir = "/run/mastodon";
5 mastodon = stdenv.mkDerivation (fetchedGithub ./mastodon.json // rec {
6 buildPhase = ''
7 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
8 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
9
10 bundle install --deployment --without development test
11 yarn install --pure-lockfile
12 '';
13 installPhase = ''
14 cp -a . $out
15 '';
16 propagatedBuildInputs = with pkgs; [
17 zlib icu libchardet git bundler yarn
18 protobuf protobufc libidn libpqxx nodejs
19 imagemagick ffmpeg libxml2 libxslt pkgconfig
20 autoconf bison libyaml readline ncurses libffi gdbm
21 jemalloc which postgresql python3 cacert
22 ];
23 });
9d90e7e2 24 config = writeText "mastodon_environment" ''
35a397cd
IB
25 REDIS_HOST=localhost
26 REDIS_PORT=6379
27 REDIS_DB=13
28 DB_HOST=/run/postgresql
29 DB_USER=mastodon
30 DB_NAME=mastodon
9d90e7e2 31 DB_PASS=${env.postgresql.password}
35a397cd
IB
32 DB_PORT=5432
33
34 LOCAL_DOMAIN=mastodon.immae.eu
35 LOCAL_HTTPS=true
36 ALTERNATE_DOMAINS=immae.eu
37
9d90e7e2
IB
38 PAPERCLIP_SECRET=${env.paperclip_secret}
39 SECRET_KEY_BASE=${env.secret_key_base}
40 OTP_SECRET=${env.otp_secret}
35a397cd 41
9d90e7e2
IB
42 VAPID_PRIVATE_KEY=${env.vapid.private}
43 VAPID_PUBLIC_KEY=${env.vapid.public}
35a397cd
IB
44
45 SMTP_SERVER=mail.immae.eu
46 SMTP_PORT=587
47 SMTP_FROM_ADDRESS=notifications@mastodon.immae.eu
48 SMTP_DELIVERY_METHOD=smtp
49 PAPERCLIP_ROOT_PATH=${varDir}
50
51 STREAMING_CLUSTER_NUM=1
52
53 # LDAP authentication (optional)
54 LDAP_ENABLED=true
55 LDAP_HOST=ldap.immae.eu
56 LDAP_PORT=636
57 LDAP_METHOD=simple_tls
58 LDAP_BASE="dc=immae,dc=eu"
59 LDAP_BIND_DN="cn=mastodon,ou=services,dc=immae,dc=eu"
9d90e7e2 60 LDAP_PASSWORD="${env.ldap.password}"
35a397cd
IB
61 LDAP_UID="uid"
62 LDAP_SEARCH_FILTER="(&(%{uid}=%{email})(memberOf=cn=users,cn=mastodon,ou=services,dc=immae,dc=eu))"
63 '';
64
65 railsRoot = stdenv.mkDerivation {
66 name = "mastodon_immae";
67 inherit config mastodon;
68 builder = writeText "build_mastodon_immae" ''
69 source $stdenv/setup
70 set -a
71 source $config
72 set +a
73 cp -a $mastodon $out
74 cd $out
75 chmod u+rwX . node_modules public
76 RAILS_ENV=production bundle exec rails assets:precompile
77 '';
78 propagatedBuildInputs = with pkgs; [
79 zlib icu libchardet git bundler yarn
80 protobuf protobufc libidn libpqxx nodejs
81 imagemagick ffmpeg libxml2 libxslt pkgconfig
82 autoconf bison libyaml readline ncurses libffi gdbm
83 jemalloc which postgresql python3 cacert
84 ];
85 };
86in
87 {
88 inherit railsRoot config varDir socketsDir;
89 nodeSocket = "${socketsDir}/live_immae_node.sock";
90 railsSocket = "${socketsDir}/live_immae_puma.sock";
91 }