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

nerdfonts: reuse individual fonts #86459

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 32 additions & 24 deletions pkgs/data/fonts/nerdfonts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, fetchurl
, lib
, unzip
, symlinkJoin
# To select only certain fonts, put a list of strings to `fonts`: every key in
# ./shas.nix is an optional font
, fonts ? []
Expand All @@ -25,33 +26,40 @@ let
fName:
fontsShas."${fName}"
);
srcs = lib.attrsets.mapAttrsToList (
# Create a separate derivation for each individual font so that a font doesn't
# need to be rebuilt when used in different selection fonts. Reduces
# unnecessary rebuilds and disk usage.
fontPkgs = lib.attrsets.mapAttrsToList (
fName:
fSha:
(fetchurl {
url = "https://github.com/ryanoasis/nerd-fonts/releases/download/v${version}/${fName}.zip";
sha256 = fSha;
})
stdenv.mkDerivation rec {
inherit version;
pname = "nerdfonts-${fName}";
src = fetchurl {
url = "https://github.com/ryanoasis/nerd-fonts/releases/download/v${version}/${fName}.zip";
sha256 = fSha;
};
nativeBuildInputs = [
unzip
];
sourceRoot = ".";
installPhase = ''
find -name \*.otf -exec mkdir -p $out/share/fonts/opentype/NerdFonts \; -exec mv {} $out/share/fonts/opentype/NerdFonts \;
find -name \*.ttf -exec mkdir -p $out/share/fonts/truetype/NerdFonts \; -exec mv {} $out/share/fonts/truetype/NerdFonts \;
'';
meta = with stdenv.lib; {
description = "${fName} font in Nerdfonts collection";
homepage = "https://nerdfonts.com/";
maintainers = with maintainers; [ doronbehar ];
hydraPlatforms = []; # 'Output limit exceeded' on Hydra
};
}
) selectedFontsShas;
in

stdenv.mkDerivation rec {
inherit version;
inherit srcs;
pname = "nerdfonts";
nativeBuildInputs = [
unzip
];
sourceRoot = ".";
buildPhase = ''
echo "selected fonts are ${toString selectedFonts}"
ls *.otf *.ttf
'';
installPhase = ''
find -name \*.otf -exec mkdir -p $out/share/fonts/opentype/NerdFonts \; -exec mv {} $out/share/fonts/opentype/NerdFonts \;
find -name \*.ttf -exec mkdir -p $out/share/fonts/truetype/NerdFonts \; -exec mv {} $out/share/fonts/truetype/NerdFonts \;
'';

in symlinkJoin {
# This package is just a thin symlink join which wraps the separate font
# packages under the same store path.
name = "nerdfonts-${version}";
paths = fontPkgs;
meta = with stdenv.lib; {
description = "Iconic font aggregator, collection, & patcher. 3,600+ icons, 50+ patched fonts";
longDescription = ''
Expand Down