about summary refs log tree commit diff
path: root/pkgs/by-name/mo
diff options
context:
space:
mode:
authortoastal <toastal@posteo.net>2024-04-27 10:12:01 +0700
committertoastal <toastal@posteo.net>2024-04-28 16:27:01 +0700
commit13852fc9ad82314bde3de1badb4097eb7526d921 (patch)
tree6ba6a6941f567ec113ca7d6f9472eb3fe20f7c03 /pkgs/by-name/mo
parent10e3506904ab96b8ef0556f2b22e6b1a47d2ceaa (diff)
movim: remove parallel dependency
Currently there is an issue with $PATH & parallel causing build errors.
It’s probably best to just remove the dependency where bash forking is
good enough here.
Diffstat (limited to 'pkgs/by-name/mo')
-rw-r--r--pkgs/by-name/mo/movim/package.nix58
1 files changed, 24 insertions, 34 deletions
diff --git a/pkgs/by-name/mo/movim/package.nix b/pkgs/by-name/mo/movim/package.nix
index d6643e0c7d3a1..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
@@ -67,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;
 
@@ -101,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 = ''