mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 16:03:23 +00:00
Merge pull request #31835 from ttuegel/iosevka/source
Iosevka: build from source, custom font sets
This commit is contained in:
commit
135835de2d
@ -1,18 +1,92 @@
|
||||
{ stdenv, fetchzip }:
|
||||
{
|
||||
stdenv, lib,
|
||||
fetchFromGitHub, fetchurl,
|
||||
runCommand, writeText,
|
||||
nodejs, ttfautohint, otfcc,
|
||||
|
||||
# Custom font set options.
|
||||
# See https://github.com/be5invis/Iosevka#build-your-own-style
|
||||
design ? [], upright ? [], italic ? [], oblique ? [],
|
||||
# Custom font set name. Required if any custom settings above.
|
||||
set ? null
|
||||
}:
|
||||
|
||||
assert (design != []) -> set != null;
|
||||
assert (upright != []) -> set != null;
|
||||
assert (italic != []) -> set != null;
|
||||
assert (oblique != []) -> set != null;
|
||||
|
||||
let
|
||||
installPackageLock = import ./package-lock.nix { inherit fetchurl lib; };
|
||||
in
|
||||
|
||||
let pname = if set != null then "iosevka-${set}" else "iosevka"; in
|
||||
|
||||
let
|
||||
version = "1.13.3";
|
||||
in fetchzip rec {
|
||||
name = "iosevka-${version}";
|
||||
name = "${pname}-${version}";
|
||||
src = fetchFromGitHub {
|
||||
owner = "be5invis";
|
||||
repo ="Iosevka";
|
||||
rev = "v${version}";
|
||||
sha256 = "0wfhfiahllq8ngn0mybvp29cfcm7b8ndk3fyhizd620wrj50bazf";
|
||||
};
|
||||
in
|
||||
|
||||
url = "https://github.com/be5invis/Iosevka/releases/download/v${version}/iosevka-pack-${version}.zip";
|
||||
with lib;
|
||||
let unwords = concatStringsSep " "; in
|
||||
|
||||
postFetch = ''
|
||||
mkdir -p $out/share/fonts
|
||||
unzip -j $downloadedFile \*.ttc -d $out/share/fonts/iosevka
|
||||
let
|
||||
param = name: options:
|
||||
if options != [] then "${name}='${unwords options}'" else null;
|
||||
config = unwords (lib.filter (x: x != null) [
|
||||
(param "design" design)
|
||||
(param "upright" upright)
|
||||
(param "italic" italic)
|
||||
(param "oblique" oblique)
|
||||
]);
|
||||
custom = design != [] || upright != [] || italic != [] || oblique != [];
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
inherit name pname version src;
|
||||
|
||||
nativeBuildInputs = [ nodejs ttfautohint otfcc ];
|
||||
|
||||
passAsFile = [ "installPackageLock" ];
|
||||
installPackageLock = installPackageLock ./package-lock.json;
|
||||
|
||||
preConfigure = ''
|
||||
HOME=$TMPDIR
|
||||
source "$installPackageLockPath";
|
||||
npm --offline rebuild
|
||||
'';
|
||||
|
||||
sha256 = "0103rjxcp2sis42xp7fh7g8i03h5snvs8n78lgsf79g8ssw0p9d4";
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
${optionalString custom ''make custom-config set=${set} ${config}''}
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
${if custom then ''make custom set=${set}'' else ''make''}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
fontdir="$out/share/fonts/$pname"
|
||||
install -d "$fontdir"
|
||||
install "dist/$pname/ttf"/* "$fontdir"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
homepage = https://be5invis.github.io/Iosevka/;
|
||||
@ -23,6 +97,6 @@ in fetchzip rec {
|
||||
'';
|
||||
license = licenses.ofl;
|
||||
platforms = platforms.all;
|
||||
maintainers = [ maintainers.cstrahan ];
|
||||
maintainers = with maintainers; [ cstrahan jfrankenau ttuegel ];
|
||||
};
|
||||
}
|
||||
|
1017
pkgs/data/fonts/iosevka/package-lock.json
generated
Normal file
1017
pkgs/data/fonts/iosevka/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
142
pkgs/data/fonts/iosevka/package-lock.nix
Normal file
142
pkgs/data/fonts/iosevka/package-lock.nix
Normal file
@ -0,0 +1,142 @@
|
||||
{ lib, fetchurl }:
|
||||
|
||||
with lib; with builtins;
|
||||
|
||||
let
|
||||
# Convert a base64-encoded string into a list of quads and padding.
|
||||
fromBase64 = str:
|
||||
let
|
||||
len = stringLength str;
|
||||
quads = 3 * len - 4 * padding;
|
||||
padding =
|
||||
if hasSuffix "==" str then 2 else
|
||||
if hasSuffix "=" str then 1 else
|
||||
0;
|
||||
chars = stringToCharacters (substring 0 (len - padding) str);
|
||||
table = {
|
||||
"A" = [0 0 0];
|
||||
"B" = [0 0 1];
|
||||
"C" = [0 0 2];
|
||||
"D" = [0 0 3];
|
||||
"E" = [0 1 0];
|
||||
"F" = [0 1 1];
|
||||
"G" = [0 1 2];
|
||||
"H" = [0 1 3];
|
||||
"I" = [0 2 0];
|
||||
"J" = [0 2 1];
|
||||
"K" = [0 2 2];
|
||||
"L" = [0 2 3];
|
||||
"M" = [0 3 0];
|
||||
"N" = [0 3 1];
|
||||
"O" = [0 3 2];
|
||||
"P" = [0 3 3];
|
||||
"Q" = [1 0 0];
|
||||
"R" = [1 0 1];
|
||||
"S" = [1 0 2];
|
||||
"T" = [1 0 3];
|
||||
"U" = [1 1 0];
|
||||
"V" = [1 1 1];
|
||||
"W" = [1 1 2];
|
||||
"X" = [1 1 3];
|
||||
"Y" = [1 2 0];
|
||||
"Z" = [1 2 1];
|
||||
"a" = [1 2 2];
|
||||
"b" = [1 2 3];
|
||||
"c" = [1 3 0];
|
||||
"d" = [1 3 1];
|
||||
"e" = [1 3 2];
|
||||
"f" = [1 3 3];
|
||||
"g" = [2 0 0];
|
||||
"h" = [2 0 1];
|
||||
"i" = [2 0 2];
|
||||
"j" = [2 0 3];
|
||||
"k" = [2 1 0];
|
||||
"l" = [2 1 1];
|
||||
"m" = [2 1 2];
|
||||
"n" = [2 1 3];
|
||||
"o" = [2 2 0];
|
||||
"p" = [2 2 1];
|
||||
"q" = [2 2 2];
|
||||
"r" = [2 2 3];
|
||||
"s" = [2 3 0];
|
||||
"t" = [2 3 1];
|
||||
"u" = [2 3 2];
|
||||
"v" = [2 3 3];
|
||||
"w" = [3 0 0];
|
||||
"x" = [3 0 1];
|
||||
"y" = [3 0 2];
|
||||
"z" = [3 0 3];
|
||||
"0" = [3 1 0];
|
||||
"1" = [3 1 1];
|
||||
"2" = [3 1 2];
|
||||
"3" = [3 1 3];
|
||||
"4" = [3 2 0];
|
||||
"5" = [3 2 1];
|
||||
"6" = [3 2 2];
|
||||
"7" = [3 2 3];
|
||||
"8" = [3 3 0];
|
||||
"9" = [3 3 1];
|
||||
"+" = [3 3 2];
|
||||
"/" = [3 3 3];
|
||||
};
|
||||
in
|
||||
take quads (concatMap (c: table.${c}) chars);
|
||||
|
||||
# Convert a list of quads with padding into a base16-encoded string.
|
||||
toBase16 = quads:
|
||||
if length quads == 0 then "" else
|
||||
if length quads == 1 then throw "toBase16: odd quads" else
|
||||
let
|
||||
hexad = 4 * elemAt quads 0 + elemAt quads 1;
|
||||
hexits = "0123456789abcdef";
|
||||
in
|
||||
substring hexad 1 hexits + toBase16 (drop 2 quads);
|
||||
in
|
||||
|
||||
let
|
||||
fetchResolved = { resolved, integrity, ... }:
|
||||
let args = { url = resolved; } // integrityHash integrity; in
|
||||
fetchurl args;
|
||||
integrityHash = integrity:
|
||||
if hasPrefix "sha1-" integrity then integritySHA1 integrity else
|
||||
if hasPrefix "sha512-" integrity then integritySHA512 integrity else
|
||||
throw "don't understand integrity: ${integrity}";
|
||||
integritySHA1 = integrity:
|
||||
{ sha1 = toBase16 (fromBase64 (removePrefix "sha1-" integrity)); };
|
||||
integritySHA512 = integrity:
|
||||
{ sha512 = toBase16 (fromBase64 (removePrefix "sha512-" integrity)); };
|
||||
in
|
||||
|
||||
let
|
||||
depend = name: attrs@{ version, dependencies ? {}, ... }:
|
||||
{
|
||||
inherit name version;
|
||||
src = fetchResolved attrs;
|
||||
depends = mapAttrsToList depend dependencies;
|
||||
};
|
||||
prepareDepend = { name, src, depends, ... }:
|
||||
''
|
||||
unpackFile '${src}'
|
||||
mv package '${name}'
|
||||
mkdir -p '${name}/node_modules'
|
||||
(
|
||||
cd '${name}/node_modules'
|
||||
${concatMapStrings prepareDepend depends}
|
||||
)
|
||||
'';
|
||||
in
|
||||
|
||||
packageLockFile:
|
||||
|
||||
let
|
||||
packageLock = fromJSON (readFile packageLockFile);
|
||||
depends = mapAttrsToList depend packageLock.dependencies;
|
||||
in
|
||||
''
|
||||
mkdir -p node_modules
|
||||
(
|
||||
cd node_modules
|
||||
${concatMapStrings prepareDepend depends}
|
||||
)
|
||||
''
|
||||
|
37
pkgs/tools/misc/otfcc/default.nix
Normal file
37
pkgs/tools/misc/otfcc/default.nix
Normal file
@ -0,0 +1,37 @@
|
||||
{ stdenv, fetchurl, premake5, hostPlatform }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "otfcc-${version}";
|
||||
version = "0.8.6";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/caryll/otfcc/archive/v${version}.tar.gz";
|
||||
sha256 = "0kap52bzrn21fmph8j2pc71f80f38ak1p2fcczzmrh0hb1r9c8dd";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ premake5 ];
|
||||
|
||||
configurePhase = ''
|
||||
premake5 gmake
|
||||
'';
|
||||
|
||||
preBuild = "cd build/gmake";
|
||||
|
||||
makeFlags = ''config=release_${if hostPlatform.isi686 then "x86" else "x64"}'';
|
||||
|
||||
postBuild = "cd ../..";
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp bin/release-x*/otfcc* $out/bin/
|
||||
'';
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "Optimized OpenType builder and inspector";
|
||||
homepage = https://github.com/caryll/otfcc;
|
||||
license = licenses.asl20;
|
||||
platforms = platforms.linux;
|
||||
maintainers = with maintainers; [ jfrankenau ttuegel ];
|
||||
};
|
||||
|
||||
}
|
@ -3797,6 +3797,8 @@ with pkgs;
|
||||
|
||||
ostree = callPackage ../tools/misc/ostree { };
|
||||
|
||||
otfcc = callPackage ../tools/misc/otfcc { };
|
||||
|
||||
otpw = callPackage ../os-specific/linux/otpw { };
|
||||
|
||||
owncloud = owncloud70;
|
||||
@ -13440,7 +13442,9 @@ with pkgs;
|
||||
|
||||
input-fonts = callPackage ../data/fonts/input-fonts { };
|
||||
|
||||
iosevka = callPackage ../data/fonts/iosevka { };
|
||||
iosevka = callPackage ../data/fonts/iosevka {
|
||||
nodejs = nodejs-8_x;
|
||||
};
|
||||
|
||||
ipafont = callPackage ../data/fonts/ipafont {};
|
||||
ipaexfont = callPackage ../data/fonts/ipaexfont {};
|
||||
|
Loading…
Reference in New Issue
Block a user