services: nginx: use enable option

conditional enabling caused circular dependencies somehow
This commit is contained in:
Antoine Martin 2023-12-05 09:20:13 +01:00
parent 003d1c801d
commit 1bd88ce3df

View file

@ -9,12 +9,19 @@
}: let
inherit
(lib)
mkEnableOption
mkIf
;
cfg = config.my.services.nginx;
in {
options.my.services.nginx = {
enable = mkEnableOption "Nginx reverse proxy";
};
# Whenever something defines an nginx vhost, ensure that nginx defaults are
# properly set.
config = mkIf ((builtins.attrNames config.services.nginx.virtualHosts) != ["localhost"]) {
config = mkIf (cfg.enable) {
services.nginx = {
enable = true;
statusPage = true; # For monitoring scraping.