43 lines
997 B
Nix
43 lines
997 B
Nix
{
|
|
stdenv,
|
|
runCommand,
|
|
python3Packages,
|
|
zopfli,
|
|
brotli,
|
|
findutils,
|
|
dart-sass,
|
|
}: let
|
|
self = stdenv.mkDerivation {
|
|
name = "e11sync-static";
|
|
src = ../app;
|
|
nativeBuildInputs = [
|
|
python3Packages.django
|
|
python3Packages.django-compressor
|
|
dart-sass
|
|
findutils
|
|
];
|
|
patchPhase = ''patchShebangs --build manage.py'';
|
|
buildPhase = ''
|
|
export E11SYNC_STATIC_ROOT=$PWD/static
|
|
export E11SYNC_DEBUG=
|
|
export E11SYNC_COMPRESS_OFFLINE=1
|
|
./manage.py collectstatic
|
|
./manage.py compress
|
|
|
|
find static/ \
|
|
-name '*.css' -or \
|
|
-name '*.js' -or \
|
|
-name '*.svg' | \
|
|
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
|
|
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli
|
|
'';
|
|
installPhase = ''mv static $out'';
|
|
|
|
passthru.manifest = runCommand "e11sync-static-manifest" {} ''
|
|
mkdir -p $out/CACHE
|
|
cp ${self}/CACHE/manifest.json $out/CACHE/
|
|
'';
|
|
};
|
|
in
|
|
self
|