Skip to content

Commit

Permalink
Merge pull request #66492 from aanderse/extra-subservice-cleanup
Browse files Browse the repository at this point in the history
nixos/httpd: extraSubservices cleanup
  • Loading branch information
aanderse authored Aug 20, 2019
2 parents b15d868 + efbdce2 commit 249b4ad
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 377 deletions.
10 changes: 10 additions & 0 deletions nixos/doc/manual/release-notes/rl-1909.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@
<literal>false</literal>.
</para>
</listitem>
<listitem>
<para>
The <option>services.systemhealth</option> module has been removed from nixpkgs due to lack of maintainer.
</para>
</listitem>
<listitem>
<para>
The <option>services.mantisbt</option> module has been removed from nixpkgs due to lack of maintainer.
</para>
</listitem>
</itemizedlist>
</section>

Expand Down
2 changes: 0 additions & 2 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@
./services/misc/logkeys.nix
./services/misc/leaps.nix
./services/misc/lidarr.nix
./services/misc/mantisbt.nix
./services/misc/mathics.nix
./services/misc/matrix-synapse.nix
./services/misc/mbpfan.nix
Expand Down Expand Up @@ -522,7 +521,6 @@
./services/monitoring/scollector.nix
./services/monitoring/smartd.nix
./services/monitoring/sysstat.nix
./services/monitoring/systemhealth.nix
./services/monitoring/teamviewer.nix
./services/monitoring/telegraf.nix
./services/monitoring/thanos.nix
Expand Down
54 changes: 24 additions & 30 deletions nixos/modules/services/logging/awstats.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ with lib;

let
cfg = config.services.awstats;
httpd = config.services.httpd;
package = pkgs.awstats;
in

Expand Down Expand Up @@ -67,50 +68,43 @@ 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 =
''
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/"
ScriptAlias ${cfg.service.urlPrefix}/ "${package.out}/wwwroot/cgi-bin/"
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/"
ScriptAlias ${cfg.service.urlPrefix}/ "${package.out}/wwwroot/cgi-bin/"
<Directory "${package.out}/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
'';
startupScript =
let
inherit (serverInfo.serverConfig) user group;
in pkgs.writeScript "awstats_startup.sh"
''
mkdir -p '${cfg.vardir}'
chown '${user}:${group}' '${cfg.vardir}'
'';
};}];
<Directory "${package.out}/wwwroot">
Options None
Require all granted
</Directory>
'';
};

systemd.services.awstats-update = mkIf (cfg.updateAt != null) {
description = "awstats log collector";
Expand Down
68 changes: 0 additions & 68 deletions nixos/modules/services/misc/mantisbt.nix

This file was deleted.

133 changes: 0 additions & 133 deletions nixos/modules/services/monitoring/systemhealth.nix

This file was deleted.

41 changes: 18 additions & 23 deletions nixos/tests/php-pcre.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,25 @@ import ./make-test.nix ({ ...}: {
services.httpd = {
enable = true;
adminAddr = "please@dont.contact";
extraSubservices = lib.singleton {
function = f: {
enablePHP = true;
phpOptions = "pcre.jit = true";
enablePHP = true;
phpOptions = "pcre.jit = true";
extraConfig =
let
testRoot = pkgs.writeText "index.php"
''
<?php
preg_match('/(${testString})/', '${testString}', $result);
var_dump($result);
?>
'';
in
''
Alias / ${testRoot}/
extraConfig =
let
testRoot = pkgs.writeText "index.php"
''
<?php
preg_match('/(${testString})/', '${testString}', $result);
var_dump($result);
?>
'';
in
''
Alias / ${testRoot}/
<Directory ${testRoot}>
Require all granted
</Directory>
'';
};
};
<Directory ${testRoot}>
Require all granted
</Directory>
'';
};
};
testScript = { ... }:
Expand Down
Loading

0 comments on commit 249b4ad

Please sign in to comment.