1
e11sync/pkgs/e11sync-static.nix

43 lines
997 B
Nix
Raw Normal View History

2024-01-14 20:00:17 +02:00
{
stdenv,
runCommand,
2024-01-14 20:00:17 +02:00
python3Packages,
zopfli,
brotli,
findutils,
dart-sass,
}: 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
];
patchPhase = ''patchShebangs --build manage.py'';
buildPhase = ''
2024-01-17 12:59:37 +02:00
export E11SYNC_STATIC_ROOT=$PWD/static
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/ \
-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