diff --git a/docs/redirects.json b/docs/redirects.json index 08abc53..8d05b93 100644 --- a/docs/redirects.json +++ b/docs/redirects.json @@ -431,6 +431,9 @@ "blocks-borgbackup-options-shb.borgbackup.databases._name_.settings.stateDir": [ "blocks-borgbackup.html#blocks-borgbackup-options-shb.borgbackup.databases._name_.settings.stateDir" ], + "blocks-borgbackup-options-shb.borgbackup.enableDashboard": [ + "blocks-borgbackup.html#blocks-borgbackup-options-shb.borgbackup.enableDashboard" + ], "blocks-borgbackup-options-shb.borgbackup.instances": [ "blocks-borgbackup.html#blocks-borgbackup-options-shb.borgbackup.instances" ], @@ -950,6 +953,9 @@ "blocks-monitoring-options-shb.monitoring.contactPoints": [ "blocks-monitoring.html#blocks-monitoring-options-shb.monitoring.contactPoints" ], + "blocks-monitoring-options-shb.monitoring.dashboards": [ + "blocks-monitoring.html#blocks-monitoring-options-shb.monitoring.dashboards" + ], "blocks-monitoring-options-shb.monitoring.debugLog": [ "blocks-monitoring.html#blocks-monitoring-options-shb.monitoring.debugLog" ], @@ -1376,6 +1382,9 @@ "blocks-restic-options-shb.restic.databases._name_.settings.retention": [ "blocks-restic.html#blocks-restic-options-shb.restic.databases._name_.settings.retention" ], + "blocks-restic-options-shb.restic.enableDashboard": [ + "blocks-restic.html#blocks-restic-options-shb.restic.enableDashboard" + ], "blocks-restic-options-shb.restic.instances": [ "blocks-restic.html#blocks-restic-options-shb.restic.instances" ], @@ -1661,6 +1670,9 @@ "blocks-ssl-options-shb.certs.certs.selfsigned._name_.systemdService": [ "blocks-ssl.html#blocks-ssl-options-shb.certs.certs.selfsigned._name_.systemdService" ], + "blocks-ssl-options-shb.certs.enableDashboard": [ + "blocks-ssl.html#blocks-ssl-options-shb.certs.enableDashboard" + ], "blocks-ssl-options-shb.certs.systemdService": [ "blocks-ssl.html#blocks-ssl-options-shb.certs.systemdService" ], @@ -4535,6 +4547,9 @@ "services-nextcloudserver-options-shb.nextcloud.enable": [ "services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.enable" ], + "services-nextcloudserver-options-shb.nextcloud.enableDashboard": [ + "services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.enableDashboard" + ], "services-nextcloudserver-options-shb.nextcloud.externalFqdn": [ "services-nextcloud.html#services-nextcloudserver-options-shb.nextcloud.externalFqdn" ], diff --git a/modules/blocks/monitoring/dashboards/Backups.json b/modules/blocks/backup/dashboard/Backups.json similarity index 100% rename from modules/blocks/monitoring/dashboards/Backups.json rename to modules/blocks/backup/dashboard/Backups.json diff --git a/modules/blocks/borgbackup.nix b/modules/blocks/borgbackup.nix index a7548d1..55c687b 100644 --- a/modules/blocks/borgbackup.nix +++ b/modules/blocks/borgbackup.nix @@ -158,9 +158,14 @@ in { imports = [ ../../lib/module.nix + ../blocks/monitoring.nix ]; options.shb.borgbackup = { + enableDashboard = lib.mkEnableOption "the Backups SHB dashboard" // { + default = true; + }; + instances = mkOption { description = "Files to backup following the [backup contract](./shb.contracts-backup.html)."; default = { }; @@ -525,6 +530,12 @@ in in flatten (mapAttrsToList mkBorgBackupBinary cfg.databases); } + + (lib.mkIf (cfg.enableDashboard && (cfg.instances != { } || cfg.databases != { })) { + shb.monitoring.dashboards = [ + ./backup/dashboard/Backups.json + ]; + }) ] ); } diff --git a/modules/blocks/monitoring.nix b/modules/blocks/monitoring.nix index f6fb5c8..4aad94b 100644 --- a/modules/blocks/monitoring.nix +++ b/modules/blocks/monitoring.nix @@ -306,13 +306,9 @@ in (lib.mkIf cfg.enable { shb.monitoring.dashboards = [ - ./monitoring/dashboards/Backups.json ./monitoring/dashboards/Errors.json - ./monitoring/dashboards/Nextcloud.json ./monitoring/dashboards/Performance.json ./monitoring/dashboards/Scraping_Jobs.json - ./monitoring/dashboards/SSL.json - ./monitoring/dashboards/Torrents.json ]; services.grafana.provision = { diff --git a/modules/blocks/restic.nix b/modules/blocks/restic.nix index 4a17eb4..54c8c85 100644 --- a/modules/blocks/restic.nix +++ b/modules/blocks/restic.nix @@ -149,9 +149,14 @@ in { imports = [ ../../lib/module.nix + ../blocks/monitoring.nix ]; options.shb.restic = { + enableDashboard = lib.mkEnableOption "the Backups SHB dashboard" // { + default = true; + }; + instances = mkOption { description = "Files to backup following the [backup contract](./shb.contracts-backup.html)."; default = { }; @@ -506,6 +511,12 @@ in in flatten (mapAttrsToList mkResticBinary cfg.databases); } + + (lib.mkIf (cfg.enableDashboard && (cfg.instances != { } || cfg.databases != { })) { + shb.monitoring.dashboards = [ + ./backup/dashboard/Backups.json + ]; + }) ] ); } diff --git a/modules/blocks/ssl.nix b/modules/blocks/ssl.nix index 5321d3d..859d5ee 100644 --- a/modules/blocks/ssl.nix +++ b/modules/blocks/ssl.nix @@ -21,6 +21,7 @@ in { imports = [ ../../lib/module.nix + ./monitoring.nix ]; options.shb.certs = { @@ -31,6 +32,9 @@ in type = lib.types.str; default = "shb-ca-bundle.service"; }; + enableDashboard = lib.mkEnableOption "the SSL SHB dashboard" // { + default = true; + }; cas.selfsigned = lib.mkOption { description = "Generate a self-signed Certificate Authority."; default = { }; @@ -662,5 +666,10 @@ in in optionals (cfg.certs.letsencrypt != { }) (flatten (mapAttrsToList scrapeCfg cfg.certs.letsencrypt)); } + (lib.mkIf (cfg.enableDashboard && (cfg.certs.selfsigned != { } || cfg.certs.letsencrypt != { })) { + shb.monitoring.dashboards = [ + ./ssl/dashboard/SSL.json + ]; + }) ]; } diff --git a/modules/blocks/monitoring/dashboards/SSL.json b/modules/blocks/ssl/dashboard/SSL.json similarity index 100% rename from modules/blocks/monitoring/dashboards/SSL.json rename to modules/blocks/ssl/dashboard/SSL.json diff --git a/modules/services/deluge.nix b/modules/services/deluge.nix index dd2f678..53f99af 100644 --- a/modules/services/deluge.nix +++ b/modules/services/deluge.nix @@ -30,10 +30,15 @@ in imports = [ ../../lib/module.nix ../blocks/nginx.nix + ../blocks/monitoring.nix ]; options.shb.deluge = { - enable = lib.mkEnableOption "selfhostblocks.deluge"; + enable = lib.mkEnableOption "the SHB Deluge service"; + + enableDashboard = lib.mkEnableOption "the Torrents SHB dashboard" // { + default = true; + }; subdomain = lib.mkOption { type = lib.types.str; @@ -452,6 +457,12 @@ in } ]; }) + + (lib.mkIf (cfg.enable && cfg.enableDashboard) { + shb.monitoring.dashboards = [ + ./deluge/dashboard/Torrents.json + ]; + }) ] ); } diff --git a/modules/blocks/monitoring/dashboards/Torrents.json b/modules/services/deluge/dashboard/Torrents.json similarity index 100% rename from modules/blocks/monitoring/dashboards/Torrents.json rename to modules/services/deluge/dashboard/Torrents.json diff --git a/modules/services/nextcloud-server.nix b/modules/services/nextcloud-server.nix index 0196c49..6cd6fe0 100644 --- a/modules/services/nextcloud-server.nix +++ b/modules/services/nextcloud-server.nix @@ -28,10 +28,16 @@ in { imports = [ ../../lib/module.nix + ../blocks/authelia.nix + ../blocks/monitoring.nix ]; options.shb.nextcloud = { - enable = lib.mkEnableOption "selfhostblocks.nextcloud-server"; + enable = lib.mkEnableOption "the SHB Nextcloud service"; + + enableDashboard = lib.mkEnableOption "the Nextcloud SHB dashboard" // { + default = true; + }; subdomain = lib.mkOption { type = lib.types.str; @@ -1347,5 +1353,11 @@ in ''; } )) + + (lib.mkIf (cfg.enable && cfg.enableDashboard) { + shb.monitoring.dashboards = [ + ./nextcloud-server/dashboard/Nextcloud.json + ]; + }) ]; } diff --git a/modules/blocks/monitoring/dashboards/Nextcloud.json b/modules/services/nextcloud-server/dashboard/Nextcloud.json similarity index 100% rename from modules/blocks/monitoring/dashboards/Nextcloud.json rename to modules/services/nextcloud-server/dashboard/Nextcloud.json