about summary refs log tree commit diff
path: root/pkgs/data/fonts/input-fonts/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/data/fonts/input-fonts/default.nix')
-rw-r--r--pkgs/data/fonts/input-fonts/default.nix35
1 files changed, 24 insertions, 11 deletions
diff --git a/pkgs/data/fonts/input-fonts/default.nix b/pkgs/data/fonts/input-fonts/default.nix
index a5ffc2ec33a58..dc990b6e42db7 100644
--- a/pkgs/data/fonts/input-fonts/default.nix
+++ b/pkgs/data/fonts/input-fonts/default.nix
@@ -4,6 +4,8 @@
 , python3
 , config
 , acceptLicense ? config.input-fonts.acceptLicense or false
+, parallel
+, writeShellApplication
 }:
 
 let
@@ -44,17 +46,28 @@ stdenv.mkDerivation rec {
       sha256 = "BESZ4Bjgm2hvQ7oPpMvYSlE8EqvQjqHZtXWIovqyIzA=";
       stripRoot = false;
 
-      postFetch = ''
-        # Reset the timestamp to release date for determinism.
-        PATH=${lib.makeBinPath [ python3.pkgs.fonttools ]}:$PATH
-        for ttf_file in $out/Input_Fonts/*/*/*.ttf; do
-          ttx_file=$(dirname "$ttf_file")/$(basename "$ttf_file" .ttf).ttx
-          ttx "$ttf_file"
-          rm "$ttf_file"
-          touch -m -t ${builtins.replaceStrings [ "-" ] [ "" ] releaseDate}0000 "$ttx_file"
-          ttx --recalc-timestamp "$ttx_file"
-          rm "$ttx_file"
-        done
+      # Reset the timestamp to release date for determinism.
+      postFetch = let
+        ttf-fixup = writeShellApplication {
+          name = "ttf-fixup";
+          runtimeInputs = [ python3.pkgs.fonttools ];
+          text = ''
+            if [ $# != 1 ]; then
+              echo "Usage: $0 <file.ttf>: Resets timestamp on <file.ttf> for determinism" >&2
+              exit 1
+            fi
+
+            ttf_file="$1"
+            ttx_file=$(dirname "$ttf_file")/$(basename "$ttf_file" .ttf).ttx
+            ttx "$ttf_file"
+            rm "$ttf_file"
+            touch -m -t ${builtins.replaceStrings [ "-" ] [ "" ] releaseDate}0000 "$ttx_file"
+            ttx --recalc-timestamp "$ttx_file"
+            rm "$ttx_file"
+          '';
+        };
+      in ''
+        find $out/Input_Fonts -type f -name '*.ttf' -print0 | ${lib.getExe parallel} -0 -j $NIX_BUILD_CORES ${lib.getExe ttf-fixup} {}
       '';
     };