Skip to content

Commit

Permalink
nixpkgs: Add NerdFont-patched Iosevka (called Imposevka)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmthoma committed Apr 15, 2017
1 parent c9b06d5 commit 6403f75
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .nixpkgs/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
otfcc = callPackage ./pkgs/otfcc/default.nix {};

iosevka = callPackage ./pkgs/iosevka/default.nix {};

imposevka = callPackage ./pkgs/iosevka/imposevka.nix {};
};
}
18 changes: 18 additions & 0 deletions .nixpkgs/pkgs/iosevka/imposevka-patcher/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
SRCFILES=$(shell ls src/)
SOURCES=$(addprefix src/,$(SRCFILES))
TARGETS=$(addprefix dst/,$(subst iosevka-,imposevka-,$(SRCFILES)))
SOURCE_OTDS=$(addprefix tmp/,$(subst .ttf,.otd,$(SRCFILES)))
TARGET_OTDS=$(addprefix tmp/,$(subst iosevka-,imposevka-,$(subst .ttf,.otd,$(SRCFILES))))

all : $(TARGETS)

tmp/nerd.otd : nerd.ttf
otfccdump $< -o $@ --glyph-name-prefix .2. --ignore-hints

$(TARGETS) : dst/imposevka-%.ttf : tmp/imposevka-%.otd
@otfccbuild $< -o $@ --keep-average-char-width --ship
@echo Patched $@
$(TARGET_OTDS) : tmp/imposevka-%.otd : merge.js tmp/iosevka-%.otd tmp/nerd.otd
@node $^ $@
$(SOURCE_OTDS) : tmp/iosevka-%.otd : src/iosevka-%.ttf
@otfccdump $< -o $@ --glyph-name-prefix .1.
13 changes: 13 additions & 0 deletions .nixpkgs/pkgs/iosevka/imposevka-patcher/merge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var fs = require('fs');
var orig = JSON.parse(fs.readFileSync(process.argv[2], 'utf-8'));
var patch = JSON.parse(fs.readFileSync(process.argv[3], 'utf-8'));
for(var k in patch.cmap) {
if(!orig.cmap[k]) { orig.cmap[k] = patch.cmap[k] }
}
for(var k in patch.glyf) {
if(!orig.glyf[k]) { orig.glyf[k] = patch.glyf[k] }
}
for(var j = 0; j < orig.name.length; j++){
orig.name[j].nameString = orig.name[j].nameString.replace(/Iosevka/g, 'Imposevka');
}
fs.writeFileSync(process.argv[4], JSON.stringify(orig))
Binary file added .nixpkgs/pkgs/iosevka/imposevka-patcher/nerd.ttf
Binary file not shown.
33 changes: 33 additions & 0 deletions .nixpkgs/pkgs/iosevka/imposevka.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{ stdenv, otfcc, iosevka, nodejs-6_x }:

stdenv.mkDerivation rec {
name = "imposevka-${iosevka.version}";

src = ./imposevka-patcher;

nativeBuildInputs = [ otfcc nodejs-6_x ];

buildPhase = ''
mkdir src
mkdir dst
mkdir tmp
cp -v ${iosevka}/share/fonts/truetype/iosevka-* src/
make
'';

installPhase = ''
fontdir=$out/share/fonts/truetype
mkdir -p $fontdir
cp -v dst/* $fontdir
'';

meta = with stdenv.lib; {
homepage = "https://github.com/ryanoasis/nerd-fonts";
description = ''
NerdFont patched Iosevka
'';
platforms = platforms.all;
maintainers = [ maintainers.fmthoma ];
};
}

0 comments on commit 6403f75

Please sign in to comment.