commit dc72e8a2a4a2573f545781dabbba932e82b24599 (tree)
parent 6499795df1910a6bfeb0f7bd798660e9c26e18a8
Author: Motiejus Jakštys <motiejus@jakstys.lt>
Date: Sun, 14 Jan 2024 20:00:17 +0200
move e11sync-static to it's own file
Diffstat:
2 files changed, 43 insertions(+), 22 deletions(-)
diff --git 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
@@ -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'';
+}