]>
Commit | Line | Data |
---|---|---|
1 | { lib, config, pkgs, ... }: | |
2 | let | |
3 | cfg = config.myServices.websites.richie.production; | |
4 | vardir = "/var/lib/richie_production"; | |
5 | richieSrc = pkgs.stdenv.mkDerivation rec { | |
6 | version = pkgs.sources.websites-richie-app.version; | |
7 | pname = "richie"; | |
8 | name = "${pname}-${version}"; | |
9 | src = pkgs.sources.websites-richie-app; | |
10 | phases = "installPhase"; | |
11 | installPhase = '' | |
12 | cp -a $src $out | |
13 | chmod -R u+w $out | |
14 | ln -sf ${vardir}/files $out/ | |
15 | ln -sf ${vardir}/drapeaux $out/images/ | |
16 | ln -sf ${vardir}/photos $out/ | |
17 | sed -i "s@localedef --list-archive@localedef --list-archive /run/current-system/sw/lib/locale/locale-archive@" $out/admin/parametres.php | |
18 | ''; | |
19 | }; | |
20 | webappdir = config.services.websites.webappDirsPaths.richie_production; | |
21 | secretPath = config.secrets.fullPaths."websites/richie/production"; | |
22 | apacheUser = config.services.httpd.Prod.user; | |
23 | apacheGroup = config.services.httpd.Prod.group; | |
24 | in | |
25 | { | |
26 | options.myServices.websites.richie.production.enable = lib.mkEnableOption "enable Richie's website"; | |
27 | config = lib.mkIf cfg.enable { | |
28 | services.duplyBackup.profiles.richie_production.rootDir = vardir; | |
29 | services.webstats.sites = [ { name = "europe-richie.org"; } ]; | |
30 | ||
31 | secrets.keys = [{ | |
32 | dest = "websites/richie/production"; | |
33 | user = apacheUser; | |
34 | group = apacheGroup; | |
35 | permissions = "0400"; | |
36 | text = with config.myEnv.websites.richie; '' | |
37 | <?php | |
38 | ||
39 | $hote_sql = '${mysql.host}'; | |
40 | $login_sql = '${mysql.user}'; | |
41 | $bdd_sql = '${mysql.database}'; | |
42 | $mdp_sql = '${mysql.password}'; | |
43 | ||
44 | $db = mysqli_connect($hote_sql,$login_sql,$mdp_sql); | |
45 | unset($mdp_sql); | |
46 | ||
47 | $smtp_mailer->Auth('${smtp_mailer.user}', '${smtp_mailer.password}'); | |
48 | ?> | |
49 | ''; | |
50 | }]; | |
51 | services.websites.webappDirs.richie_production = richieSrc; | |
52 | system.activationScripts.richie_production = { | |
53 | deps = [ "httpd" ]; | |
54 | text = '' | |
55 | install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/richie_production | |
56 | install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${vardir} | |
57 | ''; | |
58 | }; | |
59 | services.phpfpm.pools.richie_production = { | |
60 | user = apacheUser; | |
61 | group = apacheGroup; | |
62 | settings = { | |
63 | "listen.owner" = apacheUser; | |
64 | "listen.group" = apacheGroup; | |
65 | ||
66 | "pm" = "ondemand"; | |
67 | "pm.max_children" = "5"; | |
68 | "pm.process_idle_timeout" = "60"; | |
69 | ||
70 | "php_admin_value[open_basedir]" = "${vardir}:/var/lib/php/sessions/richie_production:${secretPath}:${richieSrc}:/tmp"; | |
71 | "php_admin_value[session.save_path]" = "/var/lib/php/sessions/richie_production"; | |
72 | }; | |
73 | phpEnv = { | |
74 | PATH = "/run/current-system/sw/bin:${lib.makeBinPath [ pkgs.imagemagick ]}"; | |
75 | BDD_CONNECT = secretPath; | |
76 | }; | |
77 | phpOptions = config.services.phpfpm.phpOptions + '' | |
78 | date.timezone = 'Europe/Paris' | |
79 | ''; | |
80 | phpPackage = pkgs.php72; | |
81 | }; | |
82 | services.websites.env.production.modules = [ "proxy_fcgi" ]; | |
83 | services.websites.env.production.vhostConfs.richie_production = { | |
84 | certName = "richie"; | |
85 | addToCerts = true; | |
86 | certMainHost = "europe-richie.org"; | |
87 | hosts = [ "europe-richie.org" "www.europe-richie.org" ]; | |
88 | root = webappdir; | |
89 | extraConfig = [ | |
90 | '' | |
91 | Use Stats europe-richie.org | |
92 | ErrorDocument 404 /404.html | |
93 | <LocationMatch "^/files/.*/admin/"> | |
94 | Require all denied | |
95 | </LocationMatch> | |
96 | <Directory ${webappdir}> | |
97 | DirectoryIndex index.php index.htm index.html | |
98 | Options Indexes FollowSymLinks MultiViews Includes | |
99 | AllowOverride None | |
100 | Require all granted | |
101 | ||
102 | <FilesMatch "\.php$"> | |
103 | SetHandler "proxy:unix:${config.services.phpfpm.pools.richie_production.socket}|fcgi://localhost" | |
104 | </FilesMatch> | |
105 | </Directory> | |
106 | '' | |
107 | ]; | |
108 | }; | |
109 | }; | |
110 | } |