about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2024-04-29 09:34:08 +0200
committerGitHub <noreply@github.com>2024-04-29 09:34:08 +0200
commit368b2d71b474364c86a67f09b5aeb8e56ebbbeb3 (patch)
tree8fdf841e377c9bd24b5a6e9b40417948da1bcc2a
parente40ae4e4148a313078aa5ed444796dbe855b5482 (diff)
parent13852fc9ad82314bde3de1badb4097eb7526d921 (diff)
Merge pull request #307130 from toastal/movim-no-parallel
movim: include authentication patch & remove parallel dependency
-rw-r--r--nixos/modules/services/web-apps/movim.nix22
-rw-r--r--pkgs/by-name/mo/movim/package.nix65
2 files changed, 41 insertions, 46 deletions
diff --git a/nixos/modules/services/web-apps/movim.nix b/nixos/modules/services/web-apps/movim.nix
index bb88a185b4618..29bed0e067fa4 100644
--- a/nixos/modules/services/web-apps/movim.nix
+++ b/nixos/modules/services/web-apps/movim.nix
@@ -103,22 +103,20 @@ let
           lib.concatStringsSep "\n" [
             (lib.optionalString brotli.enable ''
               echo -n "Precompressing static files with Brotli …"
-              find ${appDir}/public -type f ${findTextFileNames} \
-                | ${lib.getExe pkgs.parallel} ${lib.escapeShellArgs [
-                    "--will-cite"
-                    "-j $NIX_BUILD_CORES"
-                    "${lib.getExe brotli.package} --keep --quality=${builtins.toString brotli.compressionLevel} --output={}.br {}"
-                   ]}
+              find ${appDir}/public -type f ${findTextFileNames} -print0 \
+                | xargs -0 -n 1 -P $NIX_BUILD_CORES ${pkgs.writeShellScript "movim_precompress_broti" ''
+                    file="$1"
+                    ${lib.getExe brotli.package} --keep --quality=${builtins.toString brotli.compressionLevel} --output=$file.br $file
+                  ''}
               echo " done."
             '')
             (lib.optionalString gzip.enable ''
               echo -n "Precompressing static files with Gzip …"
-              find ${appDir}/public -type f ${findTextFileNames} \
-                | ${lib.getExe pkgs.parallel} ${lib.escapeShellArgs [
-                    "--will-cite"
-                    "-j $NIX_BUILD_CORES"
-                    "${lib.getExe gzip.package} -c -${builtins.toString gzip.compressionLevel} {} > {}.gz"
-                   ]}
+              find ${appDir}/public -type f ${findTextFileNames} -print0 \
+                | xargs -0 -n 1 -P $NIX_BUILD_CORES ${pkgs.writeShellScript "movim_precompress_broti" ''
+                    file="$1"
+                    ${lib.getExe gzip.package} -c -${builtins.toString gzip.compressionLevel} $file > $file.gz
+                  ''}
               echo " done."
             '')
           ];
diff --git a/pkgs/by-name/mo/movim/package.nix b/pkgs/by-name/mo/movim/package.nix
index 1c0d5863dfa15..20dd5165d26e5 100644
--- a/pkgs/by-name/mo/movim/package.nix
+++ b/pkgs/by-name/mo/movim/package.nix
@@ -1,13 +1,13 @@
 { lib
 , fetchpatch
 , fetchFromGitHub
+, writeShellScript
 , dash
 , php
 , phpCfg ? null
 , withPgsql ? true # “strongly recommended” according to docs
 , withMysql ? false
 , minifyStaticFiles ? false # default files are often not minified
-, parallel
 , esbuild
 , lightningcss
 , scour
@@ -48,6 +48,13 @@ php.buildComposerProject (finalAttrs: {
     hash = "sha256-t63POjywZLk5ulppuCedFhhEhOsnB90vy3k/HhM3MGc=";
   };
 
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/movim/movim/commit/4dd2842f4617f3baaa166157892a532ad07df80d.patch";
+      hash = "sha256-32MLS5g60Rhm8HQDBPnUo9k+aB7L8dNMcnSjPIlooks=";
+    })
+  ];
+
   php = php.buildEnv ({
     extensions = ({ all, enabled }:
       enabled
@@ -60,8 +67,7 @@ php.buildComposerProject (finalAttrs: {
   });
 
   nativeBuildInputs =
-    lib.optional (lib.any (x: x.enable) (lib.attrValues minify)) parallel
-    ++ lib.optional minify.script.enable esbuild
+    lib.optional minify.script.enable esbuild
     ++ lib.optional minify.style.enable lightningcss
     ++ lib.optional minify.svg.enable scour;
 
@@ -94,39 +100,30 @@ php.buildComposerProject (finalAttrs: {
   '';
 
   preBuild = lib.optionalString minify.script.enable ''
-    find ./public -type f -iname "*.js" \
-      | parallel ${lib.escapeShellArgs [
-          "--will-cite"
-          "-j $NIX_BUILD_CORES"
-          ''
-            tmp="$(mktemp)"
-            esbuild {} --minify --target=${lib.escapeShellArg minify.script.target} --outfile=$tmp
-            [[ "$(stat -c %s $tmp)" -lt "$(stat -c %s {})" ]] && mv $tmp {}
-          ''
-        ]}
+    find ./public -type f -iname "*.js" -print0 \
+      | xargs -0 -n 1 -P $NIX_BUILD_CORES ${writeShellScript "movim_script_minify" ''
+          file="$1"
+          tmp="$(mktemp)"
+          esbuild $file --minify --target=${lib.escapeShellArg minify.script.target} --outfile=$tmp
+          [[ "$(stat -c %s $tmp)" -lt "$(stat -c %s $file)" ]] && mv $tmp $file
+        ''}
   '' + lib.optionalString minify.style.enable ''
-    export BROWSERLIST=${lib.escapeShellArg minify.style.browserslist}
-    find ./public -type f -iname "*.css" \
-      | parallel ${lib.escapeShellArgs [
-          "--will-cite"
-          "-j $NIX_BUILD_CORES"
-          ''
-            tmp="$(mktemp)"
-            lightningcss {} --minify --browserslist --output-file=$tmp
-            [[ "$(stat -c %s $tmp)" -lt "$(stat -c %s {})" ]] && mv $tmp {}
-          ''
-        ]}
+    find ./public -type f -iname "*.css" -print0 \
+      | xargs -0 -n 1 -P $NIX_BUILD_CORES ${writeShellScript "movim_style_minify" ''
+          export BROWSERLIST="${lib.escapeShellArg minify.style.browserslist}"
+          file="$1"
+          tmp="$(mktemp)"
+          lightningcss $file --minify --browserslist --output-file=$tmp
+          [[ "$(stat -c %s $tmp)" -lt "$(stat -c %s $file)" ]] && mv $tmp $file
+        ''}
   '' + lib.optionalString minify.svg.enable ''
-    find ./public -type f -iname "*.svg" -a -not -path "*/emojis/*" \
-      | parallel ${lib.escapeShellArgs [
-          "--will-cite"
-          "-j $NIX_BUILD_CORES"
-          ''
-            tmp="$(mktemp)"
-            scour -i {} -o $tmp --disable-style-to-xml --enable-comment-stripping --enable-viewboxing --indent=tab
-            [[ "$(stat -c %s $tmp)" -lt "$(stat -c %s {})" ]] && mv $tmp {}
-          ''
-        ]}
+    find ./public -type f -iname "*.svg" -a -not -path "*/emojis/*" -print0 \
+      | xargs -0 -n 1 -P $NIX_BUILD_CORES ${writeShellScript "movim_svg_minify" ''
+          file="$1"
+          tmp="$(mktemp)"
+          scour -i $file -o $tmp --disable-style-to-xml --enable-comment-stripping --enable-viewboxing --indent=tab
+          [[ "$(stat -c %s $tmp)" -lt "$(stat -c %s $file)" ]] && mv $tmp $file
+        ''}
   '';
 
   postInstall = ''