|
53 | 53 |
|
54 | 54 | settings = lib.mkOption { |
55 | 55 | description = '' |
56 | | - Configuration of GlitchTip. See <https://glitchtip.com/documentation/install#configuration> for more information. |
| 56 | + Configuration of GlitchTip. See <https://glitchtip.com/documentation/install#configuration> for more information and required settings. |
57 | 57 | ''; |
58 | 58 | default = { }; |
59 | 59 | defaultText = lib.literalExpression '' |
|
62 | 62 | DEBUG_TOOLBAR = 0; |
63 | 63 | DATABASE_URL = lib.mkIf config.services.glitchtip.database.createLocally "postgresql://@/glitchtip"; |
64 | 64 | ENABLE_OBSERVABILITY_API = false; |
| 65 | + GLITCHTIP_DOMAIN = lib.mkIf config.services.glitchtip.nginx.createLocally "https://''${config.services.glitchtip.nginx.domain}"; |
65 | 66 | GLITCHTIP_ENABLE_MCP = false; |
66 | 67 | GLITCHTIP_VERSION = config.services.glitchtip.package.version; |
67 | 68 | GRANIAN_HOST = "127.0.0.1"; |
|
73 | 74 | } |
74 | 75 | ''; |
75 | 76 | example = { |
| 77 | + GLITCHTIP_DOMAIN = "https://glitchtip.example.com"; |
76 | 78 | DATABASE_URL = "postgres://postgres:postgres@postgres/postgres"; |
77 | 79 | }; |
78 | 80 |
|
|
86 | 88 | ]); |
87 | 89 |
|
88 | 90 | options = { |
| 91 | + GLITCHTIP_DOMAIN = lib.mkOption { |
| 92 | + type = lib.types.nullOr lib.types.str; |
| 93 | + description = "The URL under which GlitchTip is externally reachable."; |
| 94 | + example = "https://glitchtip.example.com"; |
| 95 | + default = null; |
| 96 | + }; |
| 97 | + |
89 | 98 | GLITCHTIP_ENABLE_MCP = lib.mkOption { |
90 | 99 | type = lib.types.bool; |
91 | 100 | description = "Whether to enable the MCP api."; |
|
137 | 146 | database.createLocally = lib.mkOption { |
138 | 147 | type = lib.types.bool; |
139 | 148 | default = true; |
140 | | - description = '' |
141 | | - Whether to enable and configure a local PostgreSQL database server. |
142 | | - ''; |
| 149 | + description = "Whether to enable and configure a local PostgreSQL database server."; |
| 150 | + }; |
| 151 | + |
| 152 | + nginx = { |
| 153 | + createLocally = lib.mkOption { |
| 154 | + type = lib.types.bool; |
| 155 | + default = false; |
| 156 | + description = "Whether to enable and configure a local Nginx server."; |
| 157 | + }; |
| 158 | + |
| 159 | + domain = lib.mkOption { |
| 160 | + type = lib.types.str; |
| 161 | + example = "glitchtip.example.com"; |
| 162 | + description = '' |
| 163 | + Domain under which GlitchTip will be reachable. |
| 164 | + In contrast to `settings.GLITCHTIP_DOMAIN` this option has no protocol. |
| 165 | + It will also set `settings.GLITCHTIP_DOMAIN` with the `https://` protocol. |
| 166 | + ''; |
| 167 | + }; |
143 | 168 | }; |
144 | 169 |
|
145 | 170 | redis.createLocally = lib.mkOption { |
146 | 171 | type = lib.types.bool; |
147 | 172 | default = true; |
148 | | - description = '' |
149 | | - Whether to enable and configure a local Redis instance. |
150 | | - ''; |
| 173 | + description = "Whether to enable and configure a local Redis instance."; |
151 | 174 | }; |
152 | 175 | }; |
153 | 176 | }; |
|
185 | 208 | // lib.optionalAttrs cfg.database.createLocally { |
186 | 209 | DATABASE_URL = "postgresql://@/glitchtip"; |
187 | 210 | } |
| 211 | + // lib.optionalAttrs cfg.nginx.createLocally { |
| 212 | + GLITCHTIP_DOMAIN = "https://${cfg.nginx.domain}"; |
| 213 | + } |
188 | 214 | // lib.optionalAttrs cfg.redis.createLocally { |
189 | 215 | REDIS_URL = "unix://${config.services.redis.servers.glitchtip.unixSocket}"; |
190 | 216 | }; |
|
290 | 316 | }; |
291 | 317 | }; |
292 | 318 |
|
| 319 | + services.nginx = lib.mkIf cfg.nginx.createLocally { |
| 320 | + enable = true; |
| 321 | + virtualHosts.${cfg.nginx.domain} = { |
| 322 | + forceSSL = lib.mkDefault true; |
| 323 | + locations = { |
| 324 | + "/".proxyPass = "http://${cfg.settings.GRANIAN_HOST}:${toString cfg.settings.GRANIAN_PORT}"; |
| 325 | + "/static/" = { |
| 326 | + root = pkg; |
| 327 | + extraConfig = '' |
| 328 | + rewrite ^/(.*)$ /lib/glitchtip/$1 break; |
| 329 | + ''; |
| 330 | + }; |
| 331 | + }; |
| 332 | + }; |
| 333 | + }; |
| 334 | + |
293 | 335 | services.postgresql = lib.mkIf cfg.database.createLocally { |
294 | 336 | enable = true; |
295 | 337 | ensureDatabases = [ "glitchtip" ]; |
|
0 commit comments