diff options
author | stuebinm | 2023-03-22 18:34:32 +0100 |
---|---|---|
committer | stuebinm | 2023-03-22 18:34:32 +0100 |
commit | 7c4ce3a545fb74ab1eb35c02de9ace3c3dbae2ef (patch) | |
tree | 12d6716773e7fe89f43701f39de0dd145e6a263e /modules | |
parent | 50f74d35e73529e67a27cee7fcd36e18a6d92e3a (diff) |
a glitchtip module, because why not
in case i ever think i need such a thing, i guess
Diffstat (limited to '')
-rw-r--r-- | modules/glitchtip.nix | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/modules/glitchtip.nix b/modules/glitchtip.nix new file mode 100644 index 0000000..f55f9e9 --- /dev/null +++ b/modules/glitchtip.nix @@ -0,0 +1,81 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let cfg = config.services.glitchtip; +in { + options.services.glitchtip = with types; { + enable = mkOption { + type = types.bool; + default = false; + description = "Enables glitchtip. This module is bring-your-own redis & postgres (look at redisUrl & databaseUrl); both are required for glitchtip to run without errors"; + }; + + databaseUrl = mkOption { + type = str; + default = "postgres://glitchtip@localhost:5432/glitchtip"; + description = "how to connect to postgres. An empty database (e.g. created by services.postgresql.ensureDatabases) is sufficient; migrations will be run automatically on startup."; + }; + + redisUrl = mkOption { + type = str; + default = "redis://localhost"; + description = "how to connect to redis"; + }; + + domain = mkOption { + type = str; + default = "http://localhost:${toString cfg.port}"; + description = "your glitchtip's public-facing domain. Must include the schema (http/https)."; + }; + + package = mkOption { + type = package; + default = pkgs.glitchtip; + }; + + port = mkOption { + type = port; + default = 8000; + description = "port for glitchtip's uwsgi server"; + }; + }; + + config = mkIf cfg.enable { + services.uwsgi = { + enable = true; + plugins = [ "python3" ]; + instance = { + type = "normal"; + pythonPackages = _: [ cfg.package ]; + module = "glitchtip.wsgi:application"; + chdir = cfg.package; + threads = 4; + http = ":${toString cfg.port}"; + env = [ + "DATABASE_URL=${cfg.databaseUrl}" + "GLITCHTIP_DOMAIN=${cfg.domain}" + "REDIS_URL=${cfg.redisUrl}" + ]; + hook-pre-app = '' + exec:./manage.py migrate + ''; + }; + }; + + systemd.services."glitchtip-celery" = { + enable = true; + wantedBy = [ "uwsgi.service" ]; + serviceConfig.Type = "simple"; + path = [ cfg.package.dependencyEnv ]; + script = '' + cd ${cfg.package} + bin/run-celery-with-beat.sh + ''; + environment = { + DATABASE_URL = cfg.databaseUrl; + REDIS_URL = cfg.redisUrl; + }; + }; + }; +} |