From b44b42a15197813060bf9405d5a07b8b2c699af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Tue, 7 May 2019 09:06:29 +0200 Subject: Move yourls to pkgs --- nixops/modules/websites/tools/tools/default.nix | 2 +- .../websites/tools/tools/yourls-ldap-plugin.json | 15 -- nixops/modules/websites/tools/tools/yourls.json | 15 -- nixops/modules/websites/tools/tools/yourls.nix | 191 +++++++++------------ 4 files changed, 86 insertions(+), 137 deletions(-) delete mode 100644 nixops/modules/websites/tools/tools/yourls-ldap-plugin.json delete mode 100644 nixops/modules/websites/tools/tools/yourls.json (limited to 'nixops/modules/websites/tools') diff --git a/nixops/modules/websites/tools/tools/default.nix b/nixops/modules/websites/tools/tools/default.nix index 262e558..746119b 100644 --- a/nixops/modules/websites/tools/tools/default.nix +++ b/nixops/modules/websites/tools/tools/default.nix @@ -18,7 +18,7 @@ let }; wallabag = pkgs.callPackage ./wallabag.nix { env = myconfig.env.tools.wallabag; }; yourls = pkgs.callPackage ./yourls.nix { - inherit (mylibs) fetchedGithub; + inherit (pkgs.webapps) yourls yourls-plugins; env = myconfig.env.tools.yourls; }; rompr = pkgs.callPackage ./rompr.nix { diff --git a/nixops/modules/websites/tools/tools/yourls-ldap-plugin.json b/nixops/modules/websites/tools/tools/yourls-ldap-plugin.json deleted file mode 100644 index 9411e4a..0000000 --- a/nixops/modules/websites/tools/tools/yourls-ldap-plugin.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "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/nixops/modules/websites/tools/tools/yourls.json b/nixops/modules/websites/tools/tools/yourls.json deleted file mode 100644 index 0a79b18..0000000 --- a/nixops/modules/websites/tools/tools/yourls.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "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/nixops/modules/websites/tools/tools/yourls.nix b/nixops/modules/websites/tools/tools/yourls.nix index 470fb7b..df1b3a2 100644 --- a/nixops/modules/websites/tools/tools/yourls.nix +++ b/nixops/modules/websites/tools/tools/yourls.nix @@ -1,111 +1,90 @@ -{ 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 - ''; - keys = [{ - dest = "webapps/tools-yourls"; - user = apache.user; - group = apache.group; - permissions = "0400"; - text = '' - - - SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" - + define( 'LDAPAUTH_USERCACHE_TYPE', 0); + ''; + }]; + webRoot = (yourls.override { yourls_config = "/var/secrets/webapps/tools-yourls"; }).withPlugins + (builtins.attrValues yourls-plugins); + apache = rec { + user = "wwwrun"; + group = "wwwrun"; + modules = [ "proxy_fcgi" ]; + webappName = "tools_yourls"; + root = "/run/current-system/webapps/${webappName}"; + vhostConf = '' + Alias /url "${root}" + + + 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 { - serviceDeps = [ "mysql.service" "openldap.service" ]; - basedir = builtins.concatStringsSep ":" ( - [ webRoot "/var/secrets/webapps/tools-yourls" ] - ++ 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 + 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 { + serviceDeps = [ "mysql.service" "openldap.service" ]; + basedir = builtins.concatStringsSep ":" ( + [ webRoot "/var/secrets/webapps/tools-yourls" ] + ++ webRoot.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:/var/lib/php/sessions/yourls" - php_admin_value[session.save_path] = "/var/lib/php/sessions/yourls" - ''; - }; + ; Needed to avoid clashes in browser cookies (same domain) + php_value[session.name] = YourlsPHPSESSID + php_admin_value[open_basedir] = "${basedir}:/tmp:/var/lib/php/sessions/yourls" + php_admin_value[session.save_path] = "/var/lib/php/sessions/yourls" + ''; }; -in - yourls +} -- cgit v1.2.3