-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create role to build & install Ioesvka font
- Loading branch information
Showing
5 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
# Whether or not to build Iosevka | ||
iosevka_enabled: yes | ||
|
||
# Iosevka Git repo information | ||
iosevka_repo_url: https://github.com/be5invis/Iosevka.git | ||
iosevka_repo_ref: main | ||
iosevka_local_repo_path: ~/Downloads/Iosevka | ||
|
||
# Build configuration | ||
iosevka_private_build_plan: ~/.config/setup/iosevka-build-plan.toml | ||
iosevka_targets: | ||
- iosevka | ||
- iosevka-term | ||
- iosevka-fixed | ||
|
||
# Installation configuration | ||
iosevka_install_dir: ~/Library/Fonts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
|
||
# In this role, I use ansible.builtin.shell in several places where | ||
# ansible.builtin.command would normally be preferred. However, using npm | ||
# requires nvm to be initialized, which my dotfiles only set up for zsh. Thus we | ||
# need to use zsh to execute the npm commands, which cannot be done with | ||
# ansible.builtin.command. | ||
|
||
- name: Ensure fontconfig is installed | ||
community.general.homebrew: | ||
name: fontconfig | ||
state: present | ||
|
||
- name: Check if Iosevka font exists | ||
ansible.builtin.command: | ||
cmd: fc-list -q Iosevka | ||
register: fc_list | ||
changed_when: false | ||
failed_when: fc_list.rc not in [0, 1] | ||
|
||
- name: Build & install Iosevka | ||
when: fc_list.rc != 0 | ||
block: | ||
- name: Ensure NPM is found | ||
ansible.builtin.shell: | ||
cmd: npm --version | ||
executable: /bin/zsh | ||
changed_when: false | ||
|
||
- name: Clone Iosevka sources | ||
ansible.builtin.git: | ||
repo: "{{ iosevka_repo_url }}" | ||
version: "{{ iosevka_repo_ref }}" | ||
dest: "{{ iosevka_local_repo_path }}" | ||
depth: 1 | ||
recursive: no | ||
|
||
- name: Install build dependencies | ||
ansible.builtin.shell: | ||
cmd: npm ci | ||
chdir: "{{ iosevka_local_repo_path }}" | ||
executable: /bin/zsh | ||
changed_when: true | ||
|
||
- name: Copy build plans | ||
ansible.builtin.copy: | ||
src: "{{ iosevka_private_build_plan }}" | ||
dest: "{{ [iosevka_local_repo_path, 'private-build-plans.toml'] | path_join }}" | ||
remote_src: yes | ||
mode: '0644' | ||
|
||
- name: Compile Iosevka | ||
ansible.builtin.shell: | ||
cmd: "{{ (['npm', 'run', 'build'] + (iosevka_targets | map('regex_replace', '^', 'ttf::'))) | map('quote') | join(' ') }}" | ||
chdir: "{{ iosevka_local_repo_path }}" | ||
executable: /bin/zsh | ||
changed_when: true | ||
|
||
- name: Find compiled font files | ||
ansible.builtin.find: | ||
paths: "{{ [] | zip_longest(subdirs, fillvalue=distdir) | map('path_join') }}" | ||
file_type: file | ||
pattern: "*.ttf" | ||
use_regex: no | ||
# ansible.builtin.debug: | ||
# msg: "{{ [] | zip_longest(subdirs, fillvalue=distdir) | map('path_join') }}" | ||
vars: | ||
subdirs: "{{ iosevka_targets | zip_longest([], fillvalue='ttf') | map('path_join') }}" | ||
distdir: "{{ [iosevka_local_repo_path, 'dist'] | path_join }}" | ||
changed_when: false | ||
register: find_compiled_fonts | ||
|
||
- name: Install compiled font files | ||
ansible.builtin.copy: | ||
remote_src: yes | ||
src: "{{ item }}" | ||
dest: "{{ [iosevka_install_dir, (item | basename)] | path_join }}" | ||
mode: '0644' | ||
loop: "{{ find_compiled_fonts.files | map(attribute='path') }}" |