From 33e329430bdcc7ba051b3ee75f032aa604259ec9 Mon Sep 17 00:00:00 2001 From: Simon Parri Date: Mon, 15 Sep 2025 17:05:54 -0500 Subject: modules/apache: Add Apache configuration framework --- modules/apache/default.nix | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 modules/apache/default.nix (limited to 'modules/apache/default.nix') 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); + }; + }; +} -- cgit v1.2.3