-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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
nerdfonts: reuse individual fonts #86459
Conversation
85e508a
to
e4c2a05
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this makes a big difference if you change your fonts a lot. Me, and I assume most people use only 1 or 2 fonts pretty consistently. Never the less, this change is harmless for us and it makes the derivation even smarter so 👍.
Previous implementation installed all selected fonts under the same store path and created a new store path for each different selection of fonts. Therefore, when making changes to `fonts` argument, a new path containing all the selected fonts was created. This causes unnecessary re-building of fonts and disk space usage. This change puts each font under separate store paths and just combines them with `symlinkJoin`. Now, making changes to `fonts` argument causes only rebuilding of a very light wrapping package.
e4c2a05
to
5c158af
Compare
I'll make one more improvement suggestion in a few minutes.. |
@doronbehar I made one more commit suggestion: add each individual font available as an attribute of |
Another option would be to add those to top-level in |
Oh no please don't do that! These were temporary "fixes" (kept for backwards compatibility) to the problem that nerdfonts were much more annoying to install before #84858 . Thanks to you that change is taken once step further :). |
Ok! 👍 What do you think about the attributes via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jluttine I have mixed feelings now regarding this PR... I didn't mind it much in it's previous state where the only real change was to use symlinkJoin
and to reuse font packages. Considering what I commented at the review, I think you have 3 options:
- Close the PR (do nothing).
- Revert it back to use
symlinkJoin
- in the form in which I approved it initially. - Write an even broader change that will make
nerdfonts
be an attribute set such aspythonPackages
.
But, if you'll go with (3), you'll have to come up with a dictionary such as the one I wrote I don't like, and I doubt you'll find an elegant way to automate it's creation such as in #84979 (comment) .
Regarding the initial motivation for this PR:
Previous implementation installed all selected fonts under the same store path and created a new store path for each different selection of fonts. Therefore, when making changes to fonts argument, a new path containing all the selected fonts was created. This causes unnecessary re-building of fonts and disk space usage.
I'm just curios, are you sharing these nerdfonts derivations between machines and selecting different but exclusive fonts between each of these machines? When I think about it, I don't even see the symlinkJoin
implementation making a big difference for the average user. I mean if you just add a nerdfonts.override
derivation in your fonts.fonts
and leave it there..
# Make each font available also as attributes of nerdfonts package. That is, | ||
# individual font packages can be accessed as nerdfonts._3270, | ||
# nerdfonts.agave, nerdfonts.anonymous-pro and so on. | ||
passthru = fontPkgs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting.... This doesn't really work if you try e.g:
nix-build -A nerdfonts.agave
And you haven't built nerdfonts
with "Agave" ever..
I'm afraid this also explains the issue of these fonts not found in nix search -u nerdfonts
.
"Tinos" = "tinos"; | ||
"Ubuntu" = "ubuntu"; | ||
"UbuntuMono" = "ubuntu-mono"; | ||
"VictorMono" = "victor-mono"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this at all, sorry. Part of the point of #84858 was to also automate the process of fetching the available fonts there. This is a hand made dictionary I see no way of automating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I totally understand, and agree. This could also be automated by some rules in how to do the conversion but they'd be a bit complex and there would still be some exceptions (DejaVu
is converted to dejavu
instead of deja-vu
).
Officially that should go to Chapter 16: https://nixos.org/nixpkgs/manual/#chap-packages But, I'd spare my self the pain of docbook since Nixpkgs / Nix is in the process of changing documentation format, see NixOS/rfcs#64 . |
03b2afa
to
5c158af
Compare
I chose (2) and reverted back to the original PR. Yeah, I think a proper attributeset like pythonPackages would be the other options, but like you said, automating that is nontrivial and the added value is rather minimal, basically non-existent, only some possible ease of use. So, this should be now in the state you originally approved (some minor fixes to comments and meta attribute), unless I messed something up. |
Could you please answer:
? |
I'm not sure I understood the question, but I'll try to answer: On my machine, I might add/remove fonts when I need or don't need something. It might be related to development that I try different fonts or I might just want to experiment with different styles in my desktop environment, some applications or text editors. If I had, for instance, Noto Nerdfont (889 MB) installed and then I add some other font (e.g., Iosevka), I would get a new store path which has Noto again, so I'd have 889MB in my store twice. If I don't have the source for Noto anymore in store, nix would also need to download Noto zip again, causing a lot of unnecessary bandwidth usage. I could, of course, create overridden derivation separately for each font, like:
Then, they can be added and removed independently. So, it is possible to avoid the problem if one knows how. Another possible (not sure about this) small point (definitely not the main point) is that if I had:
There would be conflicts because these derivations have different files with the same name for Iosevka (the files have identical content obviously). With this PR, the files are symlinks pointing to the exact same file, so nix can solve that trivially (I'd expect that nix is smart and wouldn't complain about conflicts in that case, but I have no idea if it is so). Anyway, this was more of a side thought, I don't really know how it works in nix. I don't think this PR makes a big difference in most cases, but I think it doesn't cause any problems and in some cases it can help a little bit or even a lot. I was working on this originally before I noticed that you had already done the main effort of making it possible to install individual fonts without needing to download the full repository. I was doing the same thing, but slightly differently, so I then thought I could make a PR of this small difference that I had in my approach. |
@doronbehar I started thinking if I should still implement the option (3) you mentioned: make nerdfonts an attribute set similarly as Regarding automating the attribute names: I don't think that needs to be automated necessarily. If it is made so that if there's no defined mapping from the font name (e.g., Why would I prefer this kind of solution?
But if you feel that you wouldn't approve this kind of solution, then I won't of course waste my time on it. Just wanted share these thoughts. |
I just don't understand why can't you settle down on a set of fonts and forget about it... My overall thoughts are that this doesn't worth the effort. There are so many things worth improving in Nixpkgs which will require Nix skills such as yours :). Here are a few examples I think about instantly: |
Probably at some point I will settle down with some set of fonts after I don't do any development work that involves trying out different fonts. But anyway, as I said, I figured out already a workaround which makes each font independent:
It just took me some time to figure this out, so I thought it'd be worth making it simpler for other users. I can live with this for sure, no problem. Sometimes it's the small glitches that annoy the most, that's why I thought the attribute set approach would have value for other users, especially non-advanced users (see the points 1-6 in my previous comment). But ok, I'll work on something else, and won't spend time on this anymore. Feel free to close this (or merge if the current state was anyway ok). |
Motivation for this change
Previous implementation installed all selected fonts under the same store path and created a new store path for each different selection of fonts. Therefore, when making changes to
fonts
argument, a new path containing all the selected fonts was created. This causes unnecessary re-building of fonts and disk space usage. This change puts each font under separate store paths and just combines them withsymlinkJoin
. Now, making changes tofonts
argument causes onlyrebuilding of a very light wrapping package.
Building example:
cc maintainer @doronbehar
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)