split out e11sync-djangostatic from e11sync-static
This commit is contained in:
parent
287d0fe9ba
commit
513b2cf00d
@ -1,3 +1,4 @@
|
||||
# flake8: noqa
|
||||
# Generated by Django 5.0.1 on 2024-01-12 10:04
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -44,7 +44,13 @@
|
||||
};
|
||||
in {
|
||||
packages = {
|
||||
inherit (pkgs) e11sync-static e11sync-caddyfile e11sync-backend;
|
||||
inherit
|
||||
(pkgs)
|
||||
e11sync-static
|
||||
e11sync-djangostatic
|
||||
e11sync-caddyfile
|
||||
e11sync-backend
|
||||
;
|
||||
};
|
||||
|
||||
checks = {
|
||||
|
@ -13,6 +13,7 @@ in {
|
||||
inherit geoip2-tarball;
|
||||
};
|
||||
e11sync-static = withDjango5.callPackage ./pkgs/e11sync-static.nix {};
|
||||
e11sync-djangostatic = withDjango5.callPackage ./pkgs/e11sync-djangostatic.nix {};
|
||||
e11sync-caddyfile = withDjango5.callPackage ./pkgs/e11sync-caddyfile.nix {};
|
||||
e11sync-backend = withDjango5.callPackage ./pkgs/e11sync-backend.nix {};
|
||||
})
|
||||
|
@ -9,7 +9,7 @@
|
||||
backendPort ? 8002,
|
||||
databasePath ? null,
|
||||
geoip-mmdb,
|
||||
e11sync-static,
|
||||
e11sync-djangostatic,
|
||||
}: let
|
||||
uwsgi-python = uwsgi.override {plugins = ["python3"];};
|
||||
pythonEnv = python3.withPackages (ps: [ps.django ps.geoip2]);
|
||||
@ -43,7 +43,7 @@ in
|
||||
${lib.optionalString (databasePath != null) ''
|
||||
--set E11SYNC_DATABASE_PATH "${databasePath}" \
|
||||
''} \
|
||||
--set E11SYNC_STATIC_ROOT "${e11sync-static.passthru.manifest}" \
|
||||
--set E11SYNC_STATIC_ROOT "${e11sync-djangostatic.passthru.manifest}" \
|
||||
--set E11SYNC_DEBUG "" \
|
||||
--set GEOIP_PATH "${geoip-mmdb}" \
|
||||
'';
|
||||
@ -55,7 +55,7 @@ in
|
||||
unpackPhase
|
||||
patchShebangs --build app/manage.py
|
||||
export GEOIP_PATH="${geoip-mmdb}"
|
||||
export E11SYNC_STATIC_ROOT="${e11sync-static.passthru.manifest}"
|
||||
export E11SYNC_STATIC_ROOT="${e11sync-djangostatic.passthru.manifest}"
|
||||
app/manage.py test app
|
||||
mkdir -p $out
|
||||
'';
|
||||
|
36
pkgs/e11sync-djangostatic.nix
Normal file
36
pkgs/e11sync-djangostatic.nix
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
stdenv,
|
||||
runCommand,
|
||||
python3Packages,
|
||||
findutils,
|
||||
dart-sass,
|
||||
jq,
|
||||
}: let
|
||||
self = stdenv.mkDerivation {
|
||||
name = "e11sync-djangostatic";
|
||||
srcs = [../app ../static];
|
||||
sourceRoot = ".";
|
||||
nativeBuildInputs = [
|
||||
python3Packages.django
|
||||
dart-sass
|
||||
findutils
|
||||
];
|
||||
patchPhase = ''patchShebangs --build app/manage.py'';
|
||||
buildPhase = ''
|
||||
make -C static style.css
|
||||
app/manage.py collectstatic
|
||||
|
||||
# remove unversioned files
|
||||
pushd app/_static
|
||||
${jq}/bin/jq -r '.paths | keys[]' staticfiles.json | xargs rm
|
||||
popd
|
||||
'';
|
||||
installPhase = ''find; mv app/_static $out'';
|
||||
|
||||
passthru.manifest = runCommand "e11sync-djangostatic-manifest" {} ''
|
||||
mkdir -p $out
|
||||
cp ${self}/staticfiles.json $out/
|
||||
'';
|
||||
};
|
||||
in
|
||||
self
|
@ -1,46 +1,21 @@
|
||||
{
|
||||
stdenv,
|
||||
runCommand,
|
||||
python3Packages,
|
||||
zopfli,
|
||||
brotli,
|
||||
findutils,
|
||||
dart-sass,
|
||||
jq,
|
||||
}: let
|
||||
self = stdenv.mkDerivation {
|
||||
name = "e11sync-static";
|
||||
srcs = [../app ../static];
|
||||
sourceRoot = ".";
|
||||
nativeBuildInputs = [
|
||||
python3Packages.django
|
||||
dart-sass
|
||||
findutils
|
||||
];
|
||||
patchPhase = ''patchShebangs --build app/manage.py'';
|
||||
buildPhase = ''
|
||||
make -C static style.css
|
||||
app/manage.py collectstatic
|
||||
|
||||
# remove unversioned files
|
||||
(cd app/_static;
|
||||
${jq}/bin/jq -r '.paths | keys[]' staticfiles.json | xargs rm
|
||||
)
|
||||
|
||||
find app/_static \
|
||||
e11sync-djangostatic,
|
||||
}:
|
||||
runCommand "e11sync-static" {
|
||||
src = e11sync-djangostatic;
|
||||
nativeBuildInputs = [findutils];
|
||||
} ''
|
||||
unpackPhase
|
||||
find e11sync-djangostatic \
|
||||
-name '*.css' -or \
|
||||
-name '*.js' -or \
|
||||
-name '*.svg' -or \
|
||||
-name '*.txt' | \
|
||||
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
|
||||
mv e11sync-djangostatic $out
|
||||
''
|
||||
|
Loading…
Reference in New Issue
Block a user