depot/nix/pkgs/netbox/default.nix

106 lines
2.2 KiB
Nix
Raw Normal View History

2021-08-16 02:09:47 +00:00
{ buildPythonApplication
, overrideScope
, fetchFromGitHub
, lib
, callPackage
, configuration ? ""
, psycopg2
}:
let
deps = overrideScope (callPackage ./python-packages.nix {});
in
buildPythonApplication rec {
pname = "netbox";
2022-07-07 21:06:20 +00:00
version = "3.2.5";
2021-08-16 02:09:47 +00:00
src = fetchFromGitHub {
owner = "netbox-community";
repo = pname;
rev = "v${version}";
2022-07-07 21:06:20 +00:00
sha256 = "0blqlfl7djl1zb92cvqndy5l8drn0axjjqvhjc1q881h3sif123w";
2021-08-16 02:09:47 +00:00
};
propagatedBuildInputs = (with deps; [
2022-07-07 21:38:58 +00:00
bleach
django
2021-08-16 02:09:47 +00:00
django-cors-headers
django-debug-toolbar
django-filter
django-graphiql-debug-toolbar
django-mptt
django-pglocks
django-prometheus
django-redis
django-rq
django-tables2
django-taggit
django-timezone-field
djangorestframework
drf-yasg
graphene-django
gunicorn
Jinja2
Markdown
markdown-include
mkdocs-material
2022-07-07 21:38:58 +00:00
mkdocstrings
mkdocstrings-python-legacy
2021-08-16 02:09:47 +00:00
netaddr
pillow
PyYAML
2022-07-07 21:38:58 +00:00
sentry-sdk
social-auth-app-django
social-auth-core
2021-08-16 02:09:47 +00:00
svgwrite
tablib
2022-07-07 21:38:58 +00:00
tzdata
jsonschema
2021-08-16 02:09:47 +00:00
django-storages
]) ++ [
psycopg2
];
format = "other";
buildPhase = ''
runHook preBuild
# Do nothing.
runHook postBuild
'';
passAsFile = [ "configuration" ];
inherit configuration;
installPhase = ''
runHook preInstall
mkdir -p $out/share/netbox
cp -R . $out/share/netbox
PYVER="$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")"
PYDIR="$out/lib/python$PYVER"
mkdir -p $PYDIR
ln -s $out/share/netbox/netbox $PYDIR/site-packages
mkdir -p $out/bin
cp $out/share/netbox/netbox/manage.py $out/bin/netbox-manage
cat <<"EOF" >$out/bin/netbox-gunicorn
#!/usr/bin/python
import sys
from gunicorn.app.wsgiapp import run
if __name__ == '__main__':
sys.exit(run())
EOF
chmod +x $out/bin/netbox-gunicorn
2022-07-07 21:38:58 +00:00
cp $out/share/netbox/netbox/netbox/configuration_testing.py $out/share/netbox/netbox/netbox/configuration.py
2021-08-16 02:09:47 +00:00
PYTHONPATH=$PYDIR/site-packages:$PYTHONPATH python $out/bin/netbox-manage collectstatic --no-input
cp $configurationPath $out/share/netbox/netbox/netbox/configuration.py
runHook postInstall
'';
passthru.deps = deps;
}