diff options
Diffstat (limited to 'modules/apache/default.nix')
-rw-r--r-- | modules/apache/default.nix | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/modules/apache/default.nix b/modules/apache/default.nix new file mode 100644 index 0000000..d581aca --- /dev/null +++ b/modules/apache/default.nix @@ -0,0 +1,35 @@ +{ 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"; + virtualHosts = mergeAttrsList (map + (name: { "${name}" = + { extraConfig = readFile ./${name}.conf; } + // (if pathExists ./${name}.nix + then import ./${name}.nix { inherit lib pkgs config; } + else {});}) + cfg.vhosts); + }; + }; +} |