From 221bf59c1f75f8db922a3688dc5d282b0868e21a Mon Sep 17 00:00:00 2001 From: Jakub Trzeciak Date: Thu, 3 Aug 2023 15:41:47 +0200 Subject: Nix flake impl --- .gitignore | 3 ++- README.md | 13 ++----------- default.nix | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ flake.lock | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 47 +++++++++++++++++++++++++++++++++++++++++++++++ generate.py | 1 + makefile | 30 ++++-------------------------- 7 files changed, 165 insertions(+), 38 deletions(-) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 2b17370..fde1a85 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ vendor build down +result -*.pyc \ No newline at end of file +*.pyc diff --git a/README.md b/README.md index 6206fd6..189063f 100644 --- a/README.md +++ b/README.md @@ -7,17 +7,8 @@ A legible monospace font... the very typeface you’ve been trained to recognize

-## Installation -``` bash -make download -make -sudo make install # Only for linux and I don't realy even know, if I do it "the right way", so good luck. -``` - -### Requirments -* python3 -* fontforge -* wget +## Building +You need to have nix with flakes enabled installed and run `nix build`. ## Origins Originaly it was [Comic Mono Font](https://github.com/dtinth/comic-mono-font), but becouse of lack of support of new characters; I created my own fork that is build with Comic Shanns V2 and with small additions of my own characters. diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..450ae3c --- /dev/null +++ b/default.nix @@ -0,0 +1,49 @@ +let + + pkgs = import {}; # bring all of Nixpkgs into scope + + cousine-font = pkgs.fetchurl { + url = "https://github.com/google/fonts/raw/main/apache/cousine/Cousine-Regular.ttf"; + sha256 = "sha256-aeHqWet3ABQgTlF0+AV1D5p5PbSiUx5lFrMLdGDUcLM="; + }; + + comic-shans-font = pkgs.fetchurl { + url = "https://github.com/shannpersand/comic-shanns/raw/master/v2/comic%20shanns.otf"; + sha256 = "sha256-ogAILIIBbTnwUYzUSdX6VIbbSo7kuXihDUOZpVo1fVQ="; + }; + +in pkgs.stdenv.mkDerivation rec { + pname = "neo-comic-mono-font"; + version = "0.0.1"; + + src = ./.; + + buildInputs = with pkgs; [ + python311 + python311Packages.fontforge + wget + fontforge + ]; + + buildPhase = '' + mkdir -p vendor build + + ln -sf "${cousine-font}" vendor/cousine.ttf + ln -sf "${comic-shans-font}" vendor/comic-shanns.otf + + python generate.py + ''; + + installPhase = '' + local out_font="$out/share/fonts/neo-comic" + install -m444 -Dt "$out_font" "build/"*.ttf + ''; + + meta = with pkgs.lib; { + description = "Mono font created basing on Comic Shanns"; + homepage = "https://github.com/jptrzy/neo-comic-mono-font"; + license = licenses.mit; + maintainers = [ maintainers.jp3 ]; + platforms = platforms.all; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..1487a32 --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1690927903, + "narHash": "sha256-D5gCaCROnjEKDOel//8TO/pOP87pAEtT0uT8X+0Bj/U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bd836ac5e5a7358dea73cb74a013ca32864ccb86", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c36f641 --- /dev/null +++ b/flake.nix @@ -0,0 +1,47 @@ +{ + inputs = { + nixpkgs.url = github:NixOS/nixpkgs/nixos-23.05; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages.${system}; + + cousine-font = pkgs.fetchurl { + url = "https://github.com/google/fonts/raw/main/apache/cousine/Cousine-Regular.ttf"; + sha256 = "sha256-aeHqWet3ABQgTlF0+AV1D5p5PbSiUx5lFrMLdGDUcLM="; + }; + + comic-shans-font = pkgs.fetchurl { + url = "https://github.com/shannpersand/comic-shanns/raw/master/v2/comic%20shanns.otf"; + sha256 = "sha256-ogAILIIBbTnwUYzUSdX6VIbbSo7kuXihDUOZpVo1fVQ="; + }; + in { + packages.neo-comic-mono = pkgs.stdenv.mkDerivation rec { + pname = "Neo Comic Mono"; + version = "0.0.1"; + src = ./.; + + nativeBuildInputs = with pkgs; [ + python311 + python311Packages.fontforge + ]; + + buildPhase = '' + mkdir -p vendor build + + ln -sf "${cousine-font}" vendor/cousine.ttf + ln -sf "${comic-shans-font}" vendor/comic-shanns.otf + + python generate.py + ''; + + installPhase = '' + install -m444 -Dt "$out" "build/"*.ttf + ''; + }; + + defaultPackage = self.packages.${system}.neo-comic-mono; + } + ); +} diff --git a/generate.py b/generate.py index c77e62b..6311913 100644 --- a/generate.py +++ b/generate.py @@ -41,6 +41,7 @@ def adjust_height(source, template, scale): font = fontforge.open('vendor/comic-shanns.otf') +# Modify charasters not implemented in Comic Shans v2 new = fontforge.open('neo-font.otf') font.mergeFonts(new) diff --git a/makefile b/makefile index ac066d5..d1eb1cf 100644 --- a/makefile +++ b/makefile @@ -1,27 +1,5 @@ +build: + nix build -all: clean main - -clean: - rm -rf build/* down - -main: - mkdir -p build - python generate.py - -install: main - mkdir -p /usr/share/fonts/neo-comic - cp build/* /usr/share/fonts/neo-comic - -down: download - -download: - mkdir -p down vendor - # wget https://www.ffonts.net/Cousin.font.zip -O down/cousin.zip - wget https://www.fontsquirrel.com/fonts/download/cousine -O down/cousin.zip - unzip -u down/cousin.zip -d down - cp down/*egular.ttf vendor/cousine.ttf - wget https://github.com/shannpersand/comic-shanns/raw/master/v2/comic%20shanns.otf -O vendor/comic-shanns.otf - #wget https://github.com/shannpersand/comic-shanns/raw/master/v1/comic-shanns.otf -O vendor/comic-shanns.otf - rm -rf down - - +install: + install -m444 -Dt "/share/fonts/neo-comic" "build/"*.ttf -- cgit v1.2.3