From 91b75ffe45f2a5d7e148c92f53a4ba90ede8df77 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Tue, 24 Dec 2019 08:26:39 +0100 Subject: [PATCH] Add Richie website --- modules/private/default.nix | 1 + modules/private/environment.nix | 17 ++++ modules/private/websites/default.nix | 1 + modules/private/websites/emilia/richie.json | 14 +++ modules/private/websites/emilia/richie.nix | 101 ++++++++++++++++++++ 5 files changed, 134 insertions(+) create mode 100644 modules/private/websites/emilia/richie.json create mode 100644 modules/private/websites/emilia/richie.nix diff --git a/modules/private/default.nix b/modules/private/default.nix index 70d4b79..f768aed 100644 --- a/modules/private/default.nix +++ b/modules/private/default.nix @@ -25,6 +25,7 @@ set = { connexionswingProd = ./websites/connexionswing/production.nix; denisejeromeProd = ./websites/denisejerome/production.nix; emiliaProd = ./websites/emilia/production.nix; + richieProd = ./websites/emilia/richie.nix; florianApp = ./websites/florian/app.nix; florianInte = ./websites/florian/integration.nix; florianProd = ./websites/florian/production.nix; diff --git a/modules/private/environment.nix b/modules/private/environment.nix index 2aa8b5e..f0e39e9 100644 --- a/modules/private/environment.nix +++ b/modules/private/environment.nix @@ -1104,6 +1104,23 @@ in }; }; }; + richie = mkOption { + description = "Europe Richie configurations by environment"; + type = submodule { + options = { + mysql = mkMysqlOptions "Richie"; + smtp_mailer = mkOption { + description = "SMTP mailer configuration"; + type = submodule { + options = { + user = mkOption { type = str; description = "Username"; }; + password = mkOption { type = str; description = "Password"; }; + }; + }; + }; + }; + }; + }; tellesflorian = mkOption { description = "Tellesflorian configurations by environment"; type = diff --git a/modules/private/websites/default.nix b/modules/private/websites/default.nix index 16f02a7..3ac4cb5 100644 --- a/modules/private/websites/default.nix +++ b/modules/private/websites/default.nix @@ -238,6 +238,7 @@ in denisejerome.production.enable = true; emilia.production.enable = true; + emilia.richie_production.enable = true; florian.app.enable = true; florian.integration.enable = true; diff --git a/modules/private/websites/emilia/richie.json b/modules/private/websites/emilia/richie.json new file mode 100644 index 0000000..63aab6e --- /dev/null +++ b/modules/private/websites/emilia/richie.json @@ -0,0 +1,14 @@ +{ + "tag": "3e7b523-master", + "meta": { + "name": "richie", + "url": "ssh://gitolite@git.immae.eu/perso/Immae/Sites/Richie", + "branch": "master" + }, + "git": { + "url": "ssh://gitolite@git.immae.eu/perso/Immae/Sites/Richie", + "rev": "3e7b523dd1b47da10ec3c5b1b61df4034397a7b9", + "sha256": "04922nwprx6l0jn11mfcaxsfsxa96lq7dm170lk6q25fqr0ipa67", + "fetchSubmodules": true + } +} diff --git a/modules/private/websites/emilia/richie.nix b/modules/private/websites/emilia/richie.nix new file mode 100644 index 0000000..f7b4f8d --- /dev/null +++ b/modules/private/websites/emilia/richie.nix @@ -0,0 +1,101 @@ +{ lib, config, pkgs, ... }: +let + cfg = config.myServices.websites.emilia.richie_production; + vardir = "/var/lib/richie_production"; + richieSrc = pkgs.stdenv.mkDerivation (pkgs.mylibs.fetchedGitPrivate ./richie.json // { + phases = "installPhase"; + installPhase = '' + cp -a $src $out + chmod -R u+w $out + ln -sf ${vardir}/files $out/ + ln -sf ${vardir}/drapeaux $out/images/ + ln -sf ${vardir}/photos $out/ + sed -i "s@localedef --list-archive@localedef --list-archive /run/current-system/sw/lib/locale/locale-archive@" $out/admin/parametres.php + ''; + }); +in +{ + options.myServices.websites.emilia.richie_production.enable = lib.mkEnableOption "enable Richie's website"; + config = lib.mkIf cfg.enable { + services.duplyBackup.profiles.richie_production.rootDir = vardir; + services.webstats.sites = [ { name = "europe-richie.org"; } ]; + + secrets.keys = [{ + dest = "webapps/prod-richie"; + user = "wwwrun"; + group = "wwwrun"; + permissions = "0400"; + text = with config.myEnv.websites.richie; '' + Auth('${smtp_mailer.user}', '${smtp_mailer.password}'); + ?> + ''; + }]; + myServices.websites.webappDirs.richie_production = richieSrc; + system.activationScripts.richie_production = { + deps = [ "httpd" ]; + text = '' + install -m 0755 -o wwwrun -g wwwrun -d /var/lib/php/sessions/richie_production + install -m 0755 -o wwwrun -g wwwrun -d ${vardir} + ''; + }; + services.phpfpm.pools.richie_production = { + listen = "/run/phpfpm/richie_production.sock"; + extraConfig = '' + user = wwwrun + group = wwwrun + listen.owner = wwwrun + listen.group = wwwrun + + pm = ondemand + pm.max_children = 5 + pm.process_idle_timeout = 60 + + env[PATH] = /run/current-system/sw/bin:${lib.makeBinPath [ pkgs.imagemagick ]} + env[BDD_CONNECT] = "/var/secrets/webapps/prod-richie" + php_admin_value[open_basedir] = "${vardir}:/var/lib/php/sessions/richie_production:/var/secrets/webapps/prod-richie:${richieSrc}:/tmp" + php_admin_value[session.save_path] = "/var/lib/php/sessions/richie_production" + ''; + phpOptions = config.services.phpfpm.phpOptions + '' + date.timezone = 'Europe/Paris' + extension=${pkgs.php}/lib/php/extensions/mysqli.so + ''; + }; + services.websites.env.production.modules = [ "proxy_fcgi" ]; + services.websites.env.production.vhostConfs.richie_production = { + certName = "richie"; + addToCerts = true; + certMainHost = "europe-richie.org"; + hosts = [ "europe-richie.org" "www.europe-richie.org" ]; + root = "/run/current-system/webapps/richie_production"; + extraConfig = [ + '' + Use Stats europe-richie.org + ErrorDocument 404 /404.html + + Require all denied + + + DirectoryIndex index.php index.htm index.html + Options Indexes FollowSymLinks MultiViews Includes + AllowOverride None + Require all granted + + + SetHandler "proxy:unix:/run/phpfpm/richie_production.sock|fcgi://localhost" + + + '' + ]; + }; + }; +} -- 2.41.0