From 33d6c6602927968a244b79441697af44c09dd25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Wed, 17 Jan 2024 12:53:14 +0200 Subject: [PATCH] e11-static: contain `e11sync-static` TODO: learn about `lib.makeScope`. --- flake.nix | 4 +-- pkgs/e11sync-static.nix | 67 +++++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/flake.nix b/flake.nix index 8950e10..46cd576 100644 --- a/flake.nix +++ b/flake.nix @@ -53,9 +53,7 @@ inherit geoip2-tarball; }; - e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix { - inherit e11sync-static; - }; + e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix {}; e11sync-frontend = pkgs.callPackage ./pkgs/e11sync-frontend.nix { inherit e11sync-static; diff --git a/pkgs/e11sync-static.nix b/pkgs/e11sync-static.nix index a0a1710..0a1e0b7 100644 --- a/pkgs/e11sync-static.nix +++ b/pkgs/e11sync-static.nix @@ -8,38 +8,39 @@ findutils, dart-sass, gawk, - e11sync-static, -}: -stdenv.mkDerivation { - name = "e11sync-static"; - src = ../app; - nativeBuildInputs = [ - python3Packages.django - python3Packages.django-compressor - dart-sass - zopfli - brotli - ]; - patchPhase = ''patchShebangs --build manage.py''; - buildPhase = '' - mkdir -p static - export E11SYNC_STATIC_ROOT=static - export E11SYNC_DEBUG= - export E11SYNC_COMPRESS_OFFLINE=1 - ./manage.py collectstatic - ./manage.py compress +}: let + self = stdenv.mkDerivation { + name = "e11sync-static"; + src = ../app; + nativeBuildInputs = [ + python3Packages.django + python3Packages.django-compressor + dart-sass + zopfli + brotli + ]; + patchPhase = ''patchShebangs --build manage.py''; + buildPhase = '' + mkdir -p static + export E11SYNC_STATIC_ROOT=static + export E11SYNC_DEBUG= + export E11SYNC_COMPRESS_OFFLINE=1 + ./manage.py collectstatic + ./manage.py compress - ${findutils}/bin/find static/ \ - -name '*.css' -or \ - -name '*.js' -or \ - -name '*.svg' | \ - ${gawk}/bin/awk '{print "zopfli "$0;print "brotli "$0}' | \ - ${findutils}/bin/xargs -P''$(${coreutils}/bin/nproc) -I{} $SHELL -c {} - ''; - installPhase = ''mv static $out''; + ${findutils}/bin/find static/ \ + -name '*.css' -or \ + -name '*.js' -or \ + -name '*.svg' | \ + ${gawk}/bin/awk '{print "zopfli "$0;print "brotli "$0}' | \ + ${findutils}/bin/xargs -P''$(${coreutils}/bin/nproc) -I{} $SHELL -c {} + ''; + installPhase = ''mv static $out''; - passthru.manifest = runCommand "e11sync-static-manifest" {} '' - mkdir -p $out/CACHE - cp ${e11sync-static}/CACHE/manifest.json $out/CACHE/ - ''; -} + passthru.manifest = runCommand "e11sync-static-manifest" {} '' + mkdir -p $out/CACHE + cp ${self}/CACHE/manifest.json $out/CACHE/ + ''; + }; +in + self