Merge pull request #69219 from rileyinman/iosevka

iosevka: Simplify custom build process

The interface to configure a custom build with Nix has changed due to changes upstream; please refer to the derivation for details.
This commit is contained in:
Thomas Tuegel 2019-09-24 10:16:44 -05:00 committed by GitHub
commit 7a4d7c58e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 894 additions and 4365 deletions

View File

@ -5370,6 +5370,12 @@
github = "rickynils";
name = "Rickard Nilsson";
};
rileyinman = {
email = "rileyminman@gmail.com";
github = "rileyinman";
githubId = 37246692;
name = "Riley Inman";
};
ris = {
email = "code@humanleg.org.uk";
github = "risicle";

View File

@ -1,83 +1,70 @@
{
stdenv, lib, pkgs,
fetchFromGitHub, fetchurl,
nodejs, ttfautohint-nox, otfcc,
{ stdenv, lib, pkgs, fetchFromGitHub
, nodejs, nodePackages, remarshal, ttfautohint-nox, otfcc
# Custom font set options.
# See https://github.com/be5invis/Iosevka#build-your-own-style
design ? [], upright ? [], italic ? [], oblique ? [],
family ? null, weights ? [],
# Custom font set name. Required if any custom settings above.
set ? null,
# Extra parameters. Can be used for ligature mapping.
extraParameters ? null
# Custom font set options.
# See https://github.com/be5invis/Iosevka#build-your-own-style
# Ex:
# privateBuildPlan = {
# family = "Iosevka Expanded";
#
# design = [
# "sans"
# "expanded"
# ];
# };
, privateBuildPlan ? null
# Extra parameters. Can be used for ligature mapping.
, extraParameters ? null
# 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;
assert (family != null) -> set != null;
assert (weights != []) -> set != null;
assert (privateBuildPlan != null) -> set != null;
let
system = builtins.currentSystem;
nodePackages = import ./node-packages.nix { inherit pkgs system nodejs; };
in
stdenv.mkDerivation rec {
pname =
if set != null
then "iosevka-${set}"
else "iosevka";
let pname = if set != null then "iosevka-${set}" else "iosevka"; in
let
version = "2.3.0";
name = "${pname}-${version}";
src = fetchFromGitHub {
owner = "be5invis";
repo ="Iosevka";
repo = "Iosevka";
rev = "v${version}";
sha256 = "1qnbxhx9wvij9zia226mc3sy8j7bfsw5v1cvxvsbbwjskwqdamvv";
};
in
with lib;
let quote = str: "\"" + str + "\""; in
let toTomlList = list: "[" + (concatMapStringsSep ", " quote list) +"]"; in
let unlines = concatStringsSep "\n"; in
nativeBuildInputs = [
nodejs
nodePackages."iosevka-build-deps-../../data/fonts/iosevka"
remarshal
otfcc
ttfautohint-nox
];
let
param = name: options:
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)
(param "weights" 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 {
inherit name pname version src;
nativeBuildInputs = [ nodejs ttfautohint-nox otfcc ];
passAsFile = [ "config" "extraParameters" ];
config = config;
extraParameters = extraParameters;
privateBuildPlanJSON = builtins.toJSON { buildPlans.${pname} = privateBuildPlan; };
extraParametersJSON = builtins.toJSON { ${pname} = extraParameters; };
passAsFile = [ "privateBuildPlanJSON" "extraParametersJSON" ];
configurePhase = ''
mkdir -p node_modules/.bin
${installNodeModules}
${optionalString (set != null) ''mv "$configPath" private-build-plans.toml''}
${optionalString (extraParameters != null) ''cat "$extraParametersPath" >> parameters.toml''}
runHook preConfigure
${lib.optionalString (privateBuildPlan != null) ''
remarshal -i "$privateBuildPlanJSONPath" -o private-build-plans.toml -if json -of toml
''}
${lib.optionalString (extraParameters != null) ''
echo -e "\n" >> parameters.toml
remarshal -i "$extraParametersJSONPath" -if json -of toml >> parameters.toml
''}
ln -s ${nodePackages."iosevka-build-deps-../../data/fonts/iosevka"}/lib/node_modules/iosevka-build-deps/node_modules .
runHook postConfigure
'';
buildPhase = ''
npm run build -- ttf::${pname}
runHook preBuild
npm run build -- ttf::$pname
runHook postBuild
'';
installPhase = ''
@ -89,14 +76,20 @@ stdenv.mkDerivation {
enableParallelBuilding = true;
meta = with stdenv.lib; {
homepage = https://be5invis.github.io/Iosevka/;
downloadPage = "https://github.com/be5invis/Iosevka/releases";
homepage = https://be5invis.github.io/Iosevka;
downloadPage = https://github.com/be5invis/Iosevka/releases;
description = ''
Slender monospace sans-serif and slab-serif typeface inspired by Pragmata
Pro, M+ and PF DIN Mono, designed to be the ideal font for programming.
'';
license = licenses.ofl;
platforms = platforms.all;
maintainers = with maintainers; [ cstrahan jfrankenau ttuegel babariviere ];
maintainers = with maintainers; [
cstrahan
jfrankenau
ttuegel
babariviere
rileyinman
];
};
}

View File

@ -1,6 +0,0 @@
#!/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

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +0,0 @@
[
"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"
]

View File

@ -1,17 +0,0 @@
# 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;
}

View File

@ -0,0 +1,26 @@
{
"name": "iosevka-build-deps",
"version": "2.3.0",
"scripts": {
"build": "verda -f verdafile.js"
},
"dependencies": {
"caryll-shapeops": "^0.3.1",
"colors": "^1.3.3",
"libspiro-js": "^0.3.1",
"megaminx": "^0.9.0",
"object-assign": "^4.1.1",
"otfcc-ttcize": "^0.8.0",
"patel": "^0.33.1",
"patrisika-scopes": "^0.11.1",
"primitive-quadify-off-curves": "^0.4.0",
"stylus": "^0.54.5",
"toml": "^2.3.2",
"topsort": "0.0.2",
"ttf2woff": "^2.0.1",
"ttf2woff2": "^2.0.3",
"unorm": "^1.4.1",
"verda": "^1.0.0-0",
"yargs": "^12.0.0"
}
}

View File

@ -57,6 +57,7 @@
, "indium"
, "ionic"
, "ios-deploy"
, { "iosevka-build-deps": "../../data/fonts/iosevka" }
, "jake"
, "javascript-typescript-langserver"
, "joplin"

File diff suppressed because it is too large Load Diff