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

47 lines
1.1 KiB
Nix

{
stdenv,
runCommand,
python3Packages,
coreutils,
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
];
patchPhase = ''patchShebangs --build manage.py'';
buildPhase = ''
mkdir -p static
export E11SYNC_STATIC_ROOT=static
export E11SYNC_DEBUG=
export E11SYNC_COMPRESS_OFFLINE=1
./manage.py collectstatic
./manage.py compress
${findutils}/bin/find static/ \
-name '*.css' -or \
-name '*.js' -or \
-name '*.svg' | \
${gawk}/bin/awk '{print "zopfli "$0;print "brotli "$0}' | \
${findutils}/bin/xargs -P''$(${coreutils}/bin/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