iosevka-bin: add support for variants

This adds the ability to select a specific prebuilt variant. It also adds
an updater script for generating their hashes. Additionally, switching
to TTC files reduces the package size by an order of magnitude.

Example usage:

	fonts.fonts = with pkgs; [
	  (iosevka-bin.override { variant = "ss10"; })
	  (iosevka-bin.override { variant = "sparkle"; })
	  (iosevka-bin.override { variant = "aile"; })
	];
This commit is contained in:
V
2020-10-30 21:19:20 +01:00
parent 38a394bdee
commit d3025ee8c6
3 changed files with 79 additions and 10 deletions
+27 -10
View File
@@ -1,20 +1,35 @@
{ stdenv, fetchzip }:
{ stdenv, lib, fetchurl, unzip
, variant ? ""
}:
let
version = "3.4.6";
in fetchzip {
name = "iosevka-bin-${version}";
name = "iosevka" + lib.optionalString (variant != "") "-" + variant;
url = "https://github.com/be5invis/Iosevka/releases/download/v${version}/ttc-iosevka-${version}.zip";
variantHashes = import ./variants.nix;
validVariants = map (lib.removePrefix "iosevka-")
(builtins.attrNames (builtins.removeAttrs variantHashes [ "iosevka" ]));
in stdenv.mkDerivation rec {
pname = "${name}-bin";
version = "3.7.1";
postFetch = ''
src = fetchurl {
url = "https://github.com/be5invis/Iosevka/releases/download/v${version}/ttc-${name}-${version}.zip";
sha256 = variantHashes.${name} or (throw ''
No such variant "${variant}" for package iosevka-bin.
Valid variants are: ${lib.concatStringsSep ", " validVariants}.
'');
};
nativeBuildInputs = [ unzip ];
phases = [ "unpackPhase" ];
unpackPhase = ''
mkdir -p $out/share/fonts
unzip -j $downloadedFile \*.ttc -d $out/share/fonts/truetype
unzip -d $out/share/fonts/truetype $src
'';
sha256 = "1nab49gkpxahwvvw39xcc32q425qkccr7ffmz87jbcdv71qy7pp9";
meta = with stdenv.lib; {
meta = with lib; {
homepage = "https://be5invis.github.io/Iosevka/";
downloadPage = "https://github.com/be5invis/Iosevka/releases";
description = ''
@@ -25,4 +40,6 @@ in fetchzip {
platforms = platforms.all;
maintainers = [ maintainers.cstrahan ];
};
passthru.updateScript = ./update.sh;
}