about summary refs log tree commit diff
path: root/pkgs/servers/peertube
diff options
context:
space:
mode:
authorIzorkin <izorkin@elven.pw>2022-09-13 15:52:40 +0300
committerIzorkin <izorkin@elven.pw>2022-10-17 16:30:34 +0300
commit06f1cdf56ce95b4cc47a35249e5dd62b43f8746b (patch)
tree6a0937793ba82da4a596e48a609770428e8ac334 /pkgs/servers/peertube
parent98fd494fd0f957639d128206e6315bde1bb23adb (diff)
peertube: create static gzip and brotli files
Diffstat (limited to 'pkgs/servers/peertube')
-rw-r--r--pkgs/servers/peertube/default.nix23
1 files changed, 9 insertions, 14 deletions
diff --git a/pkgs/servers/peertube/default.nix b/pkgs/servers/peertube/default.nix
index 29e082e65cf2e..9ddad4fad1e89 100644
--- a/pkgs/servers/peertube/default.nix
+++ b/pkgs/servers/peertube/default.nix
@@ -1,16 +1,5 @@
-{ lib
-, stdenv
-, callPackage
-, fetchurl
-, fetchFromGitHub
-, buildGoModule
-, fetchYarnDeps
-, nixosTests
-, fixup_yarn_lock
-, jq
-, nodejs
-, which
-, yarn
+{ lib, stdenv, callPackage, fetchurl, fetchFromGitHub, fetchYarnDeps, nixosTests
+, brotli, fixup_yarn_lock, jq, nodejs, which, yarn
 }:
 let
   arch =
@@ -49,7 +38,7 @@ in stdenv.mkDerivation rec {
     hash = "sha256-IKMu+gQa+d30+yXjHCu/oQOQXL6kTN9WxDI/Y5IL1E8=";
   };
 
-  nativeBuildInputs = [ fixup_yarn_lock jq nodejs which yarn ];
+  nativeBuildInputs = [ brotli fixup_yarn_lock jq nodejs which yarn ];
 
   buildPhase = ''
     # Build node modules
@@ -105,6 +94,12 @@ in stdenv.mkDerivation rec {
     mkdir $out/client
     mv ~/client/{dist,node_modules,package.json,yarn.lock} $out/client
     mv ~/{config,scripts,support,CREDITS.md,FAQ.md,LICENSE,README.md,package.json,tsconfig.json,yarn.lock} $out
+
+    # Create static gzip and brotli files
+    find $out/client/dist -type f -regextype posix-extended -iregex '.*\.(css|eot|html|js|json|svg|webmanifest|xlf)' | while read file; do
+      gzip -9 -n -c $file > $file.gz
+      brotli --best -f $file -o $file.br
+    done
   '';
 
   passthru.tests.peertube = nixosTests.peertube;