X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=virtual%2Fmodules%2Fwebsites%2Ftellesflorian%2Ftellesflorian.nix;h=4237af859532d874c5823576e73cd61786e85101;hb=f406130d33a65afa5a4fb45fb3586ce97fd7b772;hp=2191b318e729cea7e9b49ef3ca6eeded74e4aade;hpb=a5365ec3d924a91abdd80c4f58d2158472788de9;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/virtual/modules/websites/tellesflorian/tellesflorian.nix b/virtual/modules/websites/tellesflorian/tellesflorian.nix index 2191b31..4237af8 100644 --- a/virtual/modules/websites/tellesflorian/tellesflorian.nix +++ b/virtual/modules/websites/tellesflorian/tellesflorian.nix @@ -1,27 +1,22 @@ -{ lib, checkEnv, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages }: +{ lib, writeText, fetchedGitPrivate, fetchurl, stdenv, composerEnv }: let - tellesflorian = { environment ? "dev" }: rec { - varPrefix = "TELLESFLORIAN"; + tellesflorian = { config }: rec { + environment = config.environment; varDir = "/var/lib/tellesflorian_${environment}"; - envName= lib.strings.toUpper environment; configRoot = - assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_PASSWORD"; - assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_USER"; - assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_NAME"; - assert checkEnv "NIXOPS_${varPrefix}_${envName}_SECRET"; writeText "parameters.yml" '' # This file is auto-generated during the composer install parameters: database_host: db-1.immae.eu database_port: null - database_name: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_NAME"} - database_user: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_USER"} - database_password: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_PASSWORD"} + database_name: ${config.mysql.name} + database_user: ${config.mysql.user} + database_password: ${config.mysql.password} mailer_transport: smtp mailer_host: mail.immae.eu mailer_user: null mailer_password: null - secret: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_SECRET"} + secret: ${config.secret} ''; phpFpm = rec { socket = "/var/run/phpfpm/floriantelles-${environment}.sock"; @@ -49,10 +44,8 @@ let pm.max_spare_servers = 3 ''}''; }; - passwords = - assert checkEnv "NIXOPS_${varPrefix}_${envName}_INVITE_PASSWORDS"; - writeText "tellesflorian_passwords" '' - invite:${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_INVITE_PASSWORDS"} + passwords = writeText "tellesflorian_passwords" '' + invite:${config.invite_passwords} ''; apache = { user = "wwwrun"; @@ -139,28 +132,22 @@ let fi ''; }; - webappDir = stdenv.mkDerivation (fetchedGitPrivate ./tellesflorian.json // rec { - buildPhase = '' - export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt - export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt - - ln -sf ${configRoot} app/config/parameters.yml - sed -i -e "/Incenteev..ParameterHandler..ScriptHandler::buildParameters/d" composer.json - ${if environment == "dev" then '' - composer install - '' else '' - SYMFONY_ENV=prod composer install --no-dev - ''} - rm -rf var - ln -sf ../../../../../${varDir}/var var - ''; - installPhase = '' - cp -a . $out - ''; - buildInputs = [ - php git cacert phpPackages.composer - ]; - }); + webappDir = composerEnv.buildPackage ( + import ./php-packages.nix { inherit composerEnv fetchurl; } // + fetchedGitPrivate ./tellesflorian.json // + rec { + noDev = (environment == "prod"); + preInstall = '' + export SYMFONY_ENV="${environment}" + ''; + postInstall = '' + cd $out + rm app/config/parameters.yml + ln -sf ${configRoot} app/config/parameters.yml + rm -rf var/{logs,cache} + ln -sf ../../../../../../${varDir}/var/{logs,cache,sessions} var/ + ''; + }); webRoot = "${webappDir}/web"; }; in