diff options
author | Yureka <yuka@yuka.dev> | 2022-12-01 17:31:37 +0100 |
---|---|---|
committer | Yureka <yuka@yuka.dev> | 2022-12-07 12:54:55 +0100 |
commit | 4c9129f5a78005e4dff59c224d81002e3ed4320e (patch) | |
tree | fd0c1fc0d0cf74569cdb52dbae10b0296bdd0f1c | |
parent | 944f7c20572df0d637d74e713b19d67fab404bd9 (diff) |
peering-manager: init at 1.7.3
-rw-r--r-- | pkgs/servers/web-apps/peering-manager/default.nix | 100 | ||||
-rw-r--r-- | pkgs/servers/web-apps/peering-manager/redis-unix-sock.patch | 47 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 2 |
3 files changed, 149 insertions, 0 deletions
diff --git a/pkgs/servers/web-apps/peering-manager/default.nix b/pkgs/servers/web-apps/peering-manager/default.nix new file mode 100644 index 0000000000000..dd60980e3290d --- /dev/null +++ b/pkgs/servers/web-apps/peering-manager/default.nix @@ -0,0 +1,100 @@ +{ python3 +, fetchFromGitHub +, fetchpatch +, nixosTests + +, plugins ? ps: [] +}: + +let + py = python3.override { + packageOverrides = final: prev: { + django = final.django_4; + drf-nested-routers = prev.drf-nested-routers.overridePythonAttrs (oldAttrs: { + patches = [ + # all for django 4 compat + (fetchpatch { + url = "https://github.com/alanjds/drf-nested-routers/commit/59764cc356f7f593422b26845a9dfac0ad196120.diff"; + hash = "sha256-mq3vLHzQlGl2EReJ5mVVQMMcYgGIVt/T+qi1STtQ0aI="; + }) + (fetchpatch { + url = "https://github.com/alanjds/drf-nested-routers/commit/723a5729dd2ffcb66fe315f229789ca454986fa4.diff"; + hash = "sha256-UCbBjwlidqsJ9vEEWlGzfqqMOr0xuB2TAaUxHsLzFfU="; + }) + (fetchpatch { + url = "https://github.com/alanjds/drf-nested-routers/commit/38e49eb73759bc7dcaaa9166169590f5315e1278.diff"; + hash = "sha256-IW4BLhHHhXDUZqHaXg46qWoQ89pMXv0ZxKjOCTnDcI0="; + }) + ]; + }); + }; + }; + +in py.pkgs.buildPythonApplication rec { + pname = "peering-manager"; + version = "1.7.3"; + + src = fetchFromGitHub { + owner = pname; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-vrRMdqEpsps4ZKgunMhznJr/TQ9+WVMNYFu76ZU7iMI="; + }; + + patches = [ + ./redis-unix-sock.patch + ]; + + format = "other"; + + propagatedBuildInputs = with py.pkgs; [ + django + djangorestframework + django-cacheops + django-debug-toolbar + django-filter + django-postgresql-netfields + django-prometheus + django-rq + django-tables2 + django-taggit + drf-spectacular + jinja2 + markdown + napalm + packaging + psycopg2 + pynetbox + pyyaml + requests + tzdata + ] ++ plugins py.pkgs; + + buildPhase = '' + runHook preBuild + cp peering_manager/configuration{.example,}.py + python3 manage.py collectstatic --no-input + rm -f peering_manager/configuration.py + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out/opt/peering-manager + cp -r . $out/opt/peering-manager + chmod +x $out/opt/peering-manager/manage.py + makeWrapper $out/opt/peering-manager/manage.py $out/bin/peering-manager \ + --prefix PYTHONPATH : "$PYTHONPATH" + runHook postInstall + ''; + + passthru = { + # PYTHONPATH of all dependencies used by the package + python = py; + pythonPath = py.pkgs.makePythonPath propagatedBuildInputs; + + tests = { + inherit (nixosTests) peering-manager; + }; + }; +} diff --git a/pkgs/servers/web-apps/peering-manager/redis-unix-sock.patch b/pkgs/servers/web-apps/peering-manager/redis-unix-sock.patch new file mode 100644 index 0000000000000..5db0d0dd01252 --- /dev/null +++ b/pkgs/servers/web-apps/peering-manager/redis-unix-sock.patch @@ -0,0 +1,47 @@ +commit 1e64a7f6ca456249305f6a3c90f9acf84af194db +Author: Yureka <yuka@yuka.dev> +Date: Tue Nov 29 14:03:08 2022 +0100 + + support unix sockets for redis connections + +diff --git a/peering_manager/settings.py b/peering_manager/settings.py +index 739d6ff..b5edf4d 100644 +--- a/peering_manager/settings.py ++++ b/peering_manager/settings.py +@@ -270,6 +270,7 @@ TASKS_REDIS_PASSWORD = TASKS_REDIS.get("PASSWORD", "") + TASKS_REDIS_DATABASE = TASKS_REDIS.get("DATABASE", 0) + TASKS_REDIS_DEFAULT_TIMEOUT = TASKS_REDIS.get("DEFAULT_TIMEOUT", 300) + TASKS_REDIS_SSL = TASKS_REDIS.get("SSL", False) ++TASKS_REDIS_UNIX_SOCKET_PATH = TASKS_REDIS.get("UNIX_SOCKET_PATH", "") + if "DEFAULT_TIMEOUT" in TASKS_REDIS: + warnings.warn( + "DEFAULT_TIMEOUT is no longer supported under REDIS configuration. Set RQ_DEFAULT_TIMEOUT instead." +@@ -294,6 +295,7 @@ CACHING_REDIS_PASSWORD = CACHING_REDIS.get("PASSWORD", "") + CACHING_REDIS_DATABASE = CACHING_REDIS.get("DATABASE", 0) + CACHING_REDIS_DEFAULT_TIMEOUT = CACHING_REDIS.get("DEFAULT_TIMEOUT", 300) + CACHING_REDIS_SSL = CACHING_REDIS.get("SSL", False) ++CACHING_REDIS_UNIX_SOCKET_PATH = CACHING_REDIS.get("UNIX_SOCKET_PATH", "") + + if CACHING_REDIS_USING_SENTINEL: + CACHEOPS_SENTINEL = { +@@ -301,6 +303,8 @@ if CACHING_REDIS_USING_SENTINEL: + "service_name": CACHING_REDIS_SENTINEL_SERVICE, + "db": CACHING_REDIS_DATABASE, + } ++elif CACHING_REDIS_UNIX_SOCKET_PATH != "": ++ CACHEOPS_REDIS = f"unix://{CACHING_REDIS_UNIX_SOCKET_PATH}?db={CACHING_REDIS_DATABASE}" + else: + REDIS_CACHE_CON_STRING = "rediss://" if CACHING_REDIS_SSL else "redis://" + if CACHING_REDIS_PASSWORD: +@@ -334,6 +338,11 @@ if TASKS_REDIS_USING_SENTINEL: + "SOCKET_TIMEOUT": None, + "CONNECTION_KWARGS": {"socket_connect_timeout": TASKS_REDIS_DEFAULT_TIMEOUT}, + } ++elif TASKS_REDIS_UNIX_SOCKET_PATH != "": ++ RQ_PARAMS = { ++ "UNIX_SOCKET_PATH": TASKS_REDIS_UNIX_SOCKET_PATH, ++ "DB": TASKS_REDIS_DATABASE, ++ } + else: + RQ_PARAMS = { + "HOST": TASKS_REDIS_HOST, diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 883df35fb01da..c573f3680477b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -23750,6 +23750,8 @@ with pkgs; hyp = callPackage ../servers/http/hyp { }; + peering-manager = callPackage ../servers/web-apps/peering-manager { }; + podgrab = callPackage ../servers/misc/podgrab { }; portunus = callPackage ../servers/portunus { }; |