{ lib, fetchFromGitHub, python3, fetchpatch2, plugins ? _ps: [ ], nixosTests, nix-update-script, runCommand, writers, }: let py = python3.override { self = py; packageOverrides = _final: prev: { django = prev.django_6; }; }; extraBuildInputs = plugins py.pkgs; in py.pkgs.buildPythonApplication (finalAttrs: { __structuredAttrs = true; pname = "netbox"; version = "4.6.8"; pyproject = false; src = fetchFromGitHub { owner = "netbox-community"; repo = "netbox"; tag = "v${finalAttrs.version}"; hash = "sha256-fhEcQBYL5R9Tv9CpAf3Ce1oIzsXCjtH5j+dP9sD6kdg="; }; patches = [ ./custom-static-root.patch # TODO: remove before upgrading to NetBox v4.7 (fetchpatch2 { name = "upgrade-django-tables2-v3.0.patch"; url = "https://github.com/netbox-community/netbox/commit/d57346d9f0eef8126eafcd5033ea43864faeaf0d.patch"; hash = "sha256-6/wdd8wDVT4eqDKMNx8tmoPTDvw8OE7atf9nzg3LZzk="; }) ]; dependencies = ( with py.pkgs; [ colorama 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-storages django-tables2 django-taggit django-timezone-field djangorestframework drf-spectacular drf-spectacular-sidecar feedparser jinja2 markdown netaddr nh3 pillow psycopg pyyaml requests social-auth-core social-auth-app-django sorl-thumbnail strawberry-graphql strawberry-graphql-django svgwrite tablib tzdata # 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 ] ++ psycopg.optional-dependencies.c ++ psycopg.optional-dependencies.pool ++ social-auth-core.optional-dependencies.openidconnect ) ++ extraBuildInputs; nativeBuildInputs = with py.pkgs; [ mkdocs-material mkdocs-material-extensions mkdocstrings mkdocstrings-python ]; postBuild = '' PYTHONPATH=$PYTHONPATH:netbox/ ${py.pythonOnBuildForHost.interpreter} -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 = py; # PYTHONPATH of all dependencies used by the package pythonPath = py.pkgs.makePythonPath finalAttrs.passthru.dependencies; inherit (py.pkgs) gunicorn; tests = { inherit (nixosTests) netbox; satisfiesBaseRequirements = runCommand "test-netbox-satisfies-base-requirements" { nativeBuildInputs = [ (writers.writePython3Bin "test-netbox-requirements" { libraries = finalAttrs.passthru.dependencies ++ [ py.pkgs.packaging finalAttrs.passthru.gunicorn ]; } (builtins.readFile ./test-netbox-requirements.py)) ]; } '' test-netbox-requirements ${finalAttrs.src}/base_requirements.txt touch $out ''; }; updateScript = nix-update-script { }; plugins = lib.recurseIntoAttrs ( lib.makeExtensible ( self: lib.packagesFromDirectoryRecursive { inherit (py.pkgs) callPackage; directory = ./plugins; } ) ); }; meta = { homepage = "https://github.com/netbox-community/netbox"; changelog = "https://github.com/netbox-community/netbox/blob/${finalAttrs.src.tag}/docs/release-notes/version-${lib.versions.majorMinor finalAttrs.version}.md"; description = "IP address management (IPAM) and data center infrastructure management (DCIM) tool"; mainProgram = "netbox"; license = lib.licenses.asl20; maintainers = with lib.maintainers; [ minijackson transcaffeine ]; }; })