1

e11-static: contain e11sync-static

TODO: learn about `lib.makeScope`.
This commit is contained in:
Motiejus Jakštys 2024-01-17 12:53:14 +02:00
parent 450419d431
commit 33d6c66029
2 changed files with 35 additions and 36 deletions

View File

@ -53,9 +53,7 @@
inherit geoip2-tarball; inherit geoip2-tarball;
}; };
e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix { e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix {};
inherit e11sync-static;
};
e11sync-frontend = pkgs.callPackage ./pkgs/e11sync-frontend.nix { e11sync-frontend = pkgs.callPackage ./pkgs/e11sync-frontend.nix {
inherit e11sync-static; inherit e11sync-static;

View File

@ -8,38 +8,39 @@
findutils, findutils,
dart-sass, dart-sass,
gawk, gawk,
e11sync-static, }: let
}: self = stdenv.mkDerivation {
stdenv.mkDerivation { name = "e11sync-static";
name = "e11sync-static"; src = ../app;
src = ../app; nativeBuildInputs = [
nativeBuildInputs = [ python3Packages.django
python3Packages.django python3Packages.django-compressor
python3Packages.django-compressor dart-sass
dart-sass zopfli
zopfli brotli
brotli ];
]; patchPhase = ''patchShebangs --build manage.py'';
patchPhase = ''patchShebangs --build manage.py''; buildPhase = ''
buildPhase = '' mkdir -p static
mkdir -p static export E11SYNC_STATIC_ROOT=static
export E11SYNC_STATIC_ROOT=static export E11SYNC_DEBUG=
export E11SYNC_DEBUG= export E11SYNC_COMPRESS_OFFLINE=1
export E11SYNC_COMPRESS_OFFLINE=1 ./manage.py collectstatic
./manage.py collectstatic ./manage.py compress
./manage.py compress
${findutils}/bin/find static/ \ ${findutils}/bin/find static/ \
-name '*.css' -or \ -name '*.css' -or \
-name '*.js' -or \ -name '*.js' -or \
-name '*.svg' | \ -name '*.svg' | \
${gawk}/bin/awk '{print "zopfli "$0;print "brotli "$0}' | \ ${gawk}/bin/awk '{print "zopfli "$0;print "brotli "$0}' | \
${findutils}/bin/xargs -P''$(${coreutils}/bin/nproc) -I{} $SHELL -c {} ${findutils}/bin/xargs -P''$(${coreutils}/bin/nproc) -I{} $SHELL -c {}
''; '';
installPhase = ''mv static $out''; installPhase = ''mv static $out'';
passthru.manifest = runCommand "e11sync-static-manifest" {} '' passthru.manifest = runCommand "e11sync-static-manifest" {} ''
mkdir -p $out/CACHE mkdir -p $out/CACHE
cp ${e11sync-static}/CACHE/manifest.json $out/CACHE/ cp ${self}/CACHE/manifest.json $out/CACHE/
''; '';
} };
in
self