1
Fork 0

move e11sync-static to it's own file

This commit is contained in:
Motiejus Jakštys 2024-01-14 20:00:17 +02:00
parent 6499795df1
commit dc72e8a2a4
2 changed files with 43 additions and 22 deletions

View File

@ -32,10 +32,6 @@
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
appDeps = with pkgs.python3Packages; [django_5 django-compressor];
runtimeDeps = with pkgs; appDeps ++ [python3Packages.geoip2 libmaxminddb];
buildDeps = with pkgs; appDeps ++ [dart-sass];
geoip-archive = pkgs.stdenv.mkDerivation {
name = "geoip-archive";
srcs = [geoip2-asn geoip2-city geoip2-country];
@ -48,23 +44,8 @@
'';
};
in rec {
packages.e11sync-static = pkgs.stdenv.mkDerivation {
name = "e11sync-static";
src = self;
nativeBuildInputs = buildDeps;
buildPhase = with pkgs; ''
mkdir -p static
export E11SYNC_STATIC_ROOT=static
export E11SYNC_DEBUG=
export E11SYNC_COMPRESS_OFFLINE=1
${python3}/bin/python3 ${self}/app/manage.py collectstatic
${python3}/bin/python3 ${self}/app/manage.py compress
${findutils}/bin/find static/CACHE -name '*.css' | \
${findutils}/bin/xargs -P''$(${coreutils}/bin/nproc) -I{} sh -c \
"${zopfli}/bin/zopfli {} && ${brotli}/bin/brotli {}"
'';
installPhase = ''mv static $out'';
packages.e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix {
inherit self;
};
packages.e11sync = pkgs.callPackage ./pkgs/e11sync.nix {
inherit self geoip-archive;
@ -84,8 +65,15 @@
};
devShells.default = pkgs.mkShellNoCC {
packages = [pkgs.python3Packages.django-debug-toolbar] ++ runtimeDeps ++ buildDeps;
packages = with pkgs; [
python3Packages.django-debug-toolbar
python3Packages.django_5
python3Packages.django-compressor
python3Packages.geoip2
libmaxminddb
dart-sass
];
GEOIP_PATH = "${geoip-archive}";
E11SYNC_DEBUG = "1";
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";

33
pkgs/e11sync-static.nix Normal file
View File

@ -0,0 +1,33 @@
{
self,
stdenv,
python3,
python3Packages,
coreutils,
zopfli,
brotli,
findutils,
dart-sass,
}:
stdenv.mkDerivation {
name = "e11sync-static";
src = self;
nativeBuildInputs = [
python3Packages.django_5
python3Packages.django-compressor
dart-sass
];
buildPhase = ''
mkdir -p static
export E11SYNC_STATIC_ROOT=static
export E11SYNC_DEBUG=
export E11SYNC_COMPRESS_OFFLINE=1
${python3}/bin/python3 ${self}/app/manage.py collectstatic
${python3}/bin/python3 ${self}/app/manage.py compress
${findutils}/bin/find static/CACHE -name '*.css' | \
${findutils}/bin/xargs -P''$(${coreutils}/bin/nproc) -I{} sh -c \
"${zopfli}/bin/zopfli {} && ${brotli}/bin/brotli {}"
'';
installPhase = ''mv static $out'';
}