Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nerd-font-patcher: init at 2.1.0 #142695

Merged
merged 1 commit into from
Nov 3, 2021
Merged

Conversation

ck3d
Copy link
Contributor

@ck3d ck3d commented Oct 23, 2021

Motivation for this change

Package font-patcher from nerd fonts.

see also #124042

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@muni-corn
Copy link
Contributor

Does this have the same limitation as #124042 in that it downloads 2+ GB of tarball?

@ck3d
Copy link
Contributor Author

ck3d commented Oct 25, 2021

Yes if fact, thanks for figuring out! I switched to the repo mentioned in ryanoasis/nerd-fonts#484 .

@betaboon
Copy link
Contributor

using nerd-font-patcher in nixos was the sole reason i created that repo ;)

pkgs/applications/misc/nerd-font-patcher/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/nerd-font-patcher/default.nix Outdated Show resolved Hide resolved

patchPhase = ''
sed -i font-patcher \
-e 's,__dir__ + "/src,"'$out'/share/${pname},'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-e 's,__dir__ + "/src,"'$out'/share/${pname},'
-e 's,__dir__ + "/src,"'$out'/share/nerd-font-patcher,'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see how this improves the readability nor maintainability.

Copy link
Member

@SuperSandro2000 SuperSandro2000 Nov 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Substitung pname all over the place makes it harder to understand what is going on because you need to substitute the variable in your head. This is an anti pattern and for many people including me this makes it harder to know what is going on.

Also the chance that the name of the program ever changes is very slim but that we change pname for organizational purposes is heigher which would break the package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your point. From my perspective, I had a different feeling while writing the code, since pname is quite long.

Do we have a coding standard, where we can define and discuss such preferences?

Comment on lines +29 to +32
mkdir -p $out/bin $out/share/${pname}
install -Dm755 font-patcher $out/bin/${pname}
cp -ra src/glyphs $out/share/${pname}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mkdir -p $out/bin $out/share/${pname}
install -Dm755 font-patcher $out/bin/${pname}
cp -ra src/glyphs $out/share/${pname}
mkdir -p $out/share/nerd-font-patcher
install -Dm755 font-patcher $out/bin/nerd-font-patcher
cp -ra src/glyphs $out/share/nerd-font-patcher

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see how this improves the readability nor maintainability.

pkgs/applications/misc/nerd-font-patcher/default.nix Outdated Show resolved Hide resolved
pkgs/applications/misc/nerd-font-patcher/default.nix Outdated Show resolved Hide resolved
@ck3d
Copy link
Contributor Author

ck3d commented Oct 25, 2021

Thanks for the recommended changes. I updated the commit.

@ck3d ck3d force-pushed the add-nerd-font-patcher branch from d646132 to f3b984b Compare November 1, 2021 21:15
@markuskowa markuskowa merged commit ed71268 into NixOS:master Nov 3, 2021
@mainrs
Copy link

mainrs commented Jan 27, 2022

Are there examples on how to use this properly to patch a font? Maybe having a custom hook to patch fonts would be beneficial 🤔

@muni-corn
Copy link
Contributor

@mainrs I have a working example here: https://codeberg.org/harrisonthorne/iosevka-muse/src/branch/main/flake.nix#L24

Is that what you're looking for?

@mainrs
Copy link

mainrs commented Jan 27, 2022

@mainrs I have a working example here: codeberg.org/harrisonthorne/iosevka-muse/src/branch/main/flake.nix#L24

Is that what you're looking for?

Yes! Thank you very much!

@dit7ya
Copy link
Member

dit7ya commented Feb 27, 2022

@harrisonthorne Thanks for your example. I tried it with cachix but seems like it goes through the entire patching process every rebuild. Do you know any way to cache the final results?

@mainrs
Copy link

mainrs commented Feb 27, 2022

@harrisonthorne Thanks for your example. I tried it with cachix but seems like it goes through the entire patching process every rebuild. Do you know any way to cache the final results?

This depends on your inputs. I added a pinned version of nixpkgs that I specifically use for these type of derivations. nerd-font-patcher gets updated a lot and therefore you almost always have to completely patch your fonts again, even if the font itself didn't change.

By using a pinned version of nerd-font-patcher, you can kind of workaround this.

@partisani
Copy link

partisani commented Oct 17, 2024

Sadly, it does not work and every single time anything changes the font rebuilds

EDIT: If you use the derivation described in the iosevka-muse repository, then change the src value to the src of the font (for example: src = iosevka-homemade.src;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants