From 94cddde66f732cefcb850773d245bdab8d541159 Mon Sep 17 00:00:00 2001
From: volth <volth@webmaster.ms>
Date: Sat, 19 Aug 2017 06:27:59 +0000
Subject: [PATCH] liberation_ttf: make derivation fixed-output

- [x] make derivation fixed-output
- [x] change upstream domain. fedorahosted.org -> pagure.{org,io}
---
 .../fonts/redhat-liberation-fonts/default.nix | 33 +++++++++++++------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/pkgs/data/fonts/redhat-liberation-fonts/default.nix b/pkgs/data/fonts/redhat-liberation-fonts/default.nix
index a0511c6a353..3fbcefc3187 100644
--- a/pkgs/data/fonts/redhat-liberation-fonts/default.nix
+++ b/pkgs/data/fonts/redhat-liberation-fonts/default.nix
@@ -4,23 +4,27 @@ let
   inherit (python2.pkgs) fonttools;
 
   common =
-    {version, url, sha256, buildInputs}:
+    {version, url, sha256, buildInputs, postPatch ? null, outputHash}:
     stdenv.mkDerivation rec {
       name = "liberation-fonts-${version}";
       src = fetchurl {
         inherit url sha256;
       };
 
-      inherit buildInputs;
+      inherit buildInputs postPatch;
 
       installPhase = ''
         mkdir -p $out/share/fonts/truetype
         cp -v $( find . -name '*.ttf') $out/share/fonts/truetype
 
-        mkdir -p "$out/doc/${name}"
-        cp -v AUTHORS ChangeLog COPYING License.txt README "$out/doc/${name}" || true
+        mkdir -p "$out/share/doc/${name}"
+        cp -v AUTHORS ChangeLog COPYING License.txt README "$out/share/doc/${name}" || true
       '';
 
+      outputHashAlgo = "sha256";
+      outputHashMode = "recursive";
+      inherit outputHash;
+
       meta = with stdenv.lib; {
         description = "Liberation Fonts, replacements for Times New Roman, Arial, and Courier New";
         longDescription = ''
@@ -36,7 +40,7 @@ let
         '';
 
         license = licenses.ofl;
-        homepage = https://fedorahosted.org/liberation-fonts/;
+        homepage = https://pagure.io/liberation-fonts/;
         maintainers = [
           maintainers.raskin
         ];
@@ -47,26 +51,35 @@ let
 in {
   liberation_ttf_v1_from_source = common rec {
     version = "1.07.4";
-    url = "https://fedorahosted.org/releases/l/i/liberation-fonts/liberation-fonts-${version}.tar.gz";
+    url = "https://releases.pagure.org/liberation-fonts/liberation-fonts-${version}.tar.gz";
     sha256 = "01jlg88q2s6by7qv6fmnrlx0lwjarrjrpxv811zjz6f2im4vg65d";
-    buildInputs = [ fontforge fonttools ];
+    buildInputs = [ fontforge ];
+    outputHash = "1q102rmg4004p74f8m4y8a6iklmnva0q39sq260jsq3lhcfypg7p";
   };
   liberation_ttf_v1_binary = common rec {
     version = "1.07.4";
-    url = "https://fedorahosted.org/releases/l/i/liberation-fonts/liberation-fonts-ttf-${version}.tar.gz";
+    url = "https://releases.pagure.org/liberation-fonts/liberation-fonts-ttf-${version}.tar.gz";
     sha256 = "0p7frz29pmjlk2d0j2zs5kfspygwdnpzxkb2hwzcfhrafjvf59v1";
     buildInputs = [ ];
+    outputHash = "12gwb9b4ij9d93ky4c9ykgp03fqr62axy37pds88q7y6zgciwkab";
   };
   liberation_ttf_v2_from_source = common rec {
     version = "2.00.1";
-    url = "https://fedorahosted.org/releases/l/i/liberation-fonts/liberation-fonts-${version}.tar.gz";
+    url = "https://releases.pagure.org/liberation-fonts/liberation-fonts-${version}.tar.gz";
     sha256 = "1ymryvd2nw4jmw4w5y1i3ll2dn48rpkqzlsgv7994lk6qc9cdjvs";
     buildInputs = [ fontforge fonttools ];
+    postPatch = ''
+      substituteInPlace scripts/setisFixedPitch-fonttools.py --replace \
+        'font = ttLib.TTFont(fontfile)' \
+        'font = ttLib.TTFont(fontfile, recalcTimestamp=False)'
+    '';
+    outputHash = "0nldgawm0a6lpn86w4w3rzx01ns3ph09ar1knq1g4jkxc8ci5rqn";
   };
   liberation_ttf_v2_binary = common rec {
     version = "2.00.1";
-    url = "https://fedorahosted.org/releases/l/i/liberation-fonts/liberation-fonts-ttf-${version}.tar.gz";
+    url = "https://releases.pagure.org/liberation-fonts/liberation-fonts-ttf-${version}.tar.gz";
     sha256 = "010m4zfqan4w04b6bs9pm3gapn9hsb18bmwwgp2p6y6idj52g43q";
     buildInputs = [ ];
+    outputHash = "19jky9li345zsig9pcb0rnlsjqqclh7r60vbi4pwh16f14850gpk";
   };
 }