41 lines
911 B
Nix
41 lines
911 B
Nix
{
|
|
stdenv,
|
|
runCommand,
|
|
python3Packages,
|
|
zopfli,
|
|
brotli,
|
|
findutils,
|
|
dart-sass,
|
|
}: let
|
|
self = stdenv.mkDerivation {
|
|
name = "e11sync-static";
|
|
srcs = [../app ../static];
|
|
sourceRoot = ".";
|
|
nativeBuildInputs = [
|
|
python3Packages.django
|
|
dart-sass
|
|
findutils
|
|
];
|
|
patchPhase = ''patchShebangs --build app/manage.py'';
|
|
buildPhase = ''
|
|
export E11SYNC_DEBUG=
|
|
make -C static style.css
|
|
app/manage.py collectstatic
|
|
|
|
find app/_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 app/_static $out'';
|
|
|
|
passthru.manifest = runCommand "e11sync-static-manifest" {} ''
|
|
mkdir -p $out
|
|
cp ${self}/staticfiles.json $out/
|
|
'';
|
|
};
|
|
in
|
|
self
|