summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--flake.nix2
-rw-r--r--ilex/configuration.nix24
-rw-r--r--pkgs/0001-fix-poetry-name-issue.patch23
-rw-r--r--pkgs/glitchtip.nix87
-rw-r--r--pkgs/overlay.nix7
5 files changed, 141 insertions, 2 deletions
diff --git a/flake.nix b/flake.nix
index 25ef7b5..5ccd370 100644
--- a/flake.nix
+++ b/flake.nix
@@ -113,7 +113,7 @@
overlays.default = final: prev:
import ./pkgs/overlay.nix final prev;
packages.x86_64-linux = {
- inherit (nixpkgs) galmon-core galmon-full;
+ inherit (nixpkgs) galmon-core galmon-full glitchtip;
};
};
}
diff --git a/ilex/configuration.nix b/ilex/configuration.nix
index 6599cd4..2b07092 100644
--- a/ilex/configuration.nix
+++ b/ilex/configuration.nix
@@ -33,19 +33,41 @@
services.postgresql = {
enable = true;
- ensureDatabases = [ "tracktrain" ];
+ ensureDatabases = [ "tracktrain" "glitchtrip" ];
ensureUsers = [ {
name = "tracktrain";
ensurePermissions = {
"DATABASE tracktrain" = "ALL PRIVILEGES";
};
+ } {
+ name = "glitchtrip";
+ ensurePermissions = {
+ "DATABASE glitchtrip" = "ALL PRIVILEGES";
+ };
} ];
authentication = ''
local all all trust
host all all 127.0.0.1/32 trust
+ host all all ::1/127 trust
'';
};
+ services.uwsgi = {
+ enable = true;
+ plugins = [ "python3" ];
+ instance = {
+ type = "normal";
+ pythonPackages = self: [ pkgs.glitchtip ];
+ module = "glitchtip.wsgi:application";
+ chdir = pkgs.glitchtip;
+ http = ":8080";
+ env = [
+ "DATABASE_URL=postgres://glitchtrip@localhost:5432/glitchtrip"
+ ];
+ };
+ };
+
+
services.tlp = {
enable = true;
settings = {
diff --git a/pkgs/0001-fix-poetry-name-issue.patch b/pkgs/0001-fix-poetry-name-issue.patch
new file mode 100644
index 0000000..9cc82bd
--- /dev/null
+++ b/pkgs/0001-fix-poetry-name-issue.patch
@@ -0,0 +1,23 @@
+From 6a38df44cc64a4952528afe71c03c3931526af15 Mon Sep 17 00:00:00 2001
+From: stuebinm <stuebinm@disroot.org>
+Date: Wed, 22 Mar 2023 00:36:23 +0100
+Subject: [PATCH] fix poetry name issue
+
+---
+ pyproject.toml | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/pyproject.toml b/pyproject.toml
+index 9eb393a..1704691 100644
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -1,5 +1,5 @@
+ [tool.poetry]
+-name = "glitchtip-backend"
++name = "glitchtip"
+ version = "0.1.0"
+ description = "Django backend that powers GlitchTip, an open source reimplementation of Sentry"
+ authors = ["David Burke"]
+--
+2.38.3
+
diff --git a/pkgs/glitchtip.nix b/pkgs/glitchtip.nix
new file mode 100644
index 0000000..fa1a594
--- /dev/null
+++ b/pkgs/glitchtip.nix
@@ -0,0 +1,87 @@
+{ stdenv, lib, poetry2nix, python, fetchFromGitLab, fetchurl, unzip }:
+
+let
+ version = "3.0.7";
+ src = fetchFromGitLab {
+ owner = "glitchtip";
+ repo = "glitchtip-backend";
+ sha256 = "sha256-Dcdvv9DkU9znlamcSkGB/her+Ib6kV4mTkei6zoeZfE=";
+ rev = "v${version}";
+ };
+ frontend = fetchurl {
+ url =
+ "https://gitlab.com/api/v4/projects/15449363/jobs/artifacts/v${version}/download?job=build-assets";
+ sha256 = "sha256-dv5/ilzcdmA8Ljee7u//my+yf5zPGevFNY8ig5YgWl0=";
+ };
+ pythonApp = poetry2nix.mkPoetryApplication rec {
+ inherit python;
+ projectDir = src;
+
+ patches = [ ./0001-fix-poetry-name-issue.patch ];
+
+ # a bunch of python packages seem to misdeclare their dependencies
+ # a few are also just broken when building with Nix, so use these
+ # from nixpkgs instead. Finally, some are inherited from nixpkgs
+ # just to prevent duplicate dependencies (where nixpkgs & glitchtip's
+ # lock file differ in package versions)
+ overrides = poetry2nix.defaultPoetryOverrides.extend (self: super: {
+ anonymizeip = super.anonymizeip.overridePythonAttrs (old: {
+ propagatedBuildInputs = (old.propagatedBuildInputs or [ ])
+ ++ [ super.setuptools ];
+ });
+ uwsgi-chunked = super.uwsgi-chunked.overridePythonAttrs (old: {
+ propagatedBuildInputs = (old.propagatedBuildInputs or [ ])
+ ++ [ super.setuptools ];
+ });
+ django-bitfield = super.django-bitfield.overridePythonAttrs (old: {
+ propagatedBuildInputs = (old.propagatedBuildInputs or [ ])
+ ++ [ super.setuptools ];
+ });
+ roundrobin = super.roundrobin.overridePythonAttrs (old: {
+ propagatedBuildInputs = (old.propagatedBuildInputs or [ ])
+ ++ [ super.setuptools ];
+ });
+ markuppy = super.markuppy.overridePythonAttrs (old: {
+ propagatedBuildInputs = (old.propagatedBuildInputs or [ ])
+ ++ [ super.setuptools ];
+ });
+ uwsgi = super.uwsgi.overridePythonAttrs (old: {
+ propagatedBuildInputs = (old.propagatedBuildInputs or [ ])
+ ++ [ super.setuptools ];
+ });
+ inherit (python.pkgs)
+ django-stubs-ext django-stubs django async-timeout mypy-extensions tomli
+ asgiref sqlparse typing-extensions pytz mypy;
+ });
+
+ # magically makes the cargo errors go away
+ preferWheels = true;
+ };
+
+ staticDir = stdenv.mkDerivation {
+ pname = "glitchtip-backend-static";
+ inherit version;
+
+ inherit src;
+
+ buildInputs = [ unzip ];
+ propagatedBuildInputs = [ pythonApp.dependencyEnv ];
+ buildPhase = ''
+ unzip ${frontend} -d unpacked
+ mv unpacked/dist/glitchtip-frontend dist
+ rm -rf unpacked
+ ${pythonApp.dependencyEnv}/bin/python ${src}/manage.py collectstatic
+ '';
+
+ installPhase = ''
+ mkdir -p $out
+ cp -r * $out
+ rm $out/manage.py
+ install -Dm755 manage.py $out/manage.py
+ '';
+ };
+
+# this is mildly cursed. It returns the static dir as a package,
+# but keeps the Nix meta-info of pythonApp in the attr set so we can
+# also feed this to pythonPackages and the like to get a python env.
+in pythonApp // staticDir
diff --git a/pkgs/overlay.nix b/pkgs/overlay.nix
index eaba1d9..ada5d47 100644
--- a/pkgs/overlay.nix
+++ b/pkgs/overlay.nix
@@ -3,4 +3,11 @@ self: super:
{
galmon-core = self.callPackage (import ./galmon.nix {}) {};
galmon-full = self.callPackage (import ./galmon.nix { buildAll = true; }) {};
+ glitchtip = (self.callPackage ./glitchtip.nix {
+ python = super.python310.override ({
+ packageOverrides = self: super: {
+ django = super.django_4;
+ };
+ });
+ });
}