49 lines
1.2 KiB
Nix
49 lines
1.2 KiB
Nix
{ depot, pkgs, ... }:
|
|
|
|
let
|
|
python = pkgs.python3.withPackages (ps: with ps; [
|
|
django_3
|
|
gunicorn
|
|
psycopg2
|
|
(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"
|
|
makeWrapper "${python}/bin/django-admin" "$out/bin/quotes-manage" \
|
|
--set DJANGO_SETTINGS_MODULE "quotes.quotesapp.prod_settings" \
|
|
--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;
|
|
}
|