From 31f5f62c50931addae2a0f3de4e7a89521b284f7 Mon Sep 17 00:00:00 2001 From: laalsaas Date: Sat, 19 Nov 2022 01:56:45 +0100 Subject: [PATCH 1/3] noto-fonts: 2020-01-23 -> v20201206-phase3 --- pkgs/data/fonts/noto-fonts/default.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/data/fonts/noto-fonts/default.nix b/pkgs/data/fonts/noto-fonts/default.nix index 019ed1f371c0..1a875a853b18 100644 --- a/pkgs/data/fonts/noto-fonts/default.nix +++ b/pkgs/data/fonts/noto-fonts/default.nix @@ -15,15 +15,15 @@ let mkNoto = { pname, weights }: - stdenvNoCC.mkDerivation { + stdenvNoCC.mkDerivation rec { inherit pname; - version = "2020-01-23"; + version = "v20201206-phase3"; src = fetchFromGitHub { owner = "googlefonts"; repo = "noto-fonts"; - rev = "f4726a2ec36169abd02a6d8abe67c8ff0236f6d8"; - sha256 = "0zc1r7zph62qmvzxqfflsprazjf6x1qnwc2ma27kyzh6v36gaykw"; + rev = version; + hash = "sha256-x60RvCRFLoGe0CNvswROnDkIsUFbWH+/laN8q2qkUPk="; }; installPhase = '' @@ -33,10 +33,10 @@ let # # TODO: install OpenType, variable versions? local out_ttf=$out/share/fonts/truetype/noto - install -m444 -Dt $out_ttf phaseIII_only/unhinted/ttf/*/*-${weights}.ttf - install -m444 -Dt $out_ttf phaseIII_only/hinted/ttf/*/*-${weights}.ttf - install -m444 -Dt $out_ttf unhinted/*/*-${weights}.ttf - install -m444 -Dt $out_ttf hinted/*/*-${weights}.ttf + install -m444 -Dt $out_ttf archive/unhinted/*/*-${weights}.ttf + install -m444 -Dt $out_ttf archive/hinted/*/*-${weights}.ttf + install -m444 -Dt $out_ttf unhinted/*/*/*-${weights}.ttf + install -m444 -Dt $out_ttf hinted/*/*/*-${weights}.ttf ''; meta = with lib; { From 34e2d794504188864c28c6e94c6083ce96bb1dca Mon Sep 17 00:00:00 2001 From: laalsaas Date: Sat, 19 Nov 2022 18:42:20 +0100 Subject: [PATCH 2/3] noto-fonts-lgc-plus: init at 20201206-phase3 This is an effort to provide more sane defaults when it comes to which fonts to install. Nobody needs Noto fonts for >190 different scripts. The noto-fonts-lgc-plus package provides the Noto Fonts for latin, greek and cyrillic, and some extras and it gives users the opportunity to specify extra fonts to install. This shoud especially be used by other modules to prevent polluting the installed fonts, making font selection in some Programs almost unusable. --- pkgs/data/fonts/noto-fonts/default.nix | 193 +++++++++++++++---------- pkgs/top-level/all-packages.nix | 2 + 2 files changed, 118 insertions(+), 77 deletions(-) diff --git a/pkgs/data/fonts/noto-fonts/default.nix b/pkgs/data/fonts/noto-fonts/default.nix index 1a875a853b18..0eaa4911cde9 100644 --- a/pkgs/data/fonts/noto-fonts/default.nix +++ b/pkgs/data/fonts/noto-fonts/default.nix @@ -11,21 +11,43 @@ , imagemagick , zopfli , buildPackages +, variants ? [ ] }: - let - mkNoto = { pname, weights }: + notoLongDescription = '' + When text is rendered by a computer, sometimes characters are + displayed as “tofu”. They are little boxes to indicate your device + doesn’t have a font to display the text. + + Google has been developing a font family called Noto, which aims to + support all languages with a harmonious look and feel. Noto is + Google’s answer to tofu. The name noto is to convey the idea that + Google’s goal is to see “no more tofu”. Noto has multiple styles and + weights, and freely available to all. + + This package also includes the Arimo, Cousine, and Tinos fonts. + ''; +in +rec { + mkNoto = + { pname + , weights + , variants ? [ ] + , longDescription ? notoLongDescription + }: stdenvNoCC.mkDerivation rec { inherit pname; - version = "v20201206-phase3"; + version = "20201206-phase3"; src = fetchFromGitHub { owner = "googlefonts"; repo = "noto-fonts"; - rev = version; + rev = "v${version}"; hash = "sha256-x60RvCRFLoGe0CNvswROnDkIsUFbWH+/laN8q2qkUPk="; }; + _variants = map (variant: builtins.replaceStrings [ " " ] [ "" ] variant) variants; + installPhase = '' # We copy in reverse preference order -- unhinted first, then # hinted -- to get the "best" version of each font while @@ -33,29 +55,24 @@ let # # TODO: install OpenType, variable versions? local out_ttf=$out/share/fonts/truetype/noto + '' + (if _variants == [ ] then '' install -m444 -Dt $out_ttf archive/unhinted/*/*-${weights}.ttf install -m444 -Dt $out_ttf archive/hinted/*/*-${weights}.ttf install -m444 -Dt $out_ttf unhinted/*/*/*-${weights}.ttf install -m444 -Dt $out_ttf hinted/*/*/*-${weights}.ttf - ''; + '' else '' + for variant in $_variants; do + install -m444 -Dt $out_ttf archive/unhinted/$variant/*-${weights}.ttf + install -m444 -Dt $out_ttf archive/hinted/$variant/*-${weights}.ttf + install -m444 -Dt $out_ttf unhinted/*/$variant/*-${weights}.ttf + install -m444 -Dt $out_ttf hinted/*/$variant/*-${weights}.ttf + done + ''); meta = with lib; { description = "Beautiful and free fonts for many languages"; homepage = "https://www.google.com/get/noto/"; - longDescription = - '' - When text is rendered by a computer, sometimes characters are - displayed as “tofu”. They are little boxes to indicate your device - doesn’t have a font to display the text. - - Google has been developing a font family called Noto, which aims to - support all languages with a harmonious look and feel. Noto is - Google’s answer to tofu. The name noto is to convey the idea that - Google’s goal is to see “no more tofu”. Noto has multiple styles and - weights, and freely available to all. - - This package also includes the Arimo, Cousine, and Tinos fonts. - ''; + inherit longDescription; license = licenses.ofl; platforms = platforms.all; maintainers = with maintainers; [ mathnerd314 emily ]; @@ -100,14 +117,34 @@ let maintainers = with maintainers; [ mathnerd314 emily ]; }; }; -in -{ noto-fonts = mkNoto { pname = "noto-fonts"; weights = "{Regular,Bold,Light,Italic,BoldItalic,LightItalic}"; }; + noto-fonts-lgc-plus = mkNoto { + pname = "noto-fonts-lgc-plus"; + weights = "{Regular,Bold,Light,Italic,BoldItalic,LightItalic}"; + variants = [ + "Noto Sans" + "Noto Serif" + "Noto Sans Display" + "Noto Serif Display" + "Noto Sans Mono" + "Noto Music" + "Noto Sans Symbols" + "Noto Sans Symbols 2" + "Noto Sans Math" + ]; + longDescription = '' + This package provides the Noto Fonts, but only for latin, greek + and cyrillic scripts, as well as some extra fonts. To create a + custom Noto package with custom variants, see the `mkNoto` + helper function. + ''; + }; + noto-fonts-extra = mkNoto { pname = "noto-fonts-extra"; weights = "{Black,Condensed,Extra,Medium,Semi,Thin}*"; @@ -127,65 +164,67 @@ in sha256 = "sha256-1w66Ge7DZjbONGhxSz69uFhfsjMsDiDkrGl6NsoB7dY="; }; - noto-fonts-emoji = let - version = "2.038"; - emojiPythonEnv = - buildPackages.python3.withPackages (p: with p; [ fonttools nototools ]); - in stdenvNoCC.mkDerivation { - pname = "noto-fonts-emoji"; - inherit version; + noto-fonts-emoji = + let + version = "2.038"; + emojiPythonEnv = + buildPackages.python3.withPackages (p: with p; [ fonttools nototools ]); + in + stdenvNoCC.mkDerivation { + pname = "noto-fonts-emoji"; + inherit version; - src = fetchFromGitHub { - owner = "googlefonts"; - repo = "noto-emoji"; - rev = "v${version}"; - sha256 = "1rgmcc6nqq805iqr8kvxxlk5cf50q714xaxk3ld6rjrd69kb8ix9"; + src = fetchFromGitHub { + owner = "googlefonts"; + repo = "noto-emoji"; + rev = "v${version}"; + sha256 = "1rgmcc6nqq805iqr8kvxxlk5cf50q714xaxk3ld6rjrd69kb8ix9"; + }; + + depsBuildBuild = [ + buildPackages.stdenv.cc + pkg-config + cairo + ]; + + nativeBuildInputs = [ + imagemagick + zopfli + pngquant + which + emojiPythonEnv + ]; + + postPatch = '' + patchShebangs *.py + patchShebangs third_party/color_emoji/*.py + # remove check for virtualenv, since we handle + # python requirements using python.withPackages + sed -i '/ifndef VIRTUAL_ENV/,+2d' Makefile + + # Make the build verbose so it won't get culled by Hydra thinking that + # it somehow got stuck doing nothing. + sed -i 's;\t@;\t;' Makefile + ''; + + enableParallelBuilding = true; + + installPhase = '' + runHook preInstall + mkdir -p $out/share/fonts/noto + cp NotoColorEmoji.ttf $out/share/fonts/noto + runHook postInstall + ''; + + meta = with lib; { + description = "Color and Black-and-White emoji fonts"; + homepage = "https://github.com/googlefonts/noto-emoji"; + license = with licenses; [ ofl asl20 ]; + platforms = platforms.all; + maintainers = with maintainers; [ mathnerd314 sternenseemann ]; + }; }; - depsBuildBuild = [ - buildPackages.stdenv.cc - pkg-config - cairo - ]; - - nativeBuildInputs = [ - imagemagick - zopfli - pngquant - which - emojiPythonEnv - ]; - - postPatch = '' - patchShebangs *.py - patchShebangs third_party/color_emoji/*.py - # remove check for virtualenv, since we handle - # python requirements using python.withPackages - sed -i '/ifndef VIRTUAL_ENV/,+2d' Makefile - - # Make the build verbose so it won't get culled by Hydra thinking that - # it somehow got stuck doing nothing. - sed -i 's;\t@;\t;' Makefile - ''; - - enableParallelBuilding = true; - - installPhase = '' - runHook preInstall - mkdir -p $out/share/fonts/noto - cp NotoColorEmoji.ttf $out/share/fonts/noto - runHook postInstall - ''; - - meta = with lib; { - description = "Color and Black-and-White emoji fonts"; - homepage = "https://github.com/googlefonts/noto-emoji"; - license = with licenses; [ ofl asl20 ]; - platforms = platforms.all; - maintainers = with maintainers; [ mathnerd314 sternenseemann ]; - }; - }; - noto-fonts-emoji-blob-bin = let pname = "noto-fonts-emoji-blob-bin"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6f3d7a3dde6d..5364e9e05d63 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -26683,7 +26683,9 @@ with pkgs; nordzy-icon-theme = callPackage ../data/icons/nordzy-icon-theme { }; inherit (callPackages ../data/fonts/noto-fonts {}) + mkNoto noto-fonts + noto-fonts-lgc-plus noto-fonts-cjk-sans noto-fonts-cjk-serif noto-fonts-emoji From 3546fca5a4c4b550f0335d8fad920fd8abc89c2a Mon Sep 17 00:00:00 2001 From: laalsaas Date: Mon, 21 Nov 2022 13:29:39 +0100 Subject: [PATCH 3/3] plasma5: add notoPackage option Some users don't want all >190 Noto fonts. --- nixos/modules/services/x11/desktop-managers/plasma5.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/x11/desktop-managers/plasma5.nix b/nixos/modules/services/x11/desktop-managers/plasma5.nix index 44faa19bc22a..112c7e7a922b 100644 --- a/nixos/modules/services/x11/desktop-managers/plasma5.nix +++ b/nixos/modules/services/x11/desktop-managers/plasma5.nix @@ -32,7 +32,7 @@ let inherit (lib) getBin optionalString literalExpression mkRemovedOptionModule mkRenamedOptionModule - mkDefault mkIf mkMerge mkOption types; + mkDefault mkIf mkMerge mkOption mkPackageOption types; ini = pkgs.formats.ini { }; @@ -198,6 +198,11 @@ in example = literalExpression "[ pkgs.plasma5Packages.oxygen ]"; }; + notoPackage = mkPackageOption pkgs "Noto fonts" { + default = [ "noto-fonts" ]; + example = "noto-fonts-lgc-plus"; + }; + # Internally allows configuring kdeglobals globally kdeglobals = mkOption { internal = true; @@ -396,7 +401,7 @@ in # Enable GTK applications to load SVG icons services.xserver.gdk-pixbuf.modulePackages = [ pkgs.librsvg ]; - fonts.fonts = with pkgs; [ noto-fonts hack-font ]; + fonts.fonts = with pkgs; [ cfg.notoPackage hack-font ]; fonts.fontconfig.defaultFonts = { monospace = [ "Hack" "Noto Sans Mono" ]; sansSerif = [ "Noto Sans" ];