3
0
Fork 0
forked from mirrors/nixpkgs

iosevka: accept custom build options

This commit is contained in:
Thomas Tuegel 2017-11-19 12:29:40 -06:00
parent 0a6b3492ee
commit ba9cf1f823
No known key found for this signature in database
GPG key ID: 22CBF5249D4B4D59

View file

@ -2,18 +2,29 @@
stdenv, lib, stdenv, lib,
fetchFromGitHub, fetchurl, fetchFromGitHub, fetchurl,
runCommand, writeText, runCommand, writeText,
nodejs, ttfautohint, otfcc 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
}: }:
with lib; assert (design != []) -> set != null;
assert (upright != []) -> set != null;
assert (italic != []) -> set != null;
assert (oblique != []) -> set != null;
let let
installPackageLock = import ./package-lock.nix { inherit fetchurl lib; }; installPackageLock = import ./package-lock.nix { inherit fetchurl lib; };
in in
let pname = if set != null then "iosevka-${set}" else "iosevka"; in
let let
version = "1.13.3"; version = "1.13.3";
name = "iosevka-${version}"; name = "${pname}-${version}";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "be5invis"; owner = "be5invis";
repo ="Iosevka"; repo ="Iosevka";
@ -22,8 +33,23 @@ let
}; };
in in
with lib;
let unwords = concatStringsSep " "; in
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 { stdenv.mkDerivation {
inherit name version src; inherit name pname version src;
nativeBuildInputs = [ nodejs ttfautohint otfcc ]; nativeBuildInputs = [ nodejs ttfautohint otfcc ];
@ -36,11 +62,30 @@ stdenv.mkDerivation {
npm --offline rebuild npm --offline rebuild
''; '';
installPhase = '' configurePhase = ''
fontdir=$out/share/fonts/iosevka runHook preConfigure
mkdir -p $fontdir ${optionalString custom ''make custom-config set=${set} ${config}''}
cp -v dist/iosevka*/ttf/*.ttf $fontdir
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; { meta = with stdenv.lib; {