3 description = "Immae's network";
7 eldiron = { config, pkgs, ... }:
8 let mypkgs = import ./packages.nix;
14 allowedTCPPorts = [ 22 80 443 3306 5432 ];
19 targetEnv = "hetzner";
21 #robotUser = "defined in HETZNER_ROBOT_USER";
22 #robotPass = "defined in HETZNER_ROBOT_PASS";
23 mainIPv4 = "176.9.151.89";
25 clearpart --all --initlabel --drives=sda,sdb
27 part swap1 --recommended --label=swap1 --fstype=swap --ondisk=sda
28 part swap2 --recommended --label=swap2 --fstype=swap --ondisk=sdb
30 part raid.1 --grow --ondisk=sda
31 part raid.2 --grow --ondisk=sdb
33 raid / --level=1 --device=md0 --fstype=ext4 --label=root raid.1 raid.2
38 # FIXME: how to run it? currently set as timer
39 security.acme.certs = {
41 webroot = "/var/lib/acme/acme-challenge";
42 email = "ismael@bouya.org";
43 domain = "eldiron.immae.eu";
44 plugins = [ "cert.pem" "chain.pem" "fullchain.pem" "full.pem" "key.pem" "account_key.json" ];
46 "systemctl reload httpd.service"
49 "db-1.immae.eu" = null;
50 "tools.immae.eu" = null;
55 services.ympd = mypkgs.ympd.config // { enable = true; };
63 adminer = mypkgs.adminer.phpFpm.pool;
65 listen = /var/run/phpfpm/www.sock
72 pm.process_idle_timeout = 60
73 ;php_admin_flag[log_errors] = on
74 php_admin_value[open_basedir] = "/var/www"
82 sslServerCert = "/var/lib/acme/${domain}/full.pem"; # FIXME: cert only?
83 sslServerKey = "/var/lib/acme/${domain}/key.pem";
84 sslServerChain = "/var/lib/acme/${domain}/fullchain.pem";
88 logPerVirtualHost = true;
89 multiProcessingModule = "worker";
90 adminAddr = "httpd@immae.eu";
92 "proxy_fcgi" # for PHP
98 <IfModule ldap_module>
99 LDAPSharedCacheSize 500000
100 LDAPCacheEntries 1024
102 LDAPOpCacheEntries 1024
107 <IfModule authnz_ldap_module>
108 AuthLDAPURL ldap://ldap.immae.eu:389/dc=immae,dc=eu
109 AuthLDAPBindDN cn=httpd,ou=services,dc=immae,dc=eu
110 AuthLDAPBindPassword "${builtins.getEnv "NIXOPS_HTTP_LDAP_PASSWORD"}"
112 AuthName "Authentification requise (Acces LDAP)"
113 AuthBasicProvider ldap
118 (withSSL "eldiron" // {
119 listen = [ { ip = "*"; port = 443; } ];
120 hostName = "eldiron.immae.eu";
121 # FIXME: directory needs to exist
122 documentRoot = "/var/www";
124 (withSSL "eldiron" // {
125 listen = [ { ip = "*"; port = 443; } ];
126 hostName = "db-1.immae.eu";
128 extraConfig = builtins.concatStringsSep "\n" [
129 mypkgs.adminer.apache.vhostConf
132 (withSSL "eldiron" // {
133 listen = [ { ip = "*"; port = 443; } ];
134 hostName = "tools.immae.eu";
136 extraConfig = builtins.concatStringsSep "\n" [
137 mypkgs.adminer.apache.vhostConf
138 mypkgs.ympd.apache.vhostConf
141 { # Should go last, default fallback
142 listen = [ { ip = "*"; port = 80; } ];
143 hostName = "redirectSSL";
144 serverAliases = [ "*" ];
146 # FIXME: directory needs to exist
147 documentRoot = "/var/lib/acme/acme-challenge";
150 RewriteCond "%{REQUEST_URI}" "!^/\.well-known"
151 RewriteRule ^(.+) https://%{HTTP_HOST}$1 [R=301]
152 # To redirect in specific "VirtualHost *:80", do
153 # RedirectMatch 301 ^/((?!\.well-known.*$).*)$ https://host/$1
154 # rather than rewrite
160 # FIXME: environment variables ?
161 security.pam.services = let
162 pam_ldap = pkgs.pam_ldap;
163 pam_ldap_mysql = pkgs.writeText "mysql.conf" ''
166 binddn cn=mysql,cn=pam,ou=services,dc=immae,dc=eu
167 bindpw ${builtins.getEnv "NIXOPS_MYSQL_PAM_PASSWORD"}
168 pam_filter memberOf=cn=users,cn=mysql,cn=pam,ou=services,dc=immae,dc=eu
174 # https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/
175 auth required ${pam_ldap}/lib/security/pam_ldap.so config=${pam_ldap_mysql}
176 account required ${pam_ldap}/lib/security/pam_ldap.so config=${pam_ldap_mysql}
181 # FIXME: initial sync
183 # FIXME: restart after pam
184 # FIXME: pam access doesn’t work (because of php module)
186 services.mysql = rec {
188 package = pkgs.mariadb.overrideAttrs(old: rec {
189 cmakeFlags = old.cmakeFlags ++ [ "-DWITH_AUTHENTICATION_PAM=ON" ];
190 buildInputs = old.buildInputs ++ [ pkgs.pam ];
194 # FIXME: initial sync
197 services.postgresql = rec {
199 package = pkgs.postgresql100.overrideAttrs(old: rec {
200 passthru = old.passthru // { psqlSchema = "11.0"; };
201 name = "postgresql-11.1";
202 src = pkgs.fetchurl {
203 url = "mirror://postgresql/source/v11.1/${name}.tar.bz2";
204 sha256 = "026v0sicsh7avzi45waf8shcbhivyxmi7qgn9fd1x0vl520mx0ch";
209 max_connections = 100
211 shared_buffers = 128MB
214 log_timezone = 'Europe/Paris'
215 datestyle = 'iso, mdy'
216 timezone = 'Europe/Paris'
217 lc_messages = 'en_US.UTF-8'
218 lc_monetary = 'en_US.UTF-8'
219 lc_numeric = 'en_US.UTF-8'
220 lc_time = 'en_US.UTF-8'
221 default_text_search_config = 'pg_catalog.english'
223 # ssl_cert_file = '/var/lib/acme/eldiron/fullchain.pem'
224 # ssl_key_file = '/var/lib/acme/eldiron/key.pem'
227 local all postgres ident
229 host all all 178.33.252.96/32 md5
230 host all all 188.165.209.148/32 md5
231 #host all all all pam