]>
Commit | Line | Data |
---|---|---|
91b75ffe IB |
1 | { lib, config, pkgs, ... }: |
2 | let | |
d3452fc5 | 3 | cfg = config.myServices.websites.richie.production; |
91b75ffe | 4 | vardir = "/var/lib/richie_production"; |
db343436 IB |
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; | |
91b75ffe IB |
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 | ''; | |
db343436 | 19 | }; |
d3452fc5 IB |
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; | |
91b75ffe IB |
24 | in |
25 | { | |
d3452fc5 | 26 | options.myServices.websites.richie.production.enable = lib.mkEnableOption "enable Richie's website"; |
91b75ffe IB |
27 | config = lib.mkIf cfg.enable { |
28 | services.duplyBackup.profiles.richie_production.rootDir = vardir; | |
5a61f6ad | 29 | services.duplyBackup.profiles.richie_production.remotes = ["eriomem" "ovh"]; |
91b75ffe IB |
30 | services.webstats.sites = [ { name = "europe-richie.org"; } ]; |
31 | ||
4c4652aa | 32 | secrets.keys."websites/richie/production" = { |
d3452fc5 IB |
33 | user = apacheUser; |
34 | group = apacheGroup; | |
91b75ffe IB |
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 | ''; | |
4c4652aa | 50 | }; |
d3452fc5 | 51 | services.websites.webappDirs.richie_production = richieSrc; |
91b75ffe IB |
52 | system.activationScripts.richie_production = { |
53 | deps = [ "httpd" ]; | |
54 | text = '' | |
d3452fc5 IB |
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} | |
91b75ffe IB |
57 | ''; |
58 | }; | |
59 | services.phpfpm.pools.richie_production = { | |
d3452fc5 IB |
60 | user = apacheUser; |
61 | group = apacheGroup; | |
5400b9b6 | 62 | settings = { |
d3452fc5 IB |
63 | "listen.owner" = apacheUser; |
64 | "listen.group" = apacheGroup; | |
91b75ffe | 65 | |
5400b9b6 IB |
66 | "pm" = "ondemand"; |
67 | "pm.max_children" = "5"; | |
68 | "pm.process_idle_timeout" = "60"; | |
91b75ffe | 69 | |
d3452fc5 | 70 | "php_admin_value[open_basedir]" = "${vardir}:/var/lib/php/sessions/richie_production:${secretPath}:${richieSrc}:/tmp"; |
5400b9b6 IB |
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 ]}"; | |
d3452fc5 | 75 | BDD_CONNECT = secretPath; |
5400b9b6 | 76 | }; |
91b75ffe IB |
77 | phpOptions = config.services.phpfpm.phpOptions + '' |
78 | date.timezone = 'Europe/Paris' | |
91b75ffe | 79 | ''; |
dcac3ec7 | 80 | phpPackage = pkgs.php72; |
91b75ffe IB |
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" ]; | |
d3452fc5 | 88 | root = webappdir; |
91b75ffe IB |
89 | extraConfig = [ |
90 | '' | |
91 | Use Stats europe-richie.org | |
92 | ErrorDocument 404 /404.html | |
93 | <LocationMatch "^/files/.*/admin/"> | |
94 | Require all denied | |
95 | </LocationMatch> | |
d3452fc5 | 96 | <Directory ${webappdir}> |
91b75ffe IB |
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$"> | |
5400b9b6 | 103 | SetHandler "proxy:unix:${config.services.phpfpm.pools.richie_production.socket}|fcgi://localhost" |
91b75ffe IB |
104 | </FilesMatch> |
105 | </Directory> | |
106 | '' | |
107 | ]; | |
108 | }; | |
109 | }; | |
110 | } |