blob: 9d4579cc8f6a7f967a1ae4b6751d0c79102b3d79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
{ lib, pkgs, config, ... }:
let
cfg = config.this.apache;
inherit (lib.attrsets)
mergeAttrsList;
inherit (builtins)
map readFile pathExists;
in
{
options = {
this.apache = {
enable = lib.mkEnableOption "the Apache HTTP Server";
vhosts = lib.mkOption {
type = with lib.types; listOf str;
default = [];
};
};
};
config = lib.mkIf cfg.enable {
services.httpd = {
enable = true;
logPerVirtualHost = false;
logDir = "/var/log/apache2";
extraModules = ["userdir"];
virtualHosts = mergeAttrsList (map
(name: { "${name}" =
{ extraConfig = readFile ./${name}.conf; }
// (if pathExists ./${name}.nix
then import ./${name}.nix { inherit lib pkgs config; }
else {});})
cfg.vhosts);
};
};
}
|