{ lib, env, writeText, stdenv, fetchedGithub }:
let
yourls = let
plugins = {
ldap = stdenv.mkDerivation (fetchedGithub ./yourls-ldap-plugin.json // rec {
installPhase = ''
mkdir -p $out
cp plugin.php $out/
'';
});
};
in rec {
activationScript = ''
install -m 0755 -o ${apache.user} -g ${apache.group} -d /var/lib/php/sessions/yourls
'';
config = writeText "config.php" ''
SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
AllowOverride None
Require all granted
RewriteEngine On
RewriteBase /url/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /url/yourls-loader.php [L]
DirectoryIndex index.php
'';
};
phpFpm = rec {
basedir = builtins.concatStringsSep ":" (
[ webRoot config ]
++ lib.attrsets.mapAttrsToList (name: value: value) plugins);
socket = "/var/run/phpfpm/yourls.sock";
pool = ''
listen = ${socket}
user = ${apache.user}
group = ${apache.group}
listen.owner = ${apache.user}
listen.group = ${apache.group}
pm = ondemand
pm.max_children = 60
pm.process_idle_timeout = 60
; Needed to avoid clashes in browser cookies (same domain)
php_value[session.name] = YourlsPHPSESSID
php_admin_value[open_basedir] = "${basedir}:/tmp"
php_admin_value[session.save_path] = "/var/lib/php/sessions/yourls"
'';
};
};
in
yourls