98 lines
2.1 KiB
Nix
98 lines
2.1 KiB
Nix
{ buildPythonApplication
|
|
, overrideScope
|
|
, fetchFromGitHub
|
|
, lib
|
|
, callPackage
|
|
, configuration ? ""
|
|
, psycopg2
|
|
}:
|
|
|
|
let
|
|
deps = overrideScope (callPackage ./python-packages.nix {});
|
|
in
|
|
buildPythonApplication rec {
|
|
pname = "netbox";
|
|
version = "3.0-beta2";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "netbox-community";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
sha256 = "05cwdkqs8vlpbn10pk8yj4a0ywp0x5h5ndf2a5zf4nlmg33d0sbi";
|
|
};
|
|
|
|
propagatedBuildInputs = (with deps; [
|
|
Django
|
|
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
|
|
netaddr
|
|
pillow
|
|
pycryptodome
|
|
PyYAML
|
|
svgwrite
|
|
tablib
|
|
|
|
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
|
|
|
|
cp $out/share/netbox/netbox/netbox/configuration.testing.py $out/share/netbox/netbox/netbox/configuration.py
|
|
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;
|
|
}
|