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
|
# Generated by Django 5.0.1 on 2024-01-12 10:04
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
|
@ -44,7 +44,13 @@
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
packages = {
|
packages = {
|
||||||
inherit (pkgs) e11sync-static e11sync-caddyfile e11sync-backend;
|
inherit
|
||||||
|
(pkgs)
|
||||||
|
e11sync-static
|
||||||
|
e11sync-djangostatic
|
||||||
|
e11sync-caddyfile
|
||||||
|
e11sync-backend
|
||||||
|
;
|
||||||
};
|
};
|
||||||
|
|
||||||
checks = {
|
checks = {
|
||||||
|
|
|
@ -13,6 +13,7 @@ in {
|
||||||
inherit geoip2-tarball;
|
inherit geoip2-tarball;
|
||||||
};
|
};
|
||||||
e11sync-static = withDjango5.callPackage ./pkgs/e11sync-static.nix {};
|
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-caddyfile = withDjango5.callPackage ./pkgs/e11sync-caddyfile.nix {};
|
||||||
e11sync-backend = withDjango5.callPackage ./pkgs/e11sync-backend.nix {};
|
e11sync-backend = withDjango5.callPackage ./pkgs/e11sync-backend.nix {};
|
||||||
})
|
})
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
backendPort ? 8002,
|
backendPort ? 8002,
|
||||||
databasePath ? null,
|
databasePath ? null,
|
||||||
geoip-mmdb,
|
geoip-mmdb,
|
||||||
e11sync-static,
|
e11sync-djangostatic,
|
||||||
}: let
|
}: let
|
||||||
uwsgi-python = uwsgi.override {plugins = ["python3"];};
|
uwsgi-python = uwsgi.override {plugins = ["python3"];};
|
||||||
pythonEnv = python3.withPackages (ps: [ps.django ps.geoip2]);
|
pythonEnv = python3.withPackages (ps: [ps.django ps.geoip2]);
|
||||||
|
@ -43,7 +43,7 @@ in
|
||||||
${lib.optionalString (databasePath != null) ''
|
${lib.optionalString (databasePath != null) ''
|
||||||
--set E11SYNC_DATABASE_PATH "${databasePath}" \
|
--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 E11SYNC_DEBUG "" \
|
||||||
--set GEOIP_PATH "${geoip-mmdb}" \
|
--set GEOIP_PATH "${geoip-mmdb}" \
|
||||||
'';
|
'';
|
||||||
|
@ -55,7 +55,7 @@ in
|
||||||
unpackPhase
|
unpackPhase
|
||||||
patchShebangs --build app/manage.py
|
patchShebangs --build app/manage.py
|
||||||
export GEOIP_PATH="${geoip-mmdb}"
|
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
|
app/manage.py test app
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -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,
|
runCommand,
|
||||||
python3Packages,
|
|
||||||
zopfli,
|
zopfli,
|
||||||
brotli,
|
brotli,
|
||||||
findutils,
|
findutils,
|
||||||
dart-sass,
|
e11sync-djangostatic,
|
||||||
jq,
|
}:
|
||||||
}: let
|
runCommand "e11sync-static" {
|
||||||
self = stdenv.mkDerivation {
|
src = e11sync-djangostatic;
|
||||||
name = "e11sync-static";
|
nativeBuildInputs = [findutils];
|
||||||
srcs = [../app ../static];
|
} ''
|
||||||
sourceRoot = ".";
|
unpackPhase
|
||||||
nativeBuildInputs = [
|
find e11sync-djangostatic \
|
||||||
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 \
|
|
||||||
-name '*.css' -or \
|
-name '*.css' -or \
|
||||||
-name '*.js' -or \
|
-name '*.js' -or \
|
||||||
-name '*.svg' -or \
|
-name '*.svg' -or \
|
||||||
-name '*.txt' | \
|
-name '*.txt' | \
|
||||||
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
|
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
|
||||||
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli
|
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli
|
||||||
'';
|
mv e11sync-djangostatic $out
|
||||||
installPhase = ''mv app/_static $out'';
|
''
|
||||||
|
|
||||||
passthru.manifest = runCommand "e11sync-static-manifest" {} ''
|
|
||||||
mkdir -p $out
|
|
||||||
cp ${self}/staticfiles.json $out/
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in
|
|
||||||
self
|
|
||||||
|
|
Loading…
Reference in New Issue