Skip to content

Commit

Permalink
iosevka: 1.4.3 -> 2.3.0
Browse files Browse the repository at this point in the history
Integrate new Iosevka build system.
Add an extra arguments to add custom parameters (for example to map ligatures).
  • Loading branch information
babariviere committed Sep 15, 2019
1 parent 2607616 commit 659adfa
Show file tree
Hide file tree
Showing 3 changed files with 2,462 additions and 447 deletions.
40 changes: 21 additions & 19 deletions pkgs/data/fonts/iosevka/default.nix
Expand Up @@ -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;
Expand All @@ -25,41 +27,44 @@ 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 != [];
in

stdenv.mkDerivation {
inherit name pname version src;

nativeBuildInputs = [ nodejs ttfautohint-nox otfcc ];

passAsFile = [ "installPackageLock" ];
passAsFile = [ "installPackageLock" "config" "extraParameters" ];
installPackageLock = installPackageLock ./package-lock.json;
config = config;
extraParameters = extraParameters;

preConfigure = ''
HOME=$TMPDIR
Expand All @@ -70,21 +75,18 @@ stdenv.mkDerivation {
configurePhase = ''
runHook preConfigure
${optionalString custom ''make custom-config set=${set} ${config}''}
runHook postConfigure
${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;
Expand All @@ -98,6 +100,6 @@ stdenv.mkDerivation {
'';
license = licenses.ofl;
platforms = platforms.all;
maintainers = with maintainers; [ cstrahan jfrankenau ttuegel ];
maintainers = with maintainers; [ cstrahan jfrankenau ttuegel babariviere ];
};
}

0 comments on commit 659adfa

Please sign in to comment.