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