2021-01-19 03:51:22 +00:00
|
|
|
{ depot, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
python = pkgs.python3.withPackages (ps: with ps; [
|
|
|
|
django_3
|
|
|
|
gunicorn
|
2021-01-19 23:43:43 +00:00
|
|
|
psycopg2
|
2021-01-19 03:51:22 +00:00
|
|
|
(depot.pkgs.django-allauth.override {
|
|
|
|
django = django_3;
|
|
|
|
})
|
2021-01-20 02:04:30 +00:00
|
|
|
(depot.pkgs.django-tailwind.override {
|
|
|
|
django = django_3;
|
|
|
|
})
|
2021-01-19 03:51:22 +00:00
|
|
|
]);
|
2021-01-20 02:04:30 +00:00
|
|
|
|
|
|
|
filterSourcePred = (path: type: type != "directory" || (
|
|
|
|
baseNameOf path != "__pycache__" &&
|
|
|
|
baseNameOf path != "node_modules" &&
|
|
|
|
true));
|
2021-01-19 03:51:22 +00:00
|
|
|
in
|
|
|
|
pkgs.stdenvNoCC.mkDerivation rec {
|
|
|
|
name = "quotes";
|
|
|
|
|
2021-01-20 02:04:30 +00:00
|
|
|
src = builtins.filterSource filterSourcePred ./.;
|
2021-01-19 03:51:22 +00:00
|
|
|
|
2021-01-20 02:04:30 +00:00
|
|
|
buildInputs = with pkgs; [ makeWrapper nodejs ];
|
2021-01-19 03:51:22 +00:00
|
|
|
propagatedBuildInputs = [ python ];
|
|
|
|
|
2023-05-28 00:28:20 +00:00
|
|
|
nodeModules = (import ./node-default.nix { inherit pkgs; nodejs = pkgs.nodejs-18_x; }).shell.nodeDependencies;
|
2021-01-20 02:04:30 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
2021-07-25 07:00:49 +00:00
|
|
|
cp -R $nodeModules/lib/node_modules theme/static_src/node_modules
|
2021-01-20 02:04:30 +00:00
|
|
|
'';
|
2021-01-19 03:51:22 +00:00
|
|
|
installPhase = ''
|
|
|
|
sitepkgdir="$out/lib/${python.libPrefix}/site-packages"
|
|
|
|
pkgdir="$sitepkgdir/quotes"
|
|
|
|
mkdir -p $pkgdir
|
|
|
|
cp -R \
|
2021-01-20 02:04:30 +00:00
|
|
|
quotesapp \
|
|
|
|
quotedb \
|
|
|
|
templates \
|
|
|
|
static \
|
|
|
|
discordguild \
|
|
|
|
theme \
|
2021-01-19 03:51:22 +00:00
|
|
|
$pkgdir
|
|
|
|
|
|
|
|
mkdir "$out/bin"
|
|
|
|
makeWrapper "${python}/bin/gunicorn" "$out/bin/quotes" \
|
|
|
|
--add-flags "quotes.quotesapp.wsgi" \
|
|
|
|
--suffix PYTHONPATH : "$sitepkgdir"
|
2021-01-19 23:43:43 +00:00
|
|
|
makeWrapper "${python}/bin/django-admin" "$out/bin/quotes-manage" \
|
|
|
|
--set DJANGO_SETTINGS_MODULE "quotes.quotesapp.prod_settings" \
|
|
|
|
--suffix PYTHONPATH : "$sitepkgdir"
|
2021-01-19 03:51:22 +00:00
|
|
|
|
|
|
|
mkdir -p "$out/share/static"
|
|
|
|
export STATIC_ROOT="$out/share/static"
|
|
|
|
export DJANGO_SETTINGS_MODULE=quotes.quotesapp.settings
|
|
|
|
export PYTHONPATH=$PYTHONPATH''${PYTHONPATH:+':'}"$sitepkgdir"
|
2021-04-30 23:38:11 +00:00
|
|
|
mkdir $NIX_BUILD_TOP/tmp
|
|
|
|
export HOME=$NIX_BUILD_TOP/tmp
|
2021-01-20 02:04:30 +00:00
|
|
|
django-admin tailwind build
|
2021-01-19 03:51:22 +00:00
|
|
|
django-admin collectstatic --no-input
|
2021-01-20 02:04:30 +00:00
|
|
|
|
|
|
|
chmod -R +w $pkgdir/theme/static $pkgdir/theme/static_src
|
|
|
|
rm -rf $pkgdir/theme/static $pkgdir/theme/static_src
|
2021-01-19 03:51:22 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.pythonEnv = python;
|
|
|
|
}
|