-{ lib, checkEnv, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages, texlive, imagemagick }:
+{ pkgs, lib, writeText, fetchedGitPrivate, stdenv, composerEnv, fetchurl, fetchgit, texlive, imagemagick }:
let
- piedsjaloux = { environment ? "dev" }: rec {
- varPrefix = "PIEDSJALOUX";
+ piedsjaloux = { config }: rec {
+ environment = config.environment;
varDir = "/var/lib/piedsjaloux_${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}
+ database_server_version: ${pkgs.mariadb.mysqlVersion}
mailer_transport: smtp
mailer_host: mail.immae.eu
mailer_user: null
mailer_password: null
- secret: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_SECRET"}
+ secret: ${config.secret}
pdflatex: "${texlive.combine { inherit (texlive) attachfile preprint scheme-small; }}/bin/pdflatex"
leapt_im:
binary_path: ${imagemagick}/bin
fi
'';
};
- webappDir = stdenv.mkDerivation (fetchedGitPrivate ./piedsjaloux.json // rec {
- # FIXME: can we do better than symlink?
- # FIXME: initial sync
- # FIXME: backup
- # FIXME: miniatures and data need to be in the same dir due to a
- # bug in leapt.im (searches for data/../miniatures)
- # FIXME: var/bootstrap.php.cache doesn't get created
- # (cannot work with var as a symlink since the file
- # references ..)
- # FIXME: configuration change should not trigger a rebuild
- 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
- '';
- installPhase = ''
- cp -a . $out
- '';
- buildInputs = [
- php git cacert phpPackages.composer
- ];
- });
+ webappDir = composerEnv.buildPackage (
+ import ./php-packages.nix { inherit composerEnv fetchurl fetchgit; } //
+ fetchedGitPrivate ./piedsjaloux.json //
+ rec {
+ noDev = (environment == "prod");
+ preInstall = ''
+ export SYMFONY_ENV="${environment}"
+ '';
+ # /!\ miniatures and data need to be in the same physical dir due to a
+ # bug in leapt.im (searches for data/../miniatures)
+ postInstall = ''
+ cd $out
+ rm app/config/parameters.yml
+ ln -sf ${configRoot} app/config/parameters.yml
+ rm -rf var/{logs,cache,data,miniatures,tmp}
+ ln -sf ../../../../../../../${varDir}/{logs,cache,data,miniatures,tmp} var/
+ '';
+ });
webRoot = "${webappDir}/web";
};
in