From fb7f2ad86ebdee514b3b361aa5615e333ac66780 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 2 Jun 2019 14:31:25 +0200 Subject: [PATCH] Move florian php configuration to dedicated module --- modules/websites/php-application.nix | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/websites/php-application.nix b/modules/websites/php-application.nix index 1bc4872e..8ad7a0df 100644 --- a/modules/websites/php-application.nix +++ b/modules/websites/php-application.nix @@ -19,6 +19,13 @@ in Path to application’s vardir. ''; }; + varDirPaths = mkOption { + type = attrsOf str; + default = {}; + description = '' + Map of additional folders => mode to create under varDir + ''; + }; mode = mkOption { type = str; default = "0700"; @@ -163,7 +170,7 @@ in listen.group = ${icfg.httpdGroup} ${optionalString (icfg.phpSession) '' php_admin_value[session.save_path] = "${icfg.varDir}/phpSessions"''} - php_admin_value[open_basedir] = "${builtins.concatStringsSep ":" ([icfg.app icfg.varDir] ++ icfg.phpOpenbasedir)}" + php_admin_value[open_basedir] = "${builtins.concatStringsSep ":" ([icfg.app icfg.varDir] ++ icfg.phpWatchFiles ++ icfg.phpOpenbasedir)}" '' + icfg.phpPool; phpOptions = config.services.phpfpm.phpOptions + icfg.phpOptions; } @@ -173,6 +180,13 @@ in (if icfg.webappName == null then name else icfg.webappName) icfg.webRoot ) (attrsets.filterAttrs (n: v: !isNull v.webRoot) cfg.apps); + services.filesWatcher = attrsets.mapAttrs' (name: icfg: attrsets.nameValuePair + "phpfpm-${name}" { + restart = true; + paths = icfg.phpWatchFiles; + } + ) (attrsets.filterAttrs (n: v: builtins.length v.phpWatchFiles > 0) cfg.apps); + systemd.services = attrsets.mapAttrs' (name: icfg: attrsets.nameValuePair "phpfpm-${name}" { after = lib.mkAfter icfg.serviceDeps; @@ -210,7 +224,9 @@ in install -m ${icfg.mode} -o ${icfg.httpdUser} -g ${icfg.httpdGroup} -d ${icfg.varDir} '' + optionalString (icfg.phpSession) '' install -m 0700 -o ${icfg.httpdUser} -g ${icfg.httpdGroup} -d ${icfg.varDir}/phpSessions - ''; + '' + builtins.concatStringsSep "\n" (attrsets.mapAttrsToList (n: v: '' + install -m ${v} -o ${icfg.httpdUser} -g ${icfg.httpdGroup} -d ${icfg.varDir}/${n} + '') icfg.varDirPaths); } ) cfg.apps; }; -- 2.41.0