1
Fork 0
e11sync/pkgs/e11sync-static.nix

47 lines
1.0 KiB
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,
gawk,
}: let
self = stdenv.mkDerivation {
name = "e11sync-static";
src = ../app;
nativeBuildInputs = [
python3Packages.django
python3Packages.django-compressor
dart-sass
zopfli
brotli
2024-01-17 12:59:37 +02:00
gawk
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' | \
2024-01-17 12:59:37 +02:00
awk '{print "zopfli \""$0"\"";print "brotli \""$0"\""}' | \
xargs -P''$(nproc) -I{} $SHELL -c {}
'';
installPhase = ''mv static $out'';
passthru.manifest = runCommand "e11sync-static-manifest" {} ''
mkdir -p $out/CACHE
cp ${self}/CACHE/manifest.json $out/CACHE/
'';
};
in
self