46 lines
1 KiB
Nix
46 lines
1 KiB
Nix
|
{ depot, pkgs, ... }:
|
||
|
|
||
|
let
|
||
|
python = pkgs.python3.withPackages (ps: with ps; [
|
||
|
django_3
|
||
|
gunicorn
|
||
|
(depot.pkgs.django-allauth.override {
|
||
|
django = django_3;
|
||
|
})
|
||
|
]);
|
||
|
in
|
||
|
pkgs.stdenvNoCC.mkDerivation rec {
|
||
|
name = "quotes";
|
||
|
|
||
|
src = ./.;
|
||
|
|
||
|
buildInputs = [ pkgs.makeWrapper ];
|
||
|
propagatedBuildInputs = [ python ];
|
||
|
|
||
|
buildPhase = "true";
|
||
|
installPhase = ''
|
||
|
sitepkgdir="$out/lib/${python.libPrefix}/site-packages"
|
||
|
pkgdir="$sitepkgdir/quotes"
|
||
|
mkdir -p $pkgdir
|
||
|
cp -R \
|
||
|
$src/quotesapp \
|
||
|
$src/quotedb \
|
||
|
$src/templates \
|
||
|
$src/static \
|
||
|
$pkgdir
|
||
|
|
||
|
mkdir "$out/bin"
|
||
|
makeWrapper "${python}/bin/gunicorn" "$out/bin/quotes" \
|
||
|
--add-flags "quotes.quotesapp.wsgi" \
|
||
|
--suffix PYTHONPATH : "$sitepkgdir"
|
||
|
|
||
|
mkdir -p "$out/share/static"
|
||
|
export STATIC_ROOT="$out/share/static"
|
||
|
export DJANGO_SETTINGS_MODULE=quotes.quotesapp.settings
|
||
|
export PYTHONPATH=$PYTHONPATH''${PYTHONPATH:+':'}"$sitepkgdir"
|
||
|
django-admin collectstatic --no-input
|
||
|
'';
|
||
|
|
||
|
passthru.pythonEnv = python;
|
||
|
}
|