git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #96697 from hir12111/fix-font-dir

fontdir: Consider scalable fonts in index fonts.dir

commit04670f8b3de20e94ad864b36ab1a746d5ed7107e authorMichele Guerini Rocco <rnhmjoj@users.noreply.github.com> dateMon 5 Oct 2020, 21:20 (6 years ago) parent1781e119f8aad2
7 files changed+102−18
nixos/doc/manual/release-notes/rl-2103.xml+8 nixos/modules/config/fonts/fontdir.nix+33−14 nixos/modules/module-list.nix+1 nixos/modules/programs/sway.nix+3−2 nixos/modules/programs/xwayland.nix+45 nixos/modules/services/x11/xserver.nix+8 pkgs/servers/x11/xorg/xwayland.nix+4−2
nixos/doc/manual/release-notes/rl-2103.xml+8
@@ -63,6 +63,14 @@
6363 <literal>systemd-journal2gelf</literal> no longer parses json and expects the receiving system to handle it. How to achieve this with Graylog is described in this <link xlink:href="https://github.com/parse-nl/SystemdJournal2Gelf/issues/10">GitHub issue</link>.
6464 </para>
6565 </listitem>
66+ <listitem>
67+ <para>
68+ The option <option>fonts.enableFontDir</option> has been renamed to
69+ <xref linkend="opt-fonts.fontDir.enable"/>. The path of font directory
70+ has also been changed to <literal>/run/current-system/sw/share/X11/fonts</literal>,
71+ for consistency with other X11 resources.
72+ </para>
73+ </listitem>
6674 </itemizedlist>
6775 </section>
6876
nixos/modules/config/fonts/fontdir.nix+33−14
@@ -4,15 +4,19 @@ with lib;
44
55let
66
7+ cfg = config.fonts.fontDir;
8+
79 x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } ''
8− mkdir -p "$out/share/X11-fonts"
9− find ${toString config.fonts.fonts} \
10− \( -name fonts.dir -o -name '*.ttf' -o -name '*.otf' \) \
11− -exec ln -sf -t "$out/share/X11-fonts" '{}' \;
12− cd "$out/share/X11-fonts"
13− rm -f fonts.dir fonts.scale fonts.alias
14− ${pkgs.xorg.mkfontdir}/bin/mkfontdir
10+ mkdir -p "$out/share/X11/fonts"
11+ font_regexp='.*\.\(ttf\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
12+ find ${toString config.fonts.fonts} -regex "$font_regexp" \
13+ -exec ln -sf -t "$out/share/X11/fonts" '{}' \;
14+ cd "$out/share/X11/fonts"
15+ ${optionalString cfg.decompressFonts ''
16+ ${pkgs.gzip}/bin/gunzip -f *.gz
17+ ''}
1518 ${pkgs.xorg.mkfontscale}/bin/mkfontscale
19+ ${pkgs.xorg.mkfontdir}/bin/mkfontdir
1620 cat $(find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias
1721 '';
1822
@@ -21,28 +25,43 @@ in
2125{
2226
2327 options = {
28+ fonts.fontDir = {
2429
25− fonts = {
26−
27− enableFontDir = mkOption {
30+ enable = mkOption {
2831 type = types.bool;
2932 default = false;
3033 description = ''
3134 Whether to create a directory with links to all fonts in
32− <filename>/run/current-system/sw/share/X11-fonts</filename>.
35+ <filename>/run/current-system/sw/share/X11/fonts</filename>.
3336 '';
3437 };
3538
36− };
39+ decompressFonts = mkOption {
40+ type = types.bool;
41+ default = config.programs.xwayland.enable;
42+ description = ''
43+ Whether to decompress fonts in
44+ <filename>/run/current-system/sw/share/X11/fonts</filename>.
45+ '';
46+ };
3747
48+ };
3849 };
3950
40− config = mkIf config.fonts.enableFontDir {
51+ config = mkIf cfg.enable {
4152
53+ # This is enough to make a symlink because the xserver
54+ # module already links all /share/X11 paths.
4255 environment.systemPackages = [ x11Fonts ];
4356
44− environment.pathsToLink = [ "/share/X11-fonts" ];
57+ services.xserver.filesSection = ''
58+ FontPath "${x11Fonts}/share/X11/fonts"
59+ '';
4560
4661 };
4762
63+ imports = [
64+ (mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ])
65+ ];
66+
4867}
nixos/modules/module-list.nix+1
@@ -175,6 +175,7 @@
175175 ./programs/xfs_quota.nix
176176 ./programs/xonsh.nix
177177 ./programs/xss-lock.nix
178+ ./programs/xwayland.nix
178179 ./programs/yabar.nix
179180 ./programs/zmap.nix
180181 ./programs/zsh/oh-my-zsh.nix
nixos/modules/programs/sway.nix+3−2
@@ -86,8 +86,7 @@ in {
8686 extraPackages = mkOption {
8787 type = with types; listOf package;
8888 default = with pkgs; [
89− swaylock swayidle
90− xwayland alacritty dmenu
89+ swaylock swayidle alacritty dmenu
9190 rxvt-unicode # For backward compatibility (old default terminal)
9291 ];
9392 defaultText = literalExample ''
@@ -104,6 +103,7 @@ in {
104103 Extra packages to be installed system wide.
105104 '';
106105 };
106+
107107 };
108108
109109 config = mkIf cfg.enable {
@@ -130,6 +130,7 @@ in {
130130 programs.dconf.enable = mkDefault true;
131131 # To make a Sway session available if a display manager like SDDM is enabled:
132132 services.xserver.displayManager.sessionPackages = [ swayPackage ];
133+ programs.xwayland.enable = mkDefault true;
133134 };
134135
135136 meta.maintainers = with lib.maintainers; [ gnidorah primeos colemickens ];
nixos/modules/programs/xwayland.nixnew file+45
@@ -0,0 +1,45 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.programs.xwayland;
7+
8+in
9+
10+{
11+ options.programs.xwayland = {
12+
13+ enable = mkEnableOption ''
14+ Xwayland X server allows running X programs on a Wayland compositor.
15+ '';
16+
17+ defaultFontPath = mkOption {
18+ type = types.str;
19+ default = optionalString config.fonts.fontDir.enable
20+ "/run/current-system/sw/share/X11/fonts";
21+ description = ''
22+ Default font path. Setting this option causes Xwayland to be rebuilt.
23+ '';
24+ };
25+
26+ package = mkOption {
27+ type = types.path;
28+ description = "The Xwayland package";
29+ };
30+
31+ };
32+
33+ config = mkIf cfg.enable {
34+
35+ # Needed by some applications for fonts and default settings
36+ environment.pathsToLink = [ "/share/X11" ];
37+
38+ environment.systemPackages = [ cfg.package ];
39+
40+ programs.xwayland.package = pkgs.xwayland.override (oldArgs: {
41+ inherit (cfg) defaultFontPath;
42+ });
43+
44+ };
45+}
nixos/modules/services/x11/xserver.nix+8
@@ -136,6 +136,7 @@ let
136136 fi
137137 done
138138
139+ echo '${cfg.filesSection}' >> $out
139140 echo 'EndSection' >> $out
140141
141142 echo "$config" >> $out
@@ -366,6 +367,13 @@ in
366367 '';
367368 };
368369
370+ filesSection = mkOption {
371+ type = types.lines;
372+ default = "";
373+ example = ''FontPath "/path/to/my/fonts"'';
374+ description = "Contents of the first <literal>Files</literal> section of the X server configuration file.";
375+ };
376+
369377 deviceSection = mkOption {
370378 type = types.lines;
371379 default = "";
pkgs/servers/x11/xorg/xwayland.nix+4−2
@@ -1,4 +1,6 @@
1−{ stdenv, wayland, wayland-protocols, xorgserver, xkbcomp, xkeyboard_config, epoxy, libxslt, libunwind, makeWrapper, egl-wayland }:
1+{ stdenv, wayland, wayland-protocols, xorgserver, xkbcomp, xkeyboard_config
2+, epoxy, libxslt, libunwind, makeWrapper, egl-wayland
3+, defaultFontPath ? "" }:
24
35with stdenv.lib;
46
@@ -19,7 +21,7 @@ xorgserver.overrideAttrs (oldAttrs: {
1921 "--disable-xquartz"
2022 "--disable-xwin"
2123 "--enable-glamor"
22− "--with-default-font-path="
24+ "--with-default-font-path=${defaultFontPath}"
2325 "--with-xkb-bin-directory=${xkbcomp}/bin"
2426 "--with-xkb-path=${xkeyboard_config}/etc/X11/xkb"
2527 "--with-xkb-output=$(out)/share/X11/xkb/compiled"