2024-01-14 20:00:17 +02:00
|
|
|
{
|
|
|
|
stdenv,
|
2024-01-17 10:45:16 +02:00
|
|
|
runCommand,
|
2024-01-14 20:00:17 +02:00
|
|
|
python3Packages,
|
|
|
|
zopfli,
|
|
|
|
brotli,
|
|
|
|
findutils,
|
|
|
|
dart-sass,
|
2024-01-17 12:53:14 +02:00
|
|
|
}: let
|
|
|
|
self = stdenv.mkDerivation {
|
|
|
|
name = "e11sync-static";
|
|
|
|
src = ../app;
|
|
|
|
nativeBuildInputs = [
|
|
|
|
python3Packages.django
|
|
|
|
python3Packages.django-compressor
|
|
|
|
dart-sass
|
2024-01-17 12:59:37 +02:00
|
|
|
findutils
|
2024-01-17 12:53:14 +02:00
|
|
|
];
|
|
|
|
patchPhase = ''patchShebangs --build manage.py'';
|
|
|
|
buildPhase = ''
|
2024-01-17 12:59:37 +02:00
|
|
|
export E11SYNC_STATIC_ROOT=$PWD/static
|
2024-01-17 12:53:14 +02:00
|
|
|
export E11SYNC_DEBUG=
|
|
|
|
export E11SYNC_COMPRESS_OFFLINE=1
|
|
|
|
./manage.py collectstatic
|
|
|
|
./manage.py compress
|
2024-01-14 20:00:17 +02:00
|
|
|
|
2024-01-17 12:59:37 +02:00
|
|
|
find static/ \
|
2024-01-17 12:53:14 +02:00
|
|
|
-name '*.css' -or \
|
|
|
|
-name '*.js' -or \
|
|
|
|
-name '*.svg' | \
|
2024-01-19 13:27:41 +02:00
|
|
|
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
|
|
|
|
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli
|
2024-01-17 12:53:14 +02:00
|
|
|
'';
|
|
|
|
installPhase = ''mv static $out'';
|
2024-01-17 10:45:16 +02:00
|
|
|
|
2024-01-17 12:53:14 +02:00
|
|
|
passthru.manifest = runCommand "e11sync-static-manifest" {} ''
|
|
|
|
mkdir -p $out/CACHE
|
|
|
|
cp ${self}/CACHE/manifest.json $out/CACHE/
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
self
|