X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=nixops%2Fmodules%2Fwebsites%2Fphpfpm%2Fdefault.nix;h=60959e08e9812f0c4a228125146f08cdb14ccaaa;hb=1480d60775dcd38b33abd367a91cd1b865aacc54;hp=3c6f027ad8dc898903c574cce1f4e2e6e4898eaf;hpb=01f21083a897b86bf148f1d2bb9c8edca4d3786a;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/nixops/modules/websites/phpfpm/default.nix b/nixops/modules/websites/phpfpm/default.nix index 3c6f027..60959e0 100644 --- a/nixops/modules/websites/phpfpm/default.nix +++ b/nixops/modules/websites/phpfpm/default.nix @@ -72,6 +72,43 @@ in { "Options appended to the PHP configuration file php.ini."; }; + serviceDependencies = mkOption { + default = {}; + type = types.attrsOf (types.listOf types.string); + example = literalExample '' + { mypool = ["postgresql.service"]; } + ''; + description = '' + Extra service dependencies specific to pool. + ''; + }; + + envFile = mkOption { + default = {}; + type = types.attrsOf types.string; + example = literalExample '' + { mypool = "path/to/file"; + } + ''; + description = '' + Extra environment file go into the service script. + ''; + }; + + preStart = mkOption { + default = {}; + type = types.attrsOf types.lines; + example = literalExample '' + { mypool = ''' + touch foo + '''; + } + ''; + description = '' + Extra lines that will go into the preStart systemd service + ''; + }; + poolPhpConfigs = mkOption { default = {}; type = types.attrsOf types.lines; @@ -152,16 +189,18 @@ in { systemd.services = flip mapAttrs' poolConfigs (pool: poolConfig: nameValuePair "phpfpm-${pool}" { description = "PHP FastCGI Process Manager service for pool ${pool}"; - after = [ "network.target" ]; + after = [ "network.target" ] ++ (cfg.serviceDependencies.${pool} or []); + wants = cfg.serviceDependencies.${pool} or []; wantedBy = [ "phpfpm.target" ]; partOf = [ "phpfpm.target" ]; preStart = '' mkdir -p ${stateDir} - ''; + '' + (cfg.preStart.${pool} or ""); serviceConfig = let cfgFile = fpmCfgFile pool poolConfig; poolPhpIni = cfg.poolPhpConfigs.${pool} or ""; in { + EnvironmentFile = if builtins.hasAttr pool cfg.envFile then [cfg.envFile.${pool}] else []; Slice = "phpfpm.slice"; PrivateDevices = true; ProtectSystem = "full";