summaryrefslogtreecommitdiff
path: root/pkgs/glitchtip.nix
diff options
context:
space:
mode:
authorstuebinm2023-03-22 03:15:41 +0100
committerstuebinm2023-03-22 03:15:41 +0100
commit50f74d35e73529e67a27cee7fcd36e18a6d92e3a (patch)
tree24156224569cc55bef590cab002d4ca1f3c223fc /pkgs/glitchtip.nix
parent9b017a8ef302fe0317718a30af80bf2d51e07009 (diff)
package glitchtip
i don't know why i did this. i literally have no use for it.
Diffstat (limited to 'pkgs/glitchtip.nix')
-rw-r--r--pkgs/glitchtip.nix87
1 files changed, 87 insertions, 0 deletions
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