diff --git a/pkgs/data/fonts/source-code-pro/default.nix b/pkgs/data/fonts/source-code-pro/default.nix index 37273530bb5c..c94e9aaca480 100644 --- a/pkgs/data/fonts/source-code-pro/default.nix +++ b/pkgs/data/fonts/source-code-pro/default.nix @@ -1,14 +1,22 @@ -# when changing this expression convert it from 'fetchzip' to 'stdenvNoCC.mkDerivation' -{ lib, fetchzip }: +{ lib, stdenvNoCC, fetchzip }: -let +stdenvNoCC.mkDerivation rec { + pname = "source-code-pro"; version = "2.038"; -in (fetchzip { - name = "source-code-pro-${version}"; - url = "https://github.com/adobe-fonts/source-code-pro/releases/download/${version}R-ro%2F1.058R-it%2F1.018R-VAR/OTF-source-code-pro-${version}R-ro-1.058R-it.zip"; + src = fetchzip { + url = "https://github.com/adobe-fonts/source-code-pro/releases/download/${version}R-ro%2F1.058R-it%2F1.018R-VAR/OTF-source-code-pro-${version}R-ro-1.058R-it.zip"; + stripRoot = false; + hash = "sha256-ijeTLka131jf6B9xj/eNWK1T5r7r3aBXBgnVyRAxmuY="; + }; - sha256 = "027cf62zj27q7l3d4sqzdfgz423lzysihdg8cvmkk6z910a1v368"; + installPhase = '' + runHook preInstall + + install -Dm644 *.otf -t $out/share/fonts/opentype + + runHook postInstall + ''; meta = { description = "Monospaced font family for user interface and coding environments"; @@ -17,9 +25,4 @@ in (fetchzip { homepage = "https://adobe-fonts.github.io/source-code-pro/"; license = lib.licenses.ofl; }; -}).overrideAttrs (_: { - postFetch = '' - mkdir -p $out/share/fonts - unzip -j $downloadedFile \*.otf -d $out/share/fonts/opentype - ''; -}) +} diff --git a/pkgs/data/fonts/source-han-code-jp/default.nix b/pkgs/data/fonts/source-han-code-jp/default.nix index 076291ab8893..2a64680ee19b 100644 --- a/pkgs/data/fonts/source-han-code-jp/default.nix +++ b/pkgs/data/fonts/source-han-code-jp/default.nix @@ -1,15 +1,21 @@ -# when changing this expression convert it from 'fetchzip' to 'stdenvNoCC.mkDerivation' -{ lib, fetchzip }: +{ lib, stdenvNoCC, fetchzip }: -let +stdenvNoCC.mkDerivation rec { pname = "source-han-code-jp"; - version = "2.012R"; -in (fetchzip { - name = "${pname}-${version}"; + version = "2.012"; - url = "https://github.com/adobe-fonts/${pname}/archive/${version}.zip"; + src = fetchzip { + url = "https://github.com/adobe-fonts/${pname}/archive/${version}R.zip"; + hash = "sha256-ljO/1/CaE9Yj+AN5xxlIr30/nV/axGQPO0fGACAZGCQ="; + }; - sha256 = "16y5as1k864ghy3vzp8svr3q0sw57rv53za3f48700ksvxz5pwry"; + installPhase = '' + runHook preInstall + + install -Dm444 OTF/*.otf -t $out/share/fonts/opentype + + runHook postInstall + ''; meta = { description = "A monospaced Latin font suitable for coding"; @@ -18,9 +24,4 @@ in (fetchzip { homepage = "https://blogs.adobe.com/CCJKType/2015/06/source-han-code-jp.html"; license = lib.licenses.ofl; }; -}).overrideAttrs (_: { - postFetch = '' - mkdir -p $out/share/fonts - unzip -j $downloadedFile \*.otf -d $out/share/fonts/opentype - ''; -}) +} diff --git a/pkgs/data/fonts/source-han/default.nix b/pkgs/data/fonts/source-han/default.nix index edf8ecfaa49f..2f9111865455 100644 --- a/pkgs/data/fonts/source-han/default.nix +++ b/pkgs/data/fonts/source-han/default.nix @@ -1,7 +1,7 @@ -# when changing this expression convert it from 'fetchzip' to 'stdenvNoCC.mkDerivation' -{ stdenvNoCC -, lib -, fetchzip +{ lib +, stdenvNoCC +, fetchurl +, unzip }: let @@ -9,21 +9,37 @@ let { family , description , rev - , sha256 - , postFetch ? '' - install -m444 -Dt $out/share/fonts/opentype/source-han-${family} $downloadedFile - '' + , hash , zip ? "" }: let Family = lib.toUpper (lib.substring 0 1 family) + lib.substring 1 (lib.stringLength family) family; in - (fetchzip { - name = "source-han-${family}-${lib.removeSuffix "R" rev}"; + stdenvNoCC.mkDerivation rec { + pname = "source-han-${family}"; + version = lib.removeSuffix "R" rev; - url = "https://github.com/adobe-fonts/source-han-${family}/releases/download/${rev}/SourceHan${Family}.ttc${zip}"; - inherit sha256; + src = fetchurl { + url = "https://github.com/adobe-fonts/source-han-${family}/releases/download/${rev}/SourceHan${Family}.ttc${zip}"; + inherit hash; + }; + + nativeBuildInputs = lib.optionals (zip == ".zip") [ unzip ]; + + unpackPhase = lib.optionalString (zip == "") '' + cp $src SourceHan${Family}.ttc${zip} + '' + lib.optionalString (zip == ".zip") '' + unzip $src + ''; + + installPhase = '' + runHook preInstall + + install -Dm444 *.ttc -t $out/share/fonts/opentype/${pname} + + runHook postInstall + ''; meta = { description = "An open source Pan-CJK ${description} typeface"; @@ -31,18 +47,14 @@ let license = lib.licenses.ofl; maintainers = with lib.maintainers; [ taku0 emily ]; }; - }).overrideAttrs (_: { inherit postFetch; }); + }; in { sans = makePackage { family = "sans"; description = "sans-serif"; rev = "2.004R"; - sha256 = "052d17hvz435zc4r2y1p9cgkkgn0ps8g74mfbvnbm1pv8ykj40m9"; - postFetch = '' - mkdir -p $out/share/fonts/opentype/source-han-sans - unzip $downloadedFile -d $out/share/fonts/opentype/source-han-sans - ''; + hash = "sha256-b1kRiprdpaf+Tp5rtTgwn34dPFQR+anTKvMqeVAbfk8="; zip = ".zip"; }; @@ -50,11 +62,7 @@ in family = "serif"; description = "serif"; rev = "2.000R"; - sha256 = "0x3n6s4khdd6l0crwd7g9sjaqp8lkvksglhc7kj3cv80hldab9wp"; - postFetch = '' - mkdir -p $out/share/fonts/opentype/source-han-serif - unzip $downloadedFile -d $out/share/fonts/opentype/source-han-serif - ''; + hash = "sha256-RDgywab7gwT+YBO7F1KJvKOv0E/3+7Zi/pQl+UDsGcM="; zip = ".zip"; }; @@ -62,6 +70,6 @@ in family = "mono"; description = "monospaced"; rev = "1.002"; - sha256 = "010h1y469c21bjavwdmkpbwk3ny686inz8i062wh1dhcv8cnqk3c"; + hash = "sha256-DBkkSN6QhI8R64M2h2iDqaNtxluJZeSJYAz8x6ZzWME="; }; } diff --git a/pkgs/data/fonts/source-sans-pro/default.nix b/pkgs/data/fonts/source-sans-pro/default.nix index 382c20aa9768..2a2d2c70f289 100644 --- a/pkgs/data/fonts/source-sans-pro/default.nix +++ b/pkgs/data/fonts/source-sans-pro/default.nix @@ -1,18 +1,28 @@ -# when changing this expression convert it from 'fetchzip' to 'stdenvNoCC.mkDerivation' -{ lib, fetchzip }: +{ lib, stdenvNoCC, fetchzip }: # Source Sans Pro got renamed to Source Sans 3 (see # https://github.com/adobe-fonts/source-sans/issues/192). This is the # last version named "Pro". It is useful for backward compatibility # with older documents/templates/etc. -let - version = "3.006"; -in (fetchzip { + +stdenvNoCC.mkDerivation rec { name = "source-sans-pro-${version}"; + version = "3.006"; - url = "https://github.com/adobe-fonts/source-sans/archive/${version}R.zip"; + src = fetchzip { + url = "https://github.com/adobe-fonts/source-sans/archive/${version}R.zip"; + hash = "sha256-1Savijgq3INuUN89MR0t748HOuGseXVw5Kd4hYwuVas="; + }; - sha256 = "sha256-uWr/dFyLF65v0o6+oN/3RQoe4ziPspzGB1rgiBkoTYY="; + installPhase = '' + runHook preInstall + + install -Dm444 OTF/*.otf -t $out/share/fonts/opentype + install -Dm444 TTF/*.ttf -t $out/share/fonts/truetype + install -Dm444 VAR/*.otf -t $out/share/fonts/variable + + runHook postInstall + ''; meta = with lib; { homepage = "https://adobe-fonts.github.io/source-sans/"; @@ -21,11 +31,4 @@ in (fetchzip { platforms = platforms.all; maintainers = with maintainers; [ ttuegel ]; }; -}).overrideAttrs (_: { - postFetch = '' - mkdir -p $out/share/fonts/{opentype,truetype,variable} - unzip -j $downloadedFile "*/OTF/*.otf" -d $out/share/fonts/opentype - unzip -j $downloadedFile "*/TTF/*.ttf" -d $out/share/fonts/truetype - unzip -j $downloadedFile "*/VAR/*.otf" -d $out/share/fonts/variable - ''; -}) +} diff --git a/pkgs/data/fonts/source-sans/default.nix b/pkgs/data/fonts/source-sans/default.nix index 94df27765ee2..1433804ce71d 100644 --- a/pkgs/data/fonts/source-sans/default.nix +++ b/pkgs/data/fonts/source-sans/default.nix @@ -1,14 +1,23 @@ -# when changing this expression convert it from 'fetchzip' to 'stdenvNoCC.mkDerivation' -{ lib, fetchzip }: +{ lib, stdenvNoCC, fetchzip }: -let +stdenvNoCC.mkDerivation rec { + pname = "source-sans"; version = "3.046"; -in (fetchzip { - name = "source-sans-${version}"; - url = "https://github.com/adobe-fonts/source-sans/archive/${version}R.zip"; + src = fetchzip { + url = "https://github.com/adobe-fonts/source-sans/archive/${version}R.zip"; + hash = "sha256-nBLEK+T5n1CdZK2zvCWIhF2MxPmiAwL9l55a55yHtgU="; + }; - sha256 = "1wxdinnliq0xqbjrs0sqykwaggkmyqawfq862d9xn05g1pnxda94"; + installPhase = '' + runHook preInstall + + install -Dm444 OTF/*.otf -t $out/share/fonts/opentype + install -Dm444 TTF/*.ttf -t $out/share/fonts/truetype + install -Dm444 VAR/*.otf -t $out/share/fonts/variable + + runHook postInstall + ''; meta = with lib; { homepage = "https://adobe-fonts.github.io/source-sans/"; @@ -17,11 +26,4 @@ in (fetchzip { platforms = platforms.all; maintainers = with maintainers; [ ttuegel ]; }; -}).overrideAttrs (_: { - postFetch = '' - mkdir -p $out/share/fonts/{opentype,truetype,variable} - unzip -j $downloadedFile "*/OTF/*.otf" -d $out/share/fonts/opentype - unzip -j $downloadedFile "*/TTF/*.ttf" -d $out/share/fonts/truetype - unzip -j $downloadedFile "*/VAR/*.otf" -d $out/share/fonts/variable - ''; -}) +} diff --git a/pkgs/data/fonts/source-serif-pro/default.nix b/pkgs/data/fonts/source-serif-pro/default.nix index 8f2ae0f79904..698694faf507 100644 --- a/pkgs/data/fonts/source-serif-pro/default.nix +++ b/pkgs/data/fonts/source-serif-pro/default.nix @@ -1,18 +1,28 @@ -# when changing this expression convert it from 'fetchzip' to 'stdenvNoCC.mkDerivation' -{ lib, fetchzip }: +{ lib, stdenvNoCC, fetchzip }: # Source Serif Pro got renamed to Source Serif 4 (see # https://github.com/adobe-fonts/source-serif/issues/77). This is the # last version named "Pro". It is useful for backward compatibility # with older documents/templates/etc. -let + +stdenvNoCC.mkDerivation rec { + pname = "source-serif-pro"; version = "3.001"; -in (fetchzip { - name = "source-serif-pro-${version}"; - url = "https://github.com/adobe-fonts/source-serif/releases/download/${version}R/source-serif-pro-${version}R.zip"; + src = fetchzip { + url = "https://github.com/adobe-fonts/source-serif/releases/download/${version}R/source-serif-pro-${version}R.zip"; + hash = "sha256-chXoaPOACtQ7wz/etElXuIJH/yvUsP03WlxeCfqWF/w="; + }; - sha256 = "sha256-rYWk8D41QMuuSP+cQMk8ttT7uX3a7gBk4OqjA7K9udk="; + installPhase = '' + runHook preInstall + + install -Dm444 OTF/*.otf -t $out/share/fonts/opentype + install -Dm444 TTF/*.ttf -t $out/share/fonts/truetype + install -Dm444 VAR/*.otf -t $out/share/fonts/variable + + runHook postInstall + ''; meta = with lib; { homepage = "https://adobe-fonts.github.io/source-serif/"; @@ -21,11 +31,4 @@ in (fetchzip { platforms = platforms.all; maintainers = with maintainers; [ ttuegel ]; }; -}).overrideAttrs (_: { - postFetch = '' - mkdir -p $out/share/fonts/{opentype,truetype,variable} - unzip -j $downloadedFile "*/OTF/*.otf" -d $out/share/fonts/opentype - unzip -j $downloadedFile "*/TTF/*.ttf" -d $out/share/fonts/truetype - unzip -j $downloadedFile "*/VAR/*.otf" -d $out/share/fonts/variable - ''; -}) +} diff --git a/pkgs/data/fonts/source-serif/default.nix b/pkgs/data/fonts/source-serif/default.nix index 3c61627183c0..626b36f2705b 100644 --- a/pkgs/data/fonts/source-serif/default.nix +++ b/pkgs/data/fonts/source-serif/default.nix @@ -1,14 +1,23 @@ -# when changing this expression convert it from 'fetchzip' to 'stdenvNoCC.mkDerivation' -{ lib, fetchzip }: +{ lib, stdenvNoCC, fetchzip }: -let +stdenvNoCC.mkDerivation rec { + pname = "source-serif"; version = "4.004"; -in (fetchzip { - name = "source-serif-${version}"; - url = "https://github.com/adobe-fonts/source-serif/releases/download/${version}R/source-serif-${version}.zip"; + src = fetchzip { + url = "https://github.com/adobe-fonts/source-serif/releases/download/${version}R/source-serif-${version}.zip"; + hash = "sha256-tGSMOwYBEZat7MI78wkPr6lgJdsOdOaIZb+IAOoOlq4="; + }; - sha256 = "06814hcp20abca6p0ii61f23g6h1ibqyhq30lsva59wbwx5iha0h"; + installPhase = '' + runHook preInstall + + install -Dm444 OTF/*.otf -t $out/share/fonts/opentype + install -Dm444 TTF/*.ttf -t $out/share/fonts/truetype + install -Dm444 VAR/*.otf -t $out/share/fonts/variable + + runHook postInstall + ''; meta = with lib; { homepage = "https://adobe-fonts.github.io/source-serif/"; @@ -17,11 +26,4 @@ in (fetchzip { platforms = platforms.all; maintainers = with maintainers; [ ttuegel ]; }; -}).overrideAttrs (_: { - postFetch = '' - mkdir -p $out/share/fonts/{opentype,truetype,variable} - unzip -j $downloadedFile "*/OTF/*.otf" -d $out/share/fonts/opentype - unzip -j $downloadedFile "*/TTF/*.ttf" -d $out/share/fonts/truetype - unzip -j $downloadedFile "*/VAR/*.otf" -d $out/share/fonts/variable - ''; -}) +}