lol
1{ lib
2, fetchFromGitHub
3, python3
4, version
5, hash
6, plugins ? ps: []
7, extraPatches ? []
8, tests ? {}
9, maintainers ? []
10, eol ? false
11}:
12 let
13 extraBuildInputs = plugins python3.pkgs;
14 in
15 python3.pkgs.buildPythonApplication rec {
16 pname = "netbox";
17 inherit version;
18
19 format = "other";
20
21 src = fetchFromGitHub {
22 owner = "netbox-community";
23 repo = pname;
24 rev = "refs/tags/v${version}";
25 inherit hash;
26 };
27
28 patches = extraPatches;
29
30 propagatedBuildInputs = with python3.pkgs; [
31 bleach
32 boto3
33 django_4
34 django-cors-headers
35 django-debug-toolbar
36 django-filter
37 django-graphiql-debug-toolbar
38 django-mptt
39 django-pglocks
40 django-prometheus
41 django-redis
42 django-rq
43 django-tables2
44 django-taggit
45 django-timezone-field
46 djangorestframework
47 drf-spectacular
48 drf-spectacular-sidecar
49 drf-yasg
50 dulwich
51 swagger-spec-validator # from drf-yasg[validation]
52 feedparser
53 graphene-django
54 jinja2
55 markdown
56 markdown-include
57 netaddr
58 pillow
59 psycopg2
60 pyyaml
61 requests
62 sentry-sdk
63 social-auth-core
64 social-auth-app-django
65 svgwrite
66 tablib
67 jsonschema
68 ] ++ extraBuildInputs;
69
70 buildInputs = with python3.pkgs; [
71 mkdocs-material
72 mkdocs-material-extensions
73 mkdocstrings
74 mkdocstrings-python
75 ];
76
77 nativeBuildInputs = [
78 python3.pkgs.mkdocs
79 ];
80
81 postBuild = ''
82 PYTHONPATH=$PYTHONPATH:netbox/
83 python -m mkdocs build
84 '';
85
86 installPhase = ''
87 mkdir -p $out/opt/netbox
88 cp -r . $out/opt/netbox
89 chmod +x $out/opt/netbox/netbox/manage.py
90 makeWrapper $out/opt/netbox/netbox/manage.py $out/bin/netbox \
91 --prefix PYTHONPATH : "$PYTHONPATH"
92 '';
93
94 passthru = {
95 # PYTHONPATH of all dependencies used by the package
96 pythonPath = python3.pkgs.makePythonPath propagatedBuildInputs;
97 gunicorn = python3.pkgs.gunicorn;
98 inherit tests;
99 };
100
101 meta = {
102 homepage = "https://github.com/netbox-community/netbox";
103 description = "IP address management (IPAM) and data center infrastructure management (DCIM) tool";
104 mainProgram = "netbox";
105 license = lib.licenses.asl20;
106 knownVulnerabilities = (lib.optional eol "Netbox version ${version} is EOL; please upgrade by following the current release notes instructions.");
107 # Warning:
108 # Notice the missing `lib` in the inherit: it is using this function argument rather than a `with lib;` argument.
109 # If you replace this by `with lib;`, pay attention it does not inherit all maintainers in nixpkgs.
110 inherit maintainers;
111 };
112 }