activationScript = ''
install -m 0755 -o ${apache.user} -g ${apache.group} -d /var/lib/php/sessions/yourls
'';
- config = writeText "config.php" ''
+ keys.tools-yourls = {
+ destDir = "/run/keys/webapps";
+ user = apache.user;
+ group = apache.group;
+ permissions = "0400";
+ text = ''
<?php
define( 'YOURLS_DB_USER', '${env.mysql.user}' );
define( 'YOURLS_DB_PASS', '${env.mysql.password}' );
define( 'LDAPAUTH_USERCACHE_TYPE', 0);
'';
+ };
webRoot = stdenv.mkDerivation (fetchedGithub ./yourls.json // rec {
installPhase = ''
mkdir -p $out
cp -a */ *.php $out/
cp sample-robots.txt $out/robots.txt
- ln -sf ${config} $out/includes/config.php
+ ln -sf /run/keys/webapps/tools-yourls $out/includes/config.php
${builtins.concatStringsSep "\n" (
lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/user/plugins/${name}") plugins
)}
'';
});
- apache = {
+ apache = rec {
user = "wwwrun";
group = "wwwrun";
modules = [ "proxy_fcgi" ];
+ webappName = "tools_yourls";
+ root = "/run/current-system/webapps/${webappName}";
vhostConf = ''
- Alias /url "${webRoot}"
- <Directory "${webRoot}">
+ Alias /url "${root}"
+ <Directory "${root}">
<FilesMatch "\.php$">
SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
</FilesMatch>
'';
};
phpFpm = rec {
+ serviceDeps = [ "mysql.service" "openldap.service" "tools-yourls-key.service" ];
basedir = builtins.concatStringsSep ":" (
- [ webRoot config ]
+ [ webRoot "/run/keys/webapps/tools-yourls" ]
++ lib.attrsets.mapAttrsToList (name: value: value) plugins);
socket = "/var/run/phpfpm/yourls.sock";
pool = ''