1- { config , lib , ... } :
1+ { flake , config , lib , ... } :
22
33with lib ;
44
5- {
5+ let nixosConfig = config ;
6+ in {
67 options . provides = mkOption {
7- type = types . attrsOf ( types . submodule {
8+ type = types . attrsOf ( types . submodule ( { config , ... } : {
89 options = {
910 name = mkOption {
1011 type = types . str ;
@@ -17,7 +18,7 @@ with lib;
1718 host = mkOption {
1819 type = types . str ;
1920 description = "The host of this HTTP service" ;
20- default = config . networking . hostName ;
21+ default = nixosConfig . networking . hostName ;
2122 } ;
2223
2324 port = mkOption {
@@ -92,8 +93,62 @@ with lib;
9293 } ;
9394 } ;
9495 } ;
96+
97+ monitor = mkOption {
98+ type = types . submodule {
99+ options = {
100+ enable = mkEnableOption
101+ "Enabling monitoring of this service using Gatus" ;
102+
103+ name = mkOption {
104+ type = types . str ;
105+ description = "Name of the service being monitored" ;
106+ default = config . name ;
107+ } ;
108+
109+ url = mkOption {
110+ type = types . str ;
111+ description = "URL of the service to monitor" ;
112+ default = if config . http . proxy . enable then
113+ ( if config . http . proxy . skipTLSVerify then
114+ "http://${ config . http . proxy . domain } "
115+ else
116+ "https://${ config . http . proxy . domain } " )
117+ else
118+ "http://${ config . http . host } :${ toString config . http . port } " ;
119+ } ;
120+
121+ group = mkOption {
122+ type = types . str ;
123+ description = "Group to put the monitor in" ;
124+ default = flake . lib . strings . capitalizeString
125+ nixosConfig . networking . hostName ;
126+ } ;
127+
128+ conditions = mkOption {
129+ type = types . listOf types . str ;
130+ description =
131+ "List of Gatus conditions to evaluate if the service is healthy" ;
132+ default = [ "[STATUS] == 200" ] ;
133+ } ;
134+
135+ interval = mkOption {
136+ type = types . str ;
137+ description = "Interval to check if the service is healthy" ;
138+ default = "60s" ;
139+ } ;
140+
141+ extraConfig = mkOption {
142+ type = types . attrs ;
143+ description = "Extra config for the Gatus endpoint" ;
144+ default = { } ;
145+ } ;
146+ } ;
147+ } ;
148+ default = { } ;
149+ } ;
95150 } ;
96- } ) ;
151+ } ) ) ;
97152 default = { } ;
98153 } ;
99154}
0 commit comments