]>
Commit | Line | Data |
---|---|---|
a1bb33c4 IB |
1 | { |
2 | network = { | |
3 | description = "Immae's network"; | |
4 | enableRollback = true; | |
5 | }; | |
6 | ||
ab5d04b8 | 7 | eldiron = { config, pkgs, ... }: |
5c101474 IB |
8 | with import ../libs.nix; |
9 | let | |
712ccefd | 10 | mypkgs = pkgs.callPackage ./packages.nix { |
5c101474 | 11 | inherit checkEnv fetchedGitPrivate fetchedGithub; |
5c101474 | 12 | }; |
ab5d04b8 IB |
13 | in |
14 | { | |
91493dc0 | 15 | nixpkgs.config.packageOverrides = oldpkgs: rec { |
c5aaa64a IB |
16 | gitolite = oldpkgs.gitolite.overrideAttrs(old: rec { |
17 | name = "gitolite-${version}"; | |
18 | version = "3.6.10"; | |
19 | src = pkgs.fetchFromGitHub { | |
20 | owner = "sitaramc"; | |
21 | repo = "gitolite"; | |
22 | rev = "v${version}"; | |
23 | sha256 = "0p2697mn6rwm03ndlv7q137zczai82n41aplq1g006ii7f12xy8h"; | |
24 | }; | |
25 | }); | |
712ccefd IB |
26 | gitweb = oldpkgs.gitweb.overrideAttrs(old: { |
27 | installPhase = old.installPhase + '' | |
28 | cp -r ${./packages/gitweb} $out/gitweb-theme; | |
29 | ''; | |
30 | }); | |
91493dc0 IB |
31 | postgresql = postgresql111; |
32 | postgresql111 = oldpkgs.postgresql100.overrideAttrs(old: rec { | |
33 | passthru = old.passthru // { psqlSchema = "11.0"; }; | |
34 | name = "postgresql-11.1"; | |
35 | src = pkgs.fetchurl { | |
36 | url = "mirror://postgresql/source/v11.1/${name}.tar.bz2"; | |
37 | sha256 = "026v0sicsh7avzi45waf8shcbhivyxmi7qgn9fd1x0vl520mx0ch"; | |
38 | }; | |
39 | }); | |
40 | mariadb = mariadbPAM; | |
41 | mariadbPAM = oldpkgs.mariadb.overrideAttrs(old: rec { | |
42 | cmakeFlags = old.cmakeFlags ++ [ "-DWITH_AUTHENTICATION_PAM=ON" ]; | |
43 | buildInputs = old.buildInputs ++ [ pkgs.pam ]; | |
44 | }); | |
6f0d92b4 IB |
45 | goaccess = oldpkgs.goaccess.overrideAttrs(old: rec { |
46 | name = "goaccess-${version}"; | |
47 | version = "1.3"; | |
48 | src = pkgs.fetchurl { | |
49 | url = "https://tar.goaccess.io/${name}.tar.gz"; | |
50 | sha256 = "16vv3pj7pbraq173wlxa89jjsd279004j4kgzlrsk1dz4if5qxwc"; | |
51 | }; | |
52 | configureFlags = old.configureFlags ++ [ "--enable-tcb=btree" ]; | |
53 | buildInputs = old.buildInputs ++ [ pkgs.tokyocabinet pkgs.bzip2 ]; | |
54 | }); | |
91493dc0 IB |
55 | }; |
56 | ||
a1bb33c4 IB |
57 | networking = { |
58 | firewall = { | |
59 | enable = true; | |
7611e4e2 | 60 | allowedTCPPorts = [ 22 80 443 3306 5432 9418 ]; |
a1bb33c4 IB |
61 | }; |
62 | }; | |
63 | ||
64 | deployment = { | |
65 | targetEnv = "hetzner"; | |
66 | hetzner = { | |
67 | #robotUser = "defined in HETZNER_ROBOT_USER"; | |
68 | #robotPass = "defined in HETZNER_ROBOT_PASS"; | |
69 | mainIPv4 = "176.9.151.89"; | |
70 | partitions = '' | |
71 | clearpart --all --initlabel --drives=sda,sdb | |
72 | ||
73 | part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda | |
74 | part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb | |
75 | ||
76 | part raid.1 --grow --ondisk=sda | |
77 | part raid.2 --grow --ondisk=sdb | |
78 | ||
79 | raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2 | |
80 | ''; | |
81 | }; | |
82 | }; | |
83 | ||
66b5bbf6 IB |
84 | environment.systemPackages = let |
85 | # FIXME: move it to nextcloud | |
86 | occ = pkgs.writeScriptBin "nextcloud-occ" '' | |
87 | #! ${pkgs.stdenv.shell} | |
88 | cd ${mypkgs.nextcloud.webRoot} | |
89 | NEXTCLOUD_CONFIG_DIR="${mypkgs.nextcloud.webRoot}/config" \ | |
90 | exec \ | |
91 | ${config.services.phpfpm.phpPackage}/bin/php \ | |
92 | -c ${config.services.phpfpm.phpPackage}/etc/php.ini \ | |
93 | occ $* | |
94 | ''; | |
95 | in [ | |
ce6ee3b8 IB |
96 | pkgs.telnet |
97 | pkgs.vim | |
6f0d92b4 | 98 | pkgs.goaccess |
66b5bbf6 | 99 | occ |
ce6ee3b8 IB |
100 | ]; |
101 | ||
a1bb33c4 | 102 | security.acme.certs = { |
e42ba74f IB |
103 | # /!\ To create a new certificate, add first the domain to an |
104 | # existing certificate, deploy, and then use it in httpd. | |
a1bb33c4 IB |
105 | "eldiron" = { |
106 | webroot = "/var/lib/acme/acme-challenge"; | |
107 | email = "ismael@bouya.org"; | |
108 | domain = "eldiron.immae.eu"; | |
e379fd29 IB |
109 | plugins = [ "cert.pem" "chain.pem" "fullchain.pem" "full.pem" "key.pem" "account_key.json" ]; |
110 | postRun = '' | |
e273ef92 | 111 | systemctl reload httpd.service |
e379fd29 | 112 | ''; |
a1bb33c4 IB |
113 | extraDomains = { |
114 | "db-1.immae.eu" = null; | |
1b81e079 | 115 | "git.immae.eu" = null; |
e379fd29 | 116 | "tools.immae.eu" = null; |
65fe7543 IB |
117 | "connexionswing.immae.eu" = null; |
118 | "sandetludo.immae.eu" = null; | |
66b5bbf6 | 119 | "cloud.immae.eu" = null; |
e42ba74f | 120 | "ludivine.immae.eu" = null; |
6c672f34 | 121 | "dev.aten.pro" = null; |
e42ba74f IB |
122 | }; |
123 | }; | |
124 | "ludivinecassal" = { | |
125 | webroot = "/var/lib/acme/acme-challenge"; | |
126 | email = "ismael@bouya.org"; | |
127 | domain = "ludivinecassal.com"; | |
128 | plugins = [ "cert.pem" "chain.pem" "fullchain.pem" "full.pem" "key.pem" "account_key.json" ]; | |
129 | postRun = '' | |
130 | systemctl reload httpd.service | |
131 | ''; | |
132 | extraDomains = { | |
133 | "www.ludivinecassal.com" = null; | |
a1bb33c4 IB |
134 | }; |
135 | }; | |
6c672f34 IB |
136 | "aten" = { |
137 | webroot = "/var/lib/acme/acme-challenge"; | |
138 | email = "ismael@bouya.org"; | |
139 | domain = "aten.pro"; | |
140 | plugins = [ "cert.pem" "chain.pem" "fullchain.pem" "full.pem" "key.pem" "account_key.json" ]; | |
141 | postRun = '' | |
142 | systemctl reload httpd.service | |
143 | ''; | |
144 | extraDomains = { | |
145 | "www.aten.pro" = null; | |
146 | }; | |
147 | }; | |
e273ef92 IB |
148 | # "connexionswing" = { |
149 | # webroot = "/var/lib/acme/acme-challenge"; | |
150 | # email = "ismael@bouya.org"; | |
151 | # domain = "connexionswing.com"; | |
152 | # plugins = [ "cert.pem" "chain.pem" "fullchain.pem" "full.pem" "key.pem" "account_key.json" ]; | |
153 | # postRun = '' | |
154 | # systemctl reload httpd.service | |
155 | # ''; | |
156 | # extraDomains = { | |
157 | # "www.connexionswing.com" = null; | |
158 | # "sandetludo.com" = null; | |
159 | # "www.sandetludo.com" = null; | |
160 | # }; | |
161 | # }; | |
a1bb33c4 IB |
162 | }; |
163 | ||
5566d26d IB |
164 | services.openssh.extraConfig = '' |
165 | AuthorizedKeysCommand /etc/ssh/ldap_authorized_keys | |
166 | AuthorizedKeysCommandUser nobody | |
167 | ''; | |
168 | ||
cf80b4f2 IB |
169 | users.users.wwwrun.extraGroups = [ "gitolite" ]; |
170 | ||
19def671 IB |
171 | users.users.gitolite.packages = let |
172 | python-packages = python-packages: with python-packages; [ | |
173 | simplejson | |
174 | urllib3 | |
175 | ]; | |
176 | in | |
177 | [ | |
178 | (pkgs.python3.withPackages python-packages) | |
179 | ]; | |
5566d26d IB |
180 | # FIXME: after initial install, need to |
181 | # (1) copy rc file (adjust gitolite_ldap_groups.sh) | |
182 | # (2) (mark old readonly and) sync repos except gitolite-admin | |
183 | # rsync -av --exclude=gitolite-admin.git old:/var/lib/gitolite/repositories /var/lib/gitolite/ | |
184 | # chown -R gitolite:gitolite /var/lib/gitolite | |
185 | # (3) push force the gitolite-admin to new location (from external point) | |
186 | # Don't use an existing key, it will take precedence over | |
187 | # gitolite-admin | |
188 | # (4) su -u gitolite gitolite setup | |
189 | services.gitolite = { | |
190 | enable = true; | |
191 | # FIXME: key from ./ssh | |
192 | adminPubkey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXqRbiHw7QoHADNIEuo4nUT9fSOIEBMdJZH0bkQAxXyJFyCM1IMz0pxsHV0wu9tdkkr36bPEUj2aV5bkYLBN6nxcV2Y49X8bjOSCPfx3n6Own1h+NeZVBj4ZByrFmqCbTxUJIZ2bZKcWOFncML39VmWdsVhNjg0X4NBBehqXRIKr2gt3E/ESAxTYJFm0BnU0baciw9cN0bsRGqvFgf5h2P48CIAfwhVcGmPQnnAwabnosYQzRWxR0OygH5Kd8mePh6FheIRIigfXsDO8f/jdxwut8buvNIf3m5EBr3tUbTsvM+eV3M5vKGt7sk8T64DVtepTSdOOWtp+47ktsnHOMh immae@immae.eu"; | |
193 | }; | |
194 | ||
a05f8abe IB |
195 | services.ympd = mypkgs.ympd.config // { enable = true; }; |
196 | ||
58d1a782 | 197 | services.phpfpm = { |
66b5bbf6 IB |
198 | # /!\ phppackage is used in nextcloud configuation |
199 | phpOptions = '' | |
200 | ; For nextcloud | |
201 | extension=${pkgs.phpPackages.redis}/lib/php/extensions/redis.so | |
202 | ; For nextcloud | |
203 | extension=${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so | |
ec9ff2b8 IB |
204 | ; For nextcloud |
205 | zend_extension=${pkgs.php}/lib/php/extensions/opcache.so | |
66b5bbf6 | 206 | ''; |
58d1a782 IB |
207 | extraConfig = '' |
208 | log_level = notice | |
209 | ''; | |
210 | poolConfigs = { | |
27e22b76 | 211 | adminer = mypkgs.adminer.phpFpm.pool; |
65fe7543 | 212 | connexionswing_dev = mypkgs.connexionswing_dev.phpFpm.pool; |
e273ef92 | 213 | connexionswing_prod = mypkgs.connexionswing_prod.phpFpm.pool; |
e42ba74f IB |
214 | ludivinecassal_dev = mypkgs.ludivinecassal_dev.phpFpm.pool; |
215 | ludivinecassal_prod = mypkgs.ludivinecassal_prod.phpFpm.pool; | |
6c672f34 IB |
216 | aten_dev = mypkgs.aten_dev.phpFpm.pool; |
217 | aten_prod = mypkgs.aten_prod.phpFpm.pool; | |
66b5bbf6 | 218 | nextcloud = mypkgs.nextcloud.phpFpm.pool; |
50d8fa14 | 219 | mantisbt = mypkgs.mantisbt.phpFpm.pool; |
58d1a782 IB |
220 | }; |
221 | }; | |
222 | ||
65fe7543 IB |
223 | system.activationScripts = { |
224 | connexionswing_dev = mypkgs.connexionswing_dev.activationScript; | |
e273ef92 | 225 | connexionswing_prod = mypkgs.connexionswing_prod.activationScript; |
e42ba74f IB |
226 | ludivinecassal_dev = mypkgs.ludivinecassal_dev.activationScript; |
227 | ludivinecassal_prod = mypkgs.ludivinecassal_prod.activationScript; | |
6c672f34 IB |
228 | aten_dev = mypkgs.aten_dev.activationScript; |
229 | aten_prod = mypkgs.aten_prod.activationScript; | |
66b5bbf6 | 230 | nextcloud = mypkgs.nextcloud.activationScript; |
5dd28b43 IB |
231 | httpd = '' |
232 | install -d -m 0755 /var/lib/acme/acme-challenge | |
5dd28b43 | 233 | ''; |
60f67ae3 IB |
234 | redis = '' |
235 | mkdir -p /run/redis | |
236 | chown redis /run/redis | |
237 | ''; | |
5566d26d | 238 | gitolite = |
5c101474 | 239 | assert checkEnv "NIXOPS_GITOLITE_LDAP_PASSWORD"; |
5566d26d | 240 | let |
5c101474 | 241 | gitolite_ldap_groups = wrap { |
5566d26d IB |
242 | name = "gitolite_ldap_groups.sh"; |
243 | file = ./packages/gitolite_ldap_groups.sh; | |
244 | vars = { | |
245 | LDAP_PASS = builtins.getEnv "NIXOPS_GITOLITE_LDAP_PASSWORD"; | |
246 | }; | |
247 | paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.coreutils ]; | |
248 | }; | |
249 | in { | |
250 | deps = [ "users" ]; | |
251 | text = '' | |
252 | if [ -d /var/lib/gitolite ]; then | |
253 | ln -sf ${gitolite_ldap_groups} /var/lib/gitolite/gitolite_ldap_groups.sh | |
cf80b4f2 IB |
254 | chmod g+rx /var/lib/gitolite |
255 | fi | |
256 | if [ -f /var/lib/gitolite/projects.list ]; then | |
257 | chmod g+r /var/lib/gitolite/projects.list | |
5566d26d IB |
258 | fi |
259 | ''; | |
260 | }; | |
6f0d92b4 IB |
261 | goaccess = '' |
262 | mkdir -p /var/lib/goaccess | |
263 | mkdir -p /var/lib/goaccess/aten.pro | |
264 | ''; | |
5566d26d IB |
265 | }; |
266 | ||
267 | environment.etc."ssh/ldap_authorized_keys" = let | |
268 | ldap_authorized_keys = | |
5c101474 IB |
269 | assert checkEnv "NIXOPS_SSHD_LDAP_PASSWORD"; |
270 | wrap { | |
5566d26d IB |
271 | name = "ldap_authorized_keys"; |
272 | file = ./ldap_authorized_keys.sh; | |
273 | vars = { | |
274 | LDAP_PASS = builtins.getEnv "NIXOPS_SSHD_LDAP_PASSWORD"; | |
275 | GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell"; | |
276 | ECHO = "${pkgs.coreutils}/bin/echo"; | |
277 | }; | |
278 | paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ]; | |
279 | }; | |
280 | in { | |
281 | enable = true; | |
282 | mode = "0755"; | |
283 | user = "root"; | |
284 | source = ldap_authorized_keys; | |
65fe7543 IB |
285 | }; |
286 | ||
7611e4e2 IB |
287 | services.gitDaemon = { |
288 | enable = true; | |
289 | user = "gitolite"; | |
290 | group = "gitolite"; | |
291 | basePath = "${mypkgs.git.web.varDir}/repositories"; | |
292 | }; | |
293 | ||
58d1a782 | 294 | services.httpd = let |
b7cd7e4b | 295 | withConf = domain: { |
58d1a782 | 296 | enableSSL = true; |
5dd28b43 | 297 | sslServerCert = "/var/lib/acme/${domain}/cert.pem"; |
58d1a782 IB |
298 | sslServerKey = "/var/lib/acme/${domain}/key.pem"; |
299 | sslServerChain = "/var/lib/acme/${domain}/fullchain.pem"; | |
b7cd7e4b IB |
300 | logFormat = "combinedVhost"; |
301 | listen = [ { ip = "*"; port = 443; } ]; | |
58d1a782 | 302 | }; |
94818b75 IB |
303 | apacheConfig = { |
304 | gzip = { | |
305 | modules = [ "deflate" "filter" ]; | |
306 | extraConfig = '' | |
307 | AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript | |
308 | ''; | |
309 | }; | |
310 | ldap = { | |
311 | modules = [ "ldap" "authnz_ldap" ]; | |
5c101474 | 312 | extraConfig = assert checkEnv "NIXOPS_HTTP_LDAP_PASSWORD"; '' |
94818b75 IB |
313 | <IfModule ldap_module> |
314 | LDAPSharedCacheSize 500000 | |
315 | LDAPCacheEntries 1024 | |
316 | LDAPCacheTTL 600 | |
317 | LDAPOpCacheEntries 1024 | |
318 | LDAPOpCacheTTL 600 | |
319 | </IfModule> | |
320 | ||
321 | <Macro LDAPConnect> | |
322 | <IfModule authnz_ldap_module> | |
323 | AuthLDAPURL ldap://ldap.immae.eu:389/dc=immae,dc=eu | |
324 | AuthLDAPBindDN cn=httpd,ou=services,dc=immae,dc=eu | |
325 | AuthLDAPBindPassword "${builtins.getEnv "NIXOPS_HTTP_LDAP_PASSWORD"}" | |
326 | AuthType Basic | |
327 | AuthName "Authentification requise (Acces LDAP)" | |
328 | AuthBasicProvider ldap | |
329 | </IfModule> | |
330 | </Macro> | |
6f0d92b4 IB |
331 | |
332 | <Macro Stats %{domain}> | |
333 | Alias /awstats /var/lib/goaccess/%{domain} | |
334 | <Directory /var/lib/goaccess/%{domain}> | |
335 | DirectoryIndex index.html | |
336 | AllowOverride None | |
337 | Require all granted | |
338 | </Directory> | |
339 | <Location /awstats> | |
340 | Use LDAPConnect | |
341 | Require ldap-group cn=%{domain},ou=stats,cn=httpd,ou=services,dc=immae,dc=eu | |
342 | </Location> | |
343 | </Macro> | |
94818b75 IB |
344 | ''; |
345 | }; | |
b7cd7e4b IB |
346 | http2 = { |
347 | modules = [ "http2" ]; | |
348 | extraConfig = '' | |
349 | Protocols h2 http/1.1 | |
350 | ''; | |
351 | }; | |
352 | customLog = { | |
353 | modules = []; | |
354 | extraConfig = '' | |
6f0d92b4 | 355 | LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedVhost |
b7cd7e4b IB |
356 | ''; |
357 | }; | |
94818b75 | 358 | }; |
58d1a782 | 359 | in rec { |
a1bb33c4 | 360 | enable = true; |
58d1a782 IB |
361 | logPerVirtualHost = true; |
362 | multiProcessingModule = "worker"; | |
363 | adminAddr = "httpd@immae.eu"; | |
b7cd7e4b | 364 | logFormat = "combinedVhost"; |
25fd1d16 IB |
365 | extraModules = pkgs.lib.lists.unique ( |
366 | mypkgs.adminer.apache.modules ++ | |
66b5bbf6 | 367 | mypkgs.nextcloud.apache.modules ++ |
65fe7543 | 368 | mypkgs.connexionswing_dev.apache.modules ++ |
e273ef92 | 369 | mypkgs.connexionswing_prod.apache.modules ++ |
e42ba74f IB |
370 | mypkgs.ludivinecassal_dev.apache.modules ++ |
371 | mypkgs.ludivinecassal_prod.apache.modules ++ | |
6c672f34 IB |
372 | mypkgs.aten_dev.apache.modules ++ |
373 | mypkgs.aten_prod.apache.modules ++ | |
5f3e023d | 374 | mypkgs.ympd.apache.modules ++ |
cf80b4f2 | 375 | mypkgs.git.web.apache.modules ++ |
50d8fa14 | 376 | mypkgs.mantisbt.apache.modules ++ |
94818b75 IB |
377 | pkgs.lib.lists.flatten (pkgs.lib.attrsets.mapAttrsToList (n: v: v.modules) apacheConfig) ++ |
378 | [ "macro" ]); | |
379 | extraConfig = builtins.concatStringsSep "\n" | |
380 | (pkgs.lib.attrsets.mapAttrsToList (n: v: v.extraConfig) apacheConfig); | |
58d1a782 | 381 | virtualHosts = [ |
b7cd7e4b | 382 | (withConf "eldiron" // { |
58d1a782 | 383 | hostName = "eldiron.immae.eu"; |
1d4ccb2c IB |
384 | documentRoot = ./www; |
385 | extraConfig = '' | |
386 | DirectoryIndex index.htm | |
387 | ''; | |
58d1a782 | 388 | }) |
b7cd7e4b | 389 | (withConf "eldiron" // { |
58d1a782 IB |
390 | hostName = "db-1.immae.eu"; |
391 | documentRoot = null; | |
27e22b76 | 392 | extraConfig = builtins.concatStringsSep "\n" [ |
1bb2ff2c | 393 | mypkgs.adminer.apache.vhostConf |
27e22b76 | 394 | ]; |
58d1a782 | 395 | }) |
b7cd7e4b | 396 | (withConf "eldiron" // { |
e379fd29 IB |
397 | hostName = "tools.immae.eu"; |
398 | documentRoot = null; | |
399 | extraConfig = builtins.concatStringsSep "\n" [ | |
1bb2ff2c | 400 | mypkgs.adminer.apache.vhostConf |
a05f8abe | 401 | mypkgs.ympd.apache.vhostConf |
e379fd29 IB |
402 | ]; |
403 | }) | |
b7cd7e4b | 404 | (withConf "eldiron" // { |
65fe7543 IB |
405 | hostName = "connexionswing.immae.eu"; |
406 | serverAliases = [ "sandetludo.immae.eu" ]; | |
407 | documentRoot = mypkgs.connexionswing_dev.webRoot; | |
408 | extraConfig = builtins.concatStringsSep "\n" [ | |
409 | mypkgs.connexionswing_dev.apache.vhostConf | |
410 | ]; | |
411 | }) | |
e42ba74f IB |
412 | (withConf "eldiron" // { |
413 | hostName = "ludivine.immae.eu"; | |
414 | documentRoot = mypkgs.ludivinecassal_dev.webRoot; | |
415 | extraConfig = builtins.concatStringsSep "\n" [ | |
416 | mypkgs.ludivinecassal_dev.apache.vhostConf | |
417 | ]; | |
418 | }) | |
419 | (withConf "ludivinecassal" // { | |
420 | hostName = "ludivinecassal.com"; | |
421 | serverAliases = [ "www.ludivinecassal.com" ]; | |
422 | documentRoot = mypkgs.ludivinecassal_prod.webRoot; | |
423 | extraConfig = builtins.concatStringsSep "\n" [ | |
424 | mypkgs.ludivinecassal_prod.apache.vhostConf | |
425 | ]; | |
426 | }) | |
6c672f34 IB |
427 | (withConf "eldiron" // { |
428 | hostName = "dev.aten.pro"; | |
429 | documentRoot = mypkgs.aten_dev.webRoot; | |
430 | extraConfig = builtins.concatStringsSep "\n" [ | |
431 | mypkgs.aten_dev.apache.vhostConf | |
432 | ]; | |
433 | }) | |
434 | (withConf "aten" // { | |
435 | hostName = "aten.pro"; | |
436 | serverAliases = [ "www.aten.pro" ]; | |
437 | documentRoot = mypkgs.aten_prod.webRoot; | |
438 | extraConfig = builtins.concatStringsSep "\n" [ | |
439 | mypkgs.aten_prod.apache.vhostConf | |
440 | ]; | |
441 | }) | |
b7cd7e4b | 442 | (withConf "eldiron" // { |
66b5bbf6 IB |
443 | hostName = "cloud.immae.eu"; |
444 | documentRoot = mypkgs.nextcloud.webRoot; | |
445 | extraConfig = builtins.concatStringsSep "\n" [ | |
446 | mypkgs.nextcloud.apache.vhostConf | |
447 | ]; | |
448 | }) | |
b7cd7e4b | 449 | (withConf "eldiron" // { |
cf80b4f2 IB |
450 | hostName = "git.immae.eu"; |
451 | documentRoot = mypkgs.git.web.webRoot; | |
452 | extraConfig = builtins.concatStringsSep "\n" [ | |
453 | mypkgs.git.web.apache.vhostConf | |
50d8fa14 | 454 | mypkgs.mantisbt.apache.vhostConf |
cf80b4f2 IB |
455 | ] + '' |
456 | RewriteEngine on | |
457 | RewriteCond %{REQUEST_URI} ^/releases | |
458 | RewriteRule /releases(.*) https://release.immae.eu$1 [P,L] | |
459 | ''; | |
460 | }) | |
58d1a782 IB |
461 | { # Should go last, default fallback |
462 | listen = [ { ip = "*"; port = 80; } ]; | |
463 | hostName = "redirectSSL"; | |
464 | serverAliases = [ "*" ]; | |
465 | enableSSL = false; | |
b7cd7e4b | 466 | logFormat = "combinedVhost"; |
58d1a782 IB |
467 | documentRoot = "/var/lib/acme/acme-challenge"; |
468 | extraConfig = '' | |
469 | RewriteEngine on | |
470 | RewriteCond "%{REQUEST_URI}" "!^/\.well-known" | |
471 | RewriteRule ^(.+) https://%{HTTP_HOST}$1 [R=301] | |
472 | # To redirect in specific "VirtualHost *:80", do | |
473 | # RedirectMatch 301 ^/((?!\.well-known.*$).*)$ https://host/$1 | |
474 | # rather than rewrite | |
475 | ''; | |
476 | } | |
477 | ]; | |
478 | }; | |
479 | ||
dedf591d IB |
480 | security.pam.services = let |
481 | pam_ldap = pkgs.pam_ldap; | |
5c101474 | 482 | pam_ldap_mysql = assert checkEnv "NIXOPS_MYSQL_PAM_PASSWORD"; |
6cd8d6ce | 483 | pkgs.writeText "mysql.conf" '' |
dedf591d IB |
484 | host ldap.immae.eu |
485 | base dc=immae,dc=eu | |
486 | binddn cn=mysql,cn=pam,ou=services,dc=immae,dc=eu | |
487 | bindpw ${builtins.getEnv "NIXOPS_MYSQL_PAM_PASSWORD"} | |
488 | pam_filter memberOf=cn=users,cn=mysql,cn=pam,ou=services,dc=immae,dc=eu | |
489 | ''; | |
490 | in [ | |
491 | { | |
492 | name = "mysql"; | |
493 | text = '' | |
494 | # https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/ | |
495 | auth required ${pam_ldap}/lib/security/pam_ldap.so config=${pam_ldap_mysql} | |
496 | account required ${pam_ldap}/lib/security/pam_ldap.so config=${pam_ldap_mysql} | |
497 | ''; | |
498 | } | |
499 | ]; | |
500 | ||
60f67ae3 IB |
501 | # FIXME: backup |
502 | services.redis = rec { | |
503 | enable = true; | |
504 | bind = "127.0.0.1"; | |
505 | unixSocket = "/run/redis/redis.sock"; | |
506 | extraConfig = '' | |
507 | unixsocketperm 777 | |
508 | maxclients 1024 | |
509 | ''; | |
510 | }; | |
511 | ||
dedf591d IB |
512 | # FIXME: initial sync |
513 | # FIXME: backup | |
514 | # FIXME: restart after pam | |
515 | # FIXME: pam access doesn’t work (because of php module) | |
27e22b76 | 516 | # FIXME: ssl |
dedf591d IB |
517 | services.mysql = rec { |
518 | enable = true; | |
91493dc0 | 519 | package = pkgs.mariadb; |
dedf591d IB |
520 | }; |
521 | ||
a1bb33c4 | 522 | # FIXME: initial sync |
dedf591d | 523 | # FIXME: backup |
27e22b76 | 524 | # FIXME: ssl |
a1bb33c4 IB |
525 | services.postgresql = rec { |
526 | enable = true; | |
91493dc0 | 527 | package = pkgs.postgresql; |
a1bb33c4 IB |
528 | enableTCPIP = true; |
529 | extraConfig = '' | |
530 | max_connections = 100 | |
531 | wal_level = logical | |
532 | shared_buffers = 128MB | |
533 | max_wal_size = 1GB | |
534 | min_wal_size = 80MB | |
535 | log_timezone = 'Europe/Paris' | |
536 | datestyle = 'iso, mdy' | |
537 | timezone = 'Europe/Paris' | |
538 | lc_messages = 'en_US.UTF-8' | |
539 | lc_monetary = 'en_US.UTF-8' | |
540 | lc_numeric = 'en_US.UTF-8' | |
541 | lc_time = 'en_US.UTF-8' | |
542 | default_text_search_config = 'pg_catalog.english' | |
543 | # ssl = on | |
544 | # ssl_cert_file = '/var/lib/acme/eldiron/fullchain.pem' | |
545 | # ssl_key_file = '/var/lib/acme/eldiron/key.pem' | |
546 | ''; | |
547 | authentication = '' | |
548 | local all postgres ident | |
549 | local all all md5 | |
50d8fa14 | 550 | host all all samehost md5 |
a1bb33c4 IB |
551 | host all all 178.33.252.96/32 md5 |
552 | host all all 188.165.209.148/32 md5 | |
553 | #host all all all pam | |
554 | ''; | |
555 | }; | |
6f0d92b4 IB |
556 | |
557 | services.cron = { | |
558 | enable = true; | |
559 | systemCronJobs = let | |
560 | stats = domain: conf: "${pkgs.gnused}/bin/sed -n '/\\['$(LC_ALL=C ${pkgs.coreutils}/bin/date -d yesterday +'%d\\/%b\\/%Y')'/ p' /var/log/httpd/access_log-${domain} | ${pkgs.goaccess}/bin/goaccess -o /var/lib/goaccess/${domain}/index.html -p ${conf}"; | |
561 | in [ | |
562 | "5 0 * * * root ${stats "aten.pro" ./packages/aten_goaccess.conf}" | |
2f2b578b | 563 | "5 0 * * * root ${stats "ludivinecassal.com" ./packages/ludivinecassal_goaccess.conf}" |
6f0d92b4 IB |
564 | ]; |
565 | }; | |
a1bb33c4 IB |
566 | }; |
567 | } |