diff options
author | Simon Parri <simonparri@ganzeria.com> | 2025-09-15 17:05:54 -0500 |
---|---|---|
committer | Simon Parri <simonparri@ganzeria.com> | 2025-09-15 17:07:32 -0500 |
commit | 33e329430bdcc7ba051b3ee75f032aa604259ec9 (patch) | |
tree | 1fe2cc1800e8c27eb24fa7abf21abd6a18430fd6 | |
parent | 3df5e860ec36117db018311a34a3f1aa6c40ff76 (diff) | |
download | nixos-config-33e329430bdcc7ba051b3ee75f032aa604259ec9.tar.gz nixos-config-33e329430bdcc7ba051b3ee75f032aa604259ec9.zip |
modules/apache: Add Apache configuration framework
-rw-r--r-- | modules/apache/default.nix | 35 | ||||
-rw-r--r-- | modules/default.nix | 1 |
2 files changed, 36 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); + }; + }; +} diff --git a/modules/default.nix b/modules/default.nix index 06f0fb3..d2787ea 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -15,6 +15,7 @@ ./bluetooth.nix ./unfree.nix ./build-machines.nix + ./apache ./overlays ]; |