From: Ismaƫl Bouya Date: Fri, 25 Jan 2019 07:37:18 +0000 (+0100) Subject: Add yourls X-Git-Tag: nur_publish~291 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FNix.git;a=commitdiff_plain;h=133ebaee701a52a74fc6897498f44f006ea3c3d8 Add yourls Fixes https://git.immae.eu/mantisbt/view.php?id=68 --- diff --git a/virtual/modules/websites/tools/tools/default.nix b/virtual/modules/websites/tools/tools/default.nix index 294959c..7fb4974 100644 --- a/virtual/modules/websites/tools/tools/default.nix +++ b/virtual/modules/websites/tools/tools/default.nix @@ -8,6 +8,10 @@ let }; roundcubemail = pkgs.callPackage ./roundcubemail.nix { env = myconfig.env.tools.roundcubemail; }; wallabag = pkgs.callPackage ./wallabag.nix { env = myconfig.env.tools.wallabag; }; + yourls = pkgs.callPackage ./yourls.nix { + inherit (mylibs) fetchedGithub; + env = myconfig.env.tools.yourls; + }; cfg = config.services.myWebsites.tools.tools; in { @@ -23,7 +27,8 @@ in { ++ ympd.apache.modules ++ ttrss.apache.modules ++ roundcubemail.apache.modules - ++ wallabag.apache.modules; + ++ wallabag.apache.modules + ++ yourls.apache.modules; services.ympd = ympd.config // { enable = false; }; @@ -37,6 +42,7 @@ in { ttrss.apache.vhostConf roundcubemail.apache.vhostConf wallabag.apache.vhostConf + yourls.apache.vhostConf ]; }; @@ -45,12 +51,14 @@ in { ttrss = ttrss.phpFpm.pool; roundcubemail = roundcubemail.phpFpm.pool; wallabag = wallabag.phpFpm.pool; + yourls = yourls.phpFpm.pool; }; system.activationScripts = { ttrss = ttrss.activationScript; roundcubemail = roundcubemail.activationScript; wallabag = wallabag.activationScript; + yourls = yourls.activationScript; }; systemd.services.tt-rss = { diff --git a/virtual/modules/websites/tools/tools/yourls-ldap-plugin.json b/virtual/modules/websites/tools/tools/yourls-ldap-plugin.json new file mode 100644 index 0000000..9411e4a --- /dev/null +++ b/virtual/modules/websites/tools/tools/yourls-ldap-plugin.json @@ -0,0 +1,15 @@ +{ + "tag": "2a3cb03-master", + "meta": { + "name": "yourls-ldap-plugin", + "url": "https://github.com/k3a/yourls-ldap-plugin", + "branch": "master" + }, + "github": { + "owner": "k3a", + "repo": "yourls-ldap-plugin", + "rev": "2a3cb0334b8a6b81b284a7196e614bbd2b2b1615", + "sha256": "0cchbnli77d295lzf7kjmn4dcxj2bmdqa9qc3f8l8qgmp4n5n0gh", + "fetchSubmodules": true + } +} diff --git a/virtual/modules/websites/tools/tools/yourls.json b/virtual/modules/websites/tools/tools/yourls.json new file mode 100644 index 0000000..0a79b18 --- /dev/null +++ b/virtual/modules/websites/tools/tools/yourls.json @@ -0,0 +1,15 @@ +{ + "tag": "1.7.3", + "meta": { + "name": "yourls", + "url": "https://github.com/YOURLS/YOURLS", + "branch": "refs/tags/1.7.3" + }, + "github": { + "owner": "YOURLS", + "repo": "YOURLS", + "rev": "077018822d3594229daa8343310d0b40804b9ddc", + "sha256": "1av6h619rwqn0yn0kjn2s2h3gmrhmxaaa9hd5ns4ralxgg731imd", + "fetchSubmodules": true + } +} diff --git a/virtual/modules/websites/tools/tools/yourls.nix b/virtual/modules/websites/tools/tools/yourls.nix new file mode 100644 index 0000000..b97dac9 --- /dev/null +++ b/virtual/modules/websites/tools/tools/yourls.nix @@ -0,0 +1,102 @@ +{ 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