From c0e16ebce519e09b2dcc046aa9fa68d9f0cf3dca Mon Sep 17 00:00:00 2001 From: Minijackson Date: Mon, 7 Oct 2024 16:14:33 +0200 Subject: [PATCH] netbox_4_1: init at 4.1.3 --- nixos/tests/all-tests.nix | 1 + .../ne/netbox_4_1/custom-static-root.patch | 13 ++ pkgs/by-name/ne/netbox_4_1/package.nix | 133 ++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 pkgs/by-name/ne/netbox_4_1/custom-static-root.patch create mode 100644 pkgs/by-name/ne/netbox_4_1/package.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 88e542bc7382..cc792d8a175a 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -659,6 +659,7 @@ in { netbox_3_6 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_3_6; }; netbox_3_7 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_3_7; }; netbox_4_0 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_4_0; }; + netbox_4_1 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_4_1; }; netbox-upgrade = handleTest ./web-apps/netbox-upgrade.nix {}; # TODO: put in networking.nix after the test becomes more complete networkingProxy = handleTest ./networking-proxy.nix {}; diff --git a/pkgs/by-name/ne/netbox_4_1/custom-static-root.patch b/pkgs/by-name/ne/netbox_4_1/custom-static-root.patch new file mode 100644 index 000000000000..c9219fa2b871 --- /dev/null +++ b/pkgs/by-name/ne/netbox_4_1/custom-static-root.patch @@ -0,0 +1,13 @@ +diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py +index 2de06dd10..00406af48 100644 +--- a/netbox/netbox/settings.py ++++ b/netbox/netbox/settings.py +@@ -410,7 +412,7 @@ USE_X_FORWARDED_HOST = True + X_FRAME_OPTIONS = 'SAMEORIGIN' + + # Static files (CSS, JavaScript, Images) +-STATIC_ROOT = BASE_DIR + '/static' ++STATIC_ROOT = getattr(configuration, 'STATIC_ROOT', os.path.join(BASE_DIR, 'static')).rstrip('/') + STATIC_URL = f'/{BASE_PATH}static/' + STATICFILES_DIRS = ( + os.path.join(BASE_DIR, 'project-static', 'dist'), diff --git a/pkgs/by-name/ne/netbox_4_1/package.nix b/pkgs/by-name/ne/netbox_4_1/package.nix new file mode 100644 index 000000000000..be5b53042793 --- /dev/null +++ b/pkgs/by-name/ne/netbox_4_1/package.nix @@ -0,0 +1,133 @@ +{ + lib, + fetchFromGitHub, + fetchpatch, + python3, + plugins ? _ps: [ ], + nixosTests, +}: +let + py = python3.override { + packageOverrides = _final: prev: { django = prev.django_5; }; + }; + + extraBuildInputs = plugins py.pkgs; +in +py.pkgs.buildPythonApplication rec { + pname = "netbox"; + version = "4.1.3"; + + format = "other"; + + src = fetchFromGitHub { + owner = "netbox-community"; + repo = "netbox"; + rev = "refs/tags/v${version}"; + hash = "sha256-SRzkmRkniVDu6vYGa9Kd9exob/LHpGBPd+lRA/pbCFo="; + }; + + patches = [ + ./custom-static-root.patch + (fetchpatch { + url = "https://github.com/netbox-community/netbox/pull/17620.patch"; + hash = "sha256-zN2zke4qlNJUbxI8mSV+zGmEv0Qtd0zSCbCXWyE1L2k="; + }) + ]; + + propagatedBuildInputs = + ( + with py.pkgs; + [ + django + django-cors-headers + django-debug-toolbar + django-filter + django-graphiql-debug-toolbar + django-htmx + django-mptt + django-pglocks + django-prometheus + django-redis + django-rq + django-tables2 + django-taggit + django-timezone-field + djangorestframework + drf-spectacular + drf-spectacular-sidecar + feedparser + jinja2 + markdown + netaddr + nh3 + pillow + psycopg + psycopg.optional-dependencies.c + psycopg.optional-dependencies.pool + pyyaml + requests + social-auth-core + social-auth-app-django + strawberry-graphql + strawberry-django + svgwrite + tablib + + # Optional dependencies, kept here for backward compatibility + + # for the S3 data source backend + boto3 + # for Git data source backend + dulwich + # for error reporting + sentry-sdk + ] + ++ social-auth-core.passthru.optional-dependencies.openidconnect + ) + ++ extraBuildInputs; + + buildInputs = with py.pkgs; [ + mkdocs-material + mkdocs-material-extensions + mkdocstrings + mkdocstrings-python + ]; + + nativeBuildInputs = [ py.pkgs.mkdocs ]; + + postBuild = '' + PYTHONPATH=$PYTHONPATH:netbox/ + python -m mkdocs build + ''; + + installPhase = '' + mkdir -p $out/opt/netbox + cp -r . $out/opt/netbox + chmod +x $out/opt/netbox/netbox/manage.py + makeWrapper $out/opt/netbox/netbox/manage.py $out/bin/netbox \ + --prefix PYTHONPATH : "$PYTHONPATH" + ''; + + passthru = { + python = python3; + # PYTHONPATH of all dependencies used by the package + pythonPath = py.pkgs.makePythonPath propagatedBuildInputs; + inherit (py.pkgs) gunicorn; + tests = { + netbox = nixosTests.netbox_4_1; + inherit (nixosTests) netbox-upgrade; + }; + }; + + meta = { + homepage = "https://github.com/netbox-community/netbox"; + description = "IP address management (IPAM) and data center infrastructure management (DCIM) tool"; + mainProgram = "netbox"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ + minijackson + n0emis + raitobezarius + ]; + }; +}