mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-10 16:45:51 +03:00
nixos/awstats: replace usage of deprecated services.httpd.extraSubservices
This commit is contained in:
parent
31a577c736
commit
ac4327c025
@ -4,6 +4,7 @@ with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.awstats;
|
||||
httpd = config.services.httpd;
|
||||
package = pkgs.awstats;
|
||||
in
|
||||
|
||||
@ -67,29 +68,32 @@ in
|
||||
environment.etc."awstats/awstats.conf".source = pkgs.runCommand "awstats.conf"
|
||||
{ preferLocalBuild = true; }
|
||||
( let
|
||||
cfg-httpd = config.services.httpd;
|
||||
logFormat =
|
||||
if cfg-httpd.logFormat == "combined" then "1" else
|
||||
if cfg-httpd.logFormat == "common" then "4" else
|
||||
throw "awstats service doesn't support Apache log format `${cfg-httpd.logFormat}`";
|
||||
if httpd.logFormat == "combined" then "1" else
|
||||
if httpd.logFormat == "common" then "4" else
|
||||
throw "awstats service doesn't support Apache log format `${httpd.logFormat}`";
|
||||
in
|
||||
''
|
||||
sed \
|
||||
-e 's|^\(DirData\)=.*$|\1="${cfg.vardir}"|' \
|
||||
-e 's|^\(DirIcons\)=.*$|\1="icons"|' \
|
||||
-e 's|^\(CreateDirDataIfNotExists\)=.*$|\1=1|' \
|
||||
-e 's|^\(SiteDomain\)=.*$|\1="${cfg-httpd.hostName}"|' \
|
||||
-e 's|^\(LogFile\)=.*$|\1="${cfg-httpd.logDir}/access_log"|' \
|
||||
-e 's|^\(SiteDomain\)=.*$|\1="${httpd.hostName}"|' \
|
||||
-e 's|^\(LogFile\)=.*$|\1="${httpd.logDir}/access_log"|' \
|
||||
-e 's|^\(LogFormat\)=.*$|\1=${logFormat}|' \
|
||||
< '${package.out}/wwwroot/cgi-bin/awstats.model.conf' > "$out"
|
||||
echo '${cfg.extraConfig}' >> "$out"
|
||||
'');
|
||||
|
||||
systemd.tmpfiles.rules = optionals cfg.service.enable [
|
||||
"d '${cfg.vardir}' - ${httpd.user} ${httpd.group} - -"
|
||||
"Z '${cfg.vardir}' - ${httpd.user} ${httpd.group} - -"
|
||||
];
|
||||
|
||||
# The httpd sub-service showing awstats.
|
||||
services.httpd.enable = mkIf cfg.service.enable true;
|
||||
services.httpd.extraSubservices = mkIf cfg.service.enable [ { function = { serverInfo, ... }: {
|
||||
extraConfig =
|
||||
''
|
||||
services.httpd = optionalAttrs cfg.service.enable {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
Alias ${cfg.service.urlPrefix}/classes "${package.out}/wwwroot/classes/"
|
||||
Alias ${cfg.service.urlPrefix}/css "${package.out}/wwwroot/css/"
|
||||
Alias ${cfg.service.urlPrefix}/icons "${package.out}/wwwroot/icon/"
|
||||
@ -97,20 +101,10 @@ in
|
||||
|
||||
<Directory "${package.out}/wwwroot">
|
||||
Options None
|
||||
AllowOverride None
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
Require all granted
|
||||
</Directory>
|
||||
'';
|
||||
startupScript =
|
||||
let
|
||||
inherit (serverInfo.serverConfig) user group;
|
||||
in pkgs.writeScript "awstats_startup.sh"
|
||||
''
|
||||
mkdir -p '${cfg.vardir}'
|
||||
chown '${user}:${group}' '${cfg.vardir}'
|
||||
'';
|
||||
};}];
|
||||
};
|
||||
|
||||
systemd.services.awstats-update = mkIf (cfg.updateAt != null) {
|
||||
description = "awstats log collector";
|
||||
|
Loading…
Reference in New Issue
Block a user