summaryrefslogtreecommitdiff
path: root/modules/apache/default.nix
diff options
context:
space:
mode:
authorSimon Parri <simonparri@ganzeria.com>2025-09-15 17:05:54 -0500
committerSimon Parri <simonparri@ganzeria.com>2025-09-15 17:07:32 -0500
commit33e329430bdcc7ba051b3ee75f032aa604259ec9 (patch)
tree1fe2cc1800e8c27eb24fa7abf21abd6a18430fd6 /modules/apache/default.nix
parent3df5e860ec36117db018311a34a3f1aa6c40ff76 (diff)
downloadnixos-config-33e329430bdcc7ba051b3ee75f032aa604259ec9.tar.gz
nixos-config-33e329430bdcc7ba051b3ee75f032aa604259ec9.zip
modules/apache: Add Apache configuration framework
Diffstat (limited to 'modules/apache/default.nix')
-rw-r--r--modules/apache/default.nix35
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);
+ };
+ };
+}