1 { lib, pkgs, config, ... }:
3 secrets = config.myEnv.websites.ludivine.production;
4 app = pkgs.callPackage ./app {
5 composerEnv = pkgs.composerEnv.override { php = pkgs.php72; };
6 environment = secrets.environment;
7 varDir = "/var/lib/ludivine_production";
8 secretsPath = config.secrets.fullPaths."websites/ludivine/production";
10 pcfg = config.services.phpApplication;
11 cfg = config.myServices.websites.ludivine.production;
13 options.myServices.websites.ludivine.production.enable = lib.mkEnableOption "enable Ludivine's website in production";
15 config = lib.mkIf cfg.enable {
16 services.duplyBackup.profiles.ludivine_production.rootDir = app.varDir;
17 services.duplyBackup.profiles.ludivine_production.remotes = ["eriomem" "ovh"];
18 services.webstats.sites = [ { name = "ludivinecassal.com"; } ];
19 services.phpApplication.apps.ludivine_production = {
20 websiteEnv = "production";
21 httpdUser = config.services.httpd.Prod.user;
22 httpdGroup = config.services.httpd.Prod.group;
23 inherit (app) webRoot varDir;
28 serviceDeps = [ "mysql.service" ];
30 "./bin/console --env=${app.environment} cache:clear --no-warmup"
32 phpOpenbasedir = [ "/tmp" ];
34 "php_admin_value[upload_max_filesize]" = "20M";
35 "php_admin_value[post_max_size]" = "20M";
36 #"php_admin_flag[log_errors]" = "on";
38 "pm.max_children" = "20";
39 "pm.start_servers" = "2";
40 "pm.min_spare_servers" = "1";
41 "pm.max_spare_servers" = "3";
44 config.secrets.fullPaths."websites/ludivine/production"
47 PATH = lib.makeBinPath [
48 # below ones don't need to be in the PATH but they’re used in
50 pkgs.imagemagick pkgs.sass pkgs.ruby
53 phpPackage = pkgs.php72;
56 secrets.keys."websites/ludivine/production" = {
57 user = config.services.httpd.Prod.user;
58 group = config.services.httpd.Prod.group;
61 # This file is auto-generated during the composer install
63 database_host: ${secrets.mysql.host}
64 database_port: ${secrets.mysql.port}
65 database_name: ${secrets.mysql.database}
66 database_user: ${secrets.mysql.user}
67 database_password: ${secrets.mysql.password}
68 database_server_version: ${pkgs.mariadb.mysqlVersion}
69 mailer_transport: smtp
70 mailer_host: 127.0.0.1
73 secret: ${secrets.secret}
74 ldap_host: ldap.immae.eu
79 ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu'
80 ldap_base_dn: 'dc=immae,dc=eu'
81 ldap_search_dn: '${secrets.ldap.dn}'
82 ldap_search_password: '${secrets.ldap.password}'
83 ldap_search_filter: '${secrets.ldap.filter}'
85 binary_path: ${pkgs.imagemagick}/bin
87 sass: ${pkgs.sass}/bin/sass
88 ruby: ${pkgs.ruby}/bin/ruby
92 services.websites.env.production.vhostConfs.ludivine_production = {
93 certName = "ludivine";
94 certMainHost = "ludivinecassal.com";
95 hosts = ["ludivinecassal.com" "www.ludivinecassal.com" ];
100 RewriteCond "%{HTTP_HOST}" "!^ludivinecassal\.com$" [NC]
101 RewriteRule ^(.+)$ https://ludivinecassal.com$1 [R=302,L]
103 <FilesMatch "\.php$">
104 SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivine_production}|fcgi://localhost"
107 Use Stats ludivinecassal.com
109 <Directory ${app.webRoot}>
110 Options Indexes FollowSymLinks MultiViews Includes