]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/tools/diaspora/default.nix
Move backups to flake
[perso/Immae/Config/Nix.git] / modules / private / websites / tools / diaspora / default.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
a7f7fdae 2let
ab8f306d 3 env = config.myEnv.tools.diaspora;
a95ab089 4 root = "/run/current-system/webapps/tools_diaspora";
4288c2f2 5 cfg = config.myServices.websites.tools.diaspora;
7009832a 6 dcfg = config.services.diaspora;
a7f7fdae 7in {
4288c2f2 8 options.myServices.websites.tools.diaspora = {
a7f7fdae
IB
9 enable = lib.mkEnableOption "enable diaspora's website";
10 };
11
12 config = lib.mkIf cfg.enable {
d2e703c5 13 services.duplyBackup.profiles.diaspora = {
6a8252b1 14 rootDir = dcfg.dataDir;
546864bc 15 remotes = [ "eriomem" "ovh" ];
6a8252b1 16 };
7009832a 17 users.users.diaspora.extraGroups = [ "keys" ];
a7f7fdae 18
1a718805 19 secrets.keys = [
3bb8a82a
IB
20 {
21 dest = "webapps/diaspora/diaspora.yml";
22 user = "diaspora";
23 group = "diaspora";
24 permissions = "0400";
25 text = ''
26 configuration:
27 environment:
28 url: "https://diaspora.immae.eu/"
29 certificate_authorities: '${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt'
ab8f306d 30 redis: 'redis://${env.redis.host}:${env.redis.port}/${env.redis.db}'
3bb8a82a
IB
31 sidekiq:
32 s3:
33 assets:
34 logging:
35 logrotate:
36 debug:
37 server:
7009832a 38 listen: '${dcfg.sockets.rails}'
3bb8a82a
IB
39 rails_environment: 'production'
40 chat:
41 server:
42 bosh:
43 log:
44 map:
45 mapbox:
46 privacy:
47 piwik:
48 statistics:
49 camo:
50 settings:
51 enable_registrations: false
52 welcome_message:
53 invitations:
54 open: false
55 paypal_donations:
56 community_spotlight:
57 captcha:
58 enable: false
59 terms:
60 maintenance:
61 remove_old_users:
62 default_metas:
63 csp:
64 services:
65 twitter:
66 tumblr:
67 wordpress:
68 mail:
69 enable: true
70 sender_address: 'diaspora@tools.immae.eu'
71 method: 'sendmail'
72 smtp:
73 sendmail:
74 location: '/run/wrappers/bin/sendmail'
75 admins:
76 account: "ismael"
77 podmin_email: 'diaspora@tools.immae.eu'
78 relay:
79 outbound:
80 inbound:
81 ldap:
82 enable: true
ab8f306d 83 host: ${env.ldap.host}
3bb8a82a
IB
84 port: 636
85 only_ldap: true
86 mail_attribute: mail
87 skip_email_confirmation: true
88 use_bind_dn: true
ab8f306d 89 bind_dn: "${env.ldap.dn}"
3bb8a82a 90 bind_pw: "${env.ldap.password}"
ab8f306d
IB
91 search_base: "${env.ldap.base}"
92 search_filter: "${env.ldap.filter}"
3bb8a82a
IB
93 production:
94 environment:
95 development:
96 environment:
97 '';
98 }
99 {
100 dest = "webapps/diaspora/database.yml";
101 user = "diaspora";
102 group = "diaspora";
103 permissions = "0400";
104 text = ''
105 postgresql: &postgresql
106 adapter: postgresql
107 host: "${env.postgresql.socket}"
108 port: "${env.postgresql.port}"
109 username: "${env.postgresql.user}"
110 password: "${env.postgresql.password}"
111 encoding: unicode
112 common: &common
113 <<: *postgresql
114 combined: &combined
115 <<: *common
116 development:
117 <<: *combined
118 database: diaspora_development
119 production:
120 <<: *combined
121 database: ${env.postgresql.database}
122 test:
123 <<: *combined
124 database: "diaspora_test"
125 integration1:
126 <<: *combined
127 database: diaspora_integration1
128 integration2:
129 <<: *combined
130 database: diaspora_integration2
131 '';
132 }
133 {
134 dest = "webapps/diaspora/secret_token.rb";
135 user = "diaspora";
136 group = "diaspora";
137 permissions = "0400";
138 text = ''
139 Diaspora::Application.config.secret_key_base = '${env.secret_token}'
140 '';
141 }
142 ];
a7f7fdae 143
7009832a
IB
144 services.diaspora = {
145 enable = true;
146 package = pkgs.webapps.diaspora.override { ldap = true; };
147 dataDir = "/var/lib/diaspora_immae";
148 adminEmail = "diaspora@tools.immae.eu";
149 configDir = "/var/secrets/webapps/diaspora";
a7f7fdae
IB
150 };
151
17f6eae9
IB
152 services.filesWatcher.diaspora = {
153 restart = true;
154 paths = [ dcfg.configDir ];
155 };
156
29f8cb85 157 services.websites.env.tools.modules = [
a952acc4 158 "headers" "proxy" "proxy_http"
a7f7fdae 159 ];
a95ab089
IB
160 system.extraSystemBuilderCmds = ''
161 mkdir -p $out/webapps
7009832a 162 ln -s ${dcfg.workdir}/public/ $out/webapps/tools_diaspora
a95ab089 163 '';
29f8cb85 164 services.websites.env.tools.vhostConfs.diaspora = {
a7f7fdae 165 certName = "eldiron";
7df420c2 166 addToCerts = true;
a7f7fdae 167 hosts = [ "diaspora.immae.eu" ];
a95ab089 168 root = root;
a7f7fdae
IB
169 extraConfig = [ ''
170 RewriteEngine On
171 RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
7009832a 172 RewriteRule ^/(.*)$ unix://${dcfg.sockets.rails}|http://diaspora.immae.eu/%{REQUEST_URI} [P,NE,QSA,L]
a7f7fdae
IB
173
174 ProxyRequests Off
175 ProxyVia On
176 ProxyPreserveHost On
177 RequestHeader set X_FORWARDED_PROTO https
178
179 <Proxy *>
180 Require all granted
181 </Proxy>
182
a95ab089 183 <Directory ${root}>
a7f7fdae
IB
184 Require all granted
185 Options -MultiViews
186 </Directory>
187 '' ];
188 };
189 };
190}