nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 fetchFromGitHub,
4 python3,
5 plugins ? _ps: [ ],
6 nixosTests,
7 nix-update-script,
8}:
9let
10 py = python3.override {
11 self = py;
12 packageOverrides = _final: prev: { django = prev.django_5_2; };
13 };
14
15 extraBuildInputs = plugins py.pkgs;
16in
17py.pkgs.buildPythonApplication rec {
18 pname = "netbox";
19 version = "4.3.3";
20 pyproject = false;
21
22 src = fetchFromGitHub {
23 owner = "netbox-community";
24 repo = "netbox";
25 tag = "v${version}";
26 hash = "sha256-KmnTDTb3k8WtDN7sWjKOriG9i5dHY7BHXty6zPDqPqA=";
27 };
28
29 patches = [
30 ./custom-static-root.patch
31 ];
32
33 dependencies =
34 (
35 with py.pkgs;
36 [
37 django
38 django-cors-headers
39 django-debug-toolbar
40 django-filter
41 django-graphiql-debug-toolbar
42 django-htmx
43 django-mptt
44 django-pglocks
45 django-prometheus
46 django-redis
47 django-rq
48 django-storages
49 django-tables2
50 django-taggit
51 django-timezone-field
52 djangorestframework
53 drf-spectacular
54 drf-spectacular-sidecar
55 feedparser
56 jinja2
57 markdown
58 netaddr
59 nh3
60 pillow
61 psycopg
62 pyyaml
63 requests
64 social-auth-core
65 social-auth-app-django
66 strawberry-graphql
67 strawberry-django
68 svgwrite
69 tablib
70
71 # Optional dependencies, kept here for backward compatibility
72
73 # for the S3 data source backend
74 boto3
75 # for Git data source backend
76 dulwich
77 # for error reporting
78 sentry-sdk
79 ]
80 ++ psycopg.optional-dependencies.c
81 ++ psycopg.optional-dependencies.pool
82 ++ social-auth-core.optional-dependencies.openidconnect
83 )
84 ++ extraBuildInputs;
85
86 nativeBuildInputs = with py.pkgs; [
87 mkdocs-material
88 mkdocs-material-extensions
89 mkdocstrings
90 mkdocstrings-python
91 ];
92
93 postBuild = ''
94 PYTHONPATH=$PYTHONPATH:netbox/
95 ${py.interpreter} -m mkdocs build
96 '';
97
98 installPhase = ''
99 mkdir -p $out/opt/netbox
100 cp -r . $out/opt/netbox
101 chmod +x $out/opt/netbox/netbox/manage.py
102 makeWrapper $out/opt/netbox/netbox/manage.py $out/bin/netbox \
103 --prefix PYTHONPATH : "$PYTHONPATH"
104 '';
105
106 passthru = {
107 python = py;
108 # PYTHONPATH of all dependencies used by the package
109 pythonPath = py.pkgs.makePythonPath dependencies;
110 inherit (py.pkgs) gunicorn;
111 tests = {
112 netbox = nixosTests.netbox_4_3;
113 inherit (nixosTests) netbox-upgrade;
114 };
115 updateScript = nix-update-script { };
116 };
117
118 meta = {
119 homepage = "https://github.com/netbox-community/netbox";
120 changelog = "https://github.com/netbox-community/netbox/blob/${src.tag}/docs/release-notes/version-${lib.versions.majorMinor version}.md";
121 description = "IP address management (IPAM) and data center infrastructure management (DCIM) tool";
122 mainProgram = "netbox";
123 license = lib.licenses.asl20;
124 maintainers = with lib.maintainers; [
125 minijackson
126 raitobezarius
127 transcaffeine
128 ];
129 };
130}