{ depot, pkgs, ... }: let python = pkgs.python3.withPackages (ps: with ps; let django = django_4; in [ django gunicorn psycopg2 (django-allauth.override { inherit django; }) (depot.pkgs.django-tailwind.override { inherit django; }) ]); filterSourcePred = (path: type: type != "directory" || ( baseNameOf path != "__pycache__" && baseNameOf path != "node_modules" && true)); src = builtins.filterSource filterSourcePred ./.; nodeDeps = pkgs.buildNpmPackage rec { name = "quotes_node_deps"; inherit src; sourceRoot = "quotes/theme/static_src"; npmDeps = pkgs.importNpmLock { npmRoot = builtins.filterSource (path: type: baseNameOf path == "package.json" || baseNameOf path == "package-lock.json") ./theme/static_src; }; npmConfigHook = pkgs.importNpmLock.npmConfigHook; dontNpmBuild = true; installPhase = '' runHook preInstall mkdir -p $out/lib cp -R node_modules $out/lib/node_modules runHook postInstall ''; }; in pkgs.stdenvNoCC.mkDerivation rec { name = "quotes"; inherit src; buildInputs = with pkgs; [ makeWrapper nodejs ]; propagatedBuildInputs = [ python ]; inherit nodeDeps; buildPhase = '' cp -R $nodeDeps/lib/node_modules theme/static_src/node_modules ''; installPhase = '' sitepkgdir="$out/lib/${python.libPrefix}/site-packages" pkgdir="$sitepkgdir/quotes" mkdir -p $pkgdir cp -R \ quotesapp \ quotedb \ templates \ static \ discordguild \ theme \ $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" mkdir $NIX_BUILD_TOP/tmp export HOME=$NIX_BUILD_TOP/tmp django-admin tailwind build django-admin collectstatic --no-input chmod -R +w $pkgdir/theme/static $pkgdir/theme/static_src rm -rf $pkgdir/theme/static $pkgdir/theme/static_src ''; passthru.pythonEnv = python; }