nixos/selfoss: fix work with phpfpm-rootless mode

This commit is contained in:
Izorkin 2019-06-15 19:09:31 +03:00
parent d44f759b55
commit 6290bf9067

View file

@ -3,9 +3,9 @@ with lib;
let let
cfg = config.services.selfoss; cfg = config.services.selfoss;
poolName = "selfoss_pool"; poolName = "selfoss";
phpfpmSocketName = "/run/phpfpm/${poolName}.sock"; phpfpmSocketName = "/run/phpfpm-${poolName}/${poolName}.sock";
group = "${cfg.user}";
dataDir = "/var/lib/selfoss"; dataDir = "/var/lib/selfoss";
selfoss-config = selfoss-config =
@ -116,21 +116,25 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.phpfpm.poolConfigs = mkIf (cfg.pool == "${poolName}") { services.phpfpm.pools = mkIf (cfg.pool == "${poolName}") {
"${poolName}" = '' "${poolName}" = {
listen = "${phpfpmSocketName}"; socketName = "${poolName}";
listen.owner = nginx phpPackage = pkgs.php;
listen.group = nginx user = "${cfg.user}";
listen.mode = 0600 group = "${group}";
user = nginx extraConfig = ''
pm = dynamic listen.owner = ${config.services.nginx.user}
pm.max_children = 75 listen.group = ${config.services.nginx.group}
pm.start_servers = 10 listen.mode = 0600
pm.min_spare_servers = 5 pm = dynamic
pm.max_spare_servers = 20 pm.max_children = 75
pm.max_requests = 500 pm.start_servers = 10
catch_workers_output = 1 pm.min_spare_servers = 5
''; pm.max_spare_servers = 20
pm.max_requests = 500
catch_workers_output = 1
'';
};
}; };
systemd.services.selfoss-config = { systemd.services.selfoss-config = {
@ -145,7 +149,7 @@ in
# Create the files # Create the files
cp -r "${pkgs.selfoss}/"* "${dataDir}" cp -r "${pkgs.selfoss}/"* "${dataDir}"
ln -sf "${selfoss-config}" "${dataDir}/config.ini" ln -sf "${selfoss-config}" "${dataDir}/config.ini"
chown -R "${cfg.user}" "${dataDir}" chown -R "${cfg.user}":"${group}" "${dataDir}"
chmod -R 755 "${dataDir}" chmod -R 755 "${dataDir}"
''; '';
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
@ -162,5 +166,8 @@ in
}; };
users.users.nginx = {
extraGroups = [ "${group}" ];
};
}; };
} }