mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 23:43:30 +00:00
Merge pull request #68820 from babariviere/iosevka-2.0
iosevka: 1.4.3 -> 2.3.0
This commit is contained in:
commit
86db1ece88
@ -1,5 +1,5 @@
|
||||
{
|
||||
stdenv, lib,
|
||||
stdenv, lib, pkgs,
|
||||
fetchFromGitHub, fetchurl,
|
||||
nodejs, ttfautohint-nox, otfcc,
|
||||
|
||||
@ -8,7 +8,9 @@
|
||||
design ? [], upright ? [], italic ? [], oblique ? [],
|
||||
family ? null, weights ? [],
|
||||
# Custom font set name. Required if any custom settings above.
|
||||
set ? null
|
||||
set ? null,
|
||||
# Extra parameters. Can be used for ligature mapping.
|
||||
extraParameters ? null
|
||||
}:
|
||||
|
||||
assert (design != []) -> set != null;
|
||||
@ -19,38 +21,43 @@ assert (family != null) -> set != null;
|
||||
assert (weights != []) -> set != null;
|
||||
|
||||
let
|
||||
installPackageLock = import ./package-lock.nix { inherit fetchurl lib; };
|
||||
system = builtins.currentSystem;
|
||||
nodePackages = import ./node-packages.nix { inherit pkgs system nodejs; };
|
||||
in
|
||||
|
||||
let pname = if set != null then "iosevka-${set}" else "iosevka"; in
|
||||
|
||||
let
|
||||
version = "1.14.3";
|
||||
version = "2.3.0";
|
||||
name = "${pname}-${version}";
|
||||
src = fetchFromGitHub {
|
||||
owner = "be5invis";
|
||||
repo ="Iosevka";
|
||||
rev = "v${version}";
|
||||
sha256 = "0ba8hwxi88bp2jb9xfhk95nnlv8ykl74cv62xr4ybzm3b8ahpwqf";
|
||||
sha256 = "1qnbxhx9wvij9zia226mc3sy8j7bfsw5v1cvxvsbbwjskwqdamvv";
|
||||
};
|
||||
in
|
||||
|
||||
with lib;
|
||||
let unwords = concatStringsSep " "; in
|
||||
let quote = str: "\"" + str + "\""; in
|
||||
let toTomlList = list: "[" + (concatMapStringsSep ", " quote list) +"]"; in
|
||||
let unlines = concatStringsSep "\n"; in
|
||||
|
||||
let
|
||||
param = name: options:
|
||||
if options != [] then "${name}='${unwords options}'" else null;
|
||||
config = unwords (lib.filter (x: x != null) [
|
||||
if options != [] then "${name}=${toTomlList options}" else null;
|
||||
config = unlines (lib.filter (x: x != null) [
|
||||
"[buildPlans.${pname}]"
|
||||
(param "design" design)
|
||||
(param "upright" upright)
|
||||
(param "italic" italic)
|
||||
(param "oblique" oblique)
|
||||
(if family != null then "family='${family}'" else null)
|
||||
(if family != null then "family=\"${family}\"" else null)
|
||||
(param "weights" weights)
|
||||
]);
|
||||
custom = design != [] || upright != [] || italic != [] || oblique != []
|
||||
|| family != null || weights != [];
|
||||
installNodeModules = unlines (lib.mapAttrsToList
|
||||
(name: value: "mkdir -p node_modules/${name}\n cp -r ${value.outPath}/lib/node_modules/. node_modules")
|
||||
nodePackages);
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
@ -58,33 +65,25 @@ stdenv.mkDerivation {
|
||||
|
||||
nativeBuildInputs = [ nodejs ttfautohint-nox otfcc ];
|
||||
|
||||
passAsFile = [ "installPackageLock" ];
|
||||
installPackageLock = installPackageLock ./package-lock.json;
|
||||
|
||||
preConfigure = ''
|
||||
HOME=$TMPDIR
|
||||
source "$installPackageLockPath";
|
||||
npm --offline rebuild
|
||||
'';
|
||||
passAsFile = [ "config" "extraParameters" ];
|
||||
config = config;
|
||||
extraParameters = extraParameters;
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
${optionalString custom ''make custom-config set=${set} ${config}''}
|
||||
|
||||
runHook postConfigure
|
||||
mkdir -p node_modules/.bin
|
||||
${installNodeModules}
|
||||
${optionalString (set != null) ''mv "$configPath" private-build-plans.toml''}
|
||||
${optionalString (extraParameters != null) ''cat "$extraParametersPath" >> parameters.toml''}
|
||||
'';
|
||||
|
||||
makeFlags = lib.optionals custom [ "custom" "set=${set}" ];
|
||||
buildPhase = ''
|
||||
npm run build -- ttf::${pname}
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
fontdir="$out/share/fonts/$pname"
|
||||
install -d "$fontdir"
|
||||
install "dist/$pname/ttf"/* "$fontdir"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
@ -98,6 +97,6 @@ stdenv.mkDerivation {
|
||||
'';
|
||||
license = licenses.ofl;
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [ cstrahan jfrankenau ttuegel ];
|
||||
maintainers = with maintainers; [ cstrahan jfrankenau ttuegel babariviere ];
|
||||
};
|
||||
}
|
||||
|
6
pkgs/data/fonts/iosevka/generate.sh
Normal file
6
pkgs/data/fonts/iosevka/generate.sh
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
node2nix --nodejs-10 --input node-packages.json \
|
||||
--output node-packages-generated.nix \
|
||||
--composition node-packages.nix \
|
||||
--node-env ./../../../development/node-packages/node-env.nix
|
4257
pkgs/data/fonts/iosevka/node-packages-generated.nix
Normal file
4257
pkgs/data/fonts/iosevka/node-packages-generated.nix
Normal file
File diff suppressed because it is too large
Load Diff
20
pkgs/data/fonts/iosevka/node-packages.json
Normal file
20
pkgs/data/fonts/iosevka/node-packages.json
Normal file
@ -0,0 +1,20 @@
|
||||
[
|
||||
"caryll-shapeops",
|
||||
"libspiro-js",
|
||||
"megaminx",
|
||||
"object-assign",
|
||||
"otfcc-ttcize",
|
||||
"primitive-quadify-off-curves",
|
||||
"toml",
|
||||
"topsort",
|
||||
"ttf2woff",
|
||||
"ttf2woff2",
|
||||
"unorm",
|
||||
"verda",
|
||||
"yargs",
|
||||
"colors",
|
||||
"patel",
|
||||
"patrisika-scopes",
|
||||
"eslint",
|
||||
"stylus"
|
||||
]
|
17
pkgs/data/fonts/iosevka/node-packages.nix
generated
Normal file
17
pkgs/data/fonts/iosevka/node-packages.nix
generated
Normal file
@ -0,0 +1,17 @@
|
||||
# This file has been generated by node2nix 1.7.0. Do not edit!
|
||||
|
||||
{pkgs ? import <nixpkgs> {
|
||||
inherit system;
|
||||
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-10_x"}:
|
||||
|
||||
let
|
||||
nodeEnv = import ../../../development/node-packages/node-env.nix {
|
||||
inherit (pkgs) stdenv python2 utillinux runCommand writeTextFile;
|
||||
inherit nodejs;
|
||||
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
|
||||
};
|
||||
in
|
||||
import ./node-packages-generated.nix {
|
||||
inherit (pkgs) fetchurl fetchgit;
|
||||
inherit nodeEnv;
|
||||
}
|
1025
pkgs/data/fonts/iosevka/package-lock.json
generated
1025
pkgs/data/fonts/iosevka/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,142 +0,0 @@
|
||||
{ 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}
|
||||
)
|
||||
''
|
||||
|
Loading…
Reference in New Issue
Block a user