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