From dc72e8a2a4a2573f545781dabbba932e82b24599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Sun, 14 Jan 2024 20:00:17 +0200 Subject: [PATCH] move e11sync-static to it's own file --- flake.nix | 32 ++++++++++---------------------- pkgs/e11sync-static.nix | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 pkgs/e11sync-static.nix diff --git a/flake.nix b/flake.nix index a05d49f..85a80f8 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; diff --git a/pkgs/e11sync-static.nix b/pkgs/e11sync-static.nix new file mode 100644 index 0000000..db1a67c --- /dev/null +++ b/pkgs/e11sync-static.nix @@ -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''; +}