]>
Commit | Line | Data |
---|---|---|
2ff7e086 | 1 | { env, ruby_2_5, bundlerEnv, defaultGemConfig, fetchedGithub, stdenv, writeText, pkgs, cacert }: |
35a397cd IB |
2 | let |
3 | varDir = "/var/lib/mastodon_immae"; | |
4 | socketsDir = "/run/mastodon"; | |
2ff7e086 IB |
5 | gems = bundlerEnv { |
6 | name = "mastodon-env"; | |
7 | ruby = ruby_2_5; | |
8 | gemset = ./gemset.nix; | |
9 | gemdir = (fetchedGithub ./mastodon.json).src; | |
10 | groups = [ "default" "production" "test" "development" ]; | |
11 | gemConfig = defaultGemConfig // { | |
12 | cld3 = attrs: { | |
13 | buildInputs = with pkgs; [ protobuf protobufc pkgconfig ]; | |
14 | }; | |
15 | idn-ruby = attrs: { | |
16 | buildInputs = with pkgs; [ libidn ]; | |
17 | }; | |
18 | rpam2 = attrs: { | |
19 | buildInputs = with pkgs; [ pam ]; | |
20 | }; | |
21 | }; | |
22 | }; | |
35a397cd | 23 | mastodon = stdenv.mkDerivation (fetchedGithub ./mastodon.json // rec { |
2ff7e086 | 24 | __noChroot = true; |
35a397cd | 25 | buildPhase = '' |
35a397cd | 26 | yarn install --pure-lockfile |
2ff7e086 | 27 | patchShebangs node_modules |
35a397cd IB |
28 | ''; |
29 | installPhase = '' | |
30 | cp -a . $out | |
31 | ''; | |
2ff7e086 | 32 | propagatedBuildInputs = [ gems pkgs.yarn pkgs.python2 pkgs.nodejs ]; |
35a397cd | 33 | }); |
9d90e7e2 | 34 | config = writeText "mastodon_environment" '' |
35a397cd IB |
35 | REDIS_HOST=localhost |
36 | REDIS_PORT=6379 | |
37 | REDIS_DB=13 | |
38 | DB_HOST=/run/postgresql | |
39 | DB_USER=mastodon | |
40 | DB_NAME=mastodon | |
9d90e7e2 | 41 | DB_PASS=${env.postgresql.password} |
35a397cd IB |
42 | DB_PORT=5432 |
43 | ||
44 | LOCAL_DOMAIN=mastodon.immae.eu | |
45 | LOCAL_HTTPS=true | |
46 | ALTERNATE_DOMAINS=immae.eu | |
47 | ||
9d90e7e2 IB |
48 | PAPERCLIP_SECRET=${env.paperclip_secret} |
49 | SECRET_KEY_BASE=${env.secret_key_base} | |
50 | OTP_SECRET=${env.otp_secret} | |
35a397cd | 51 | |
9d90e7e2 IB |
52 | VAPID_PRIVATE_KEY=${env.vapid.private} |
53 | VAPID_PUBLIC_KEY=${env.vapid.public} | |
35a397cd IB |
54 | |
55 | SMTP_SERVER=mail.immae.eu | |
56 | SMTP_PORT=587 | |
57 | SMTP_FROM_ADDRESS=notifications@mastodon.immae.eu | |
58 | SMTP_DELIVERY_METHOD=smtp | |
59 | PAPERCLIP_ROOT_PATH=${varDir} | |
60 | ||
61 | STREAMING_CLUSTER_NUM=1 | |
62 | ||
63 | # LDAP authentication (optional) | |
64 | LDAP_ENABLED=true | |
65 | LDAP_HOST=ldap.immae.eu | |
66 | LDAP_PORT=636 | |
67 | LDAP_METHOD=simple_tls | |
68 | LDAP_BASE="dc=immae,dc=eu" | |
69 | LDAP_BIND_DN="cn=mastodon,ou=services,dc=immae,dc=eu" | |
9d90e7e2 | 70 | LDAP_PASSWORD="${env.ldap.password}" |
35a397cd IB |
71 | LDAP_UID="uid" |
72 | LDAP_SEARCH_FILTER="(&(%{uid}=%{email})(memberOf=cn=users,cn=mastodon,ou=services,dc=immae,dc=eu))" | |
73 | ''; | |
74 | ||
75 | railsRoot = stdenv.mkDerivation { | |
76 | name = "mastodon_immae"; | |
77 | inherit config mastodon; | |
78 | builder = writeText "build_mastodon_immae" '' | |
79 | source $stdenv/setup | |
80 | set -a | |
81 | source $config | |
82 | set +a | |
83 | cp -a $mastodon $out | |
84 | cd $out | |
85 | chmod u+rwX . node_modules public | |
2ff7e086 IB |
86 | RAILS_ENV=production ${gems}/bin/rails assets:precompile |
87 | rm -rf tmp/cache | |
88 | ln -sf ../../../../../../../${varDir}/tmp/cache tmp | |
35a397cd | 89 | ''; |
2ff7e086 | 90 | buildInputs = [ gems pkgs.nodejs pkgs.yarn ]; |
35a397cd IB |
91 | }; |
92 | in | |
93 | { | |
2ff7e086 | 94 | inherit railsRoot config varDir socketsDir gems; |
35a397cd IB |
95 | nodeSocket = "${socketsDir}/live_immae_node.sock"; |
96 | railsSocket = "${socketsDir}/live_immae_puma.sock"; | |
97 | } |