diff --git a/nixos/doc/manual/release-notes/rl-2103.xml b/nixos/doc/manual/release-notes/rl-2103.xml
index df39c6f64509..1d00c8976756 100644
--- a/nixos/doc/manual/release-notes/rl-2103.xml
+++ b/nixos/doc/manual/release-notes/rl-2103.xml
@@ -63,6 +63,14 @@
systemd-journal2gelf no longer parses json and expects the receiving system to handle it. How to achieve this with Graylog is described in this GitHub issue.
+
+
+ The option has been renamed to
+ . The path of font directory
+ has also been changed to /run/current-system/sw/share/X11/fonts,
+ for consistency with other X11 resources.
+
+
diff --git a/nixos/modules/config/fonts/fontdir.nix b/nixos/modules/config/fonts/fontdir.nix
index a6aa84ae8224..264d73ebafa5 100644
--- a/nixos/modules/config/fonts/fontdir.nix
+++ b/nixos/modules/config/fonts/fontdir.nix
@@ -4,15 +4,19 @@ with lib;
let
+ cfg = config.fonts.fontDir;
+
x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } ''
- mkdir -p "$out/share/X11-fonts"
- find ${toString config.fonts.fonts} \
- \( -name fonts.dir -o -name '*.ttf' -o -name '*.otf' \) \
- -exec ln -sf -t "$out/share/X11-fonts" '{}' \;
- cd "$out/share/X11-fonts"
- rm -f fonts.dir fonts.scale fonts.alias
- ${pkgs.xorg.mkfontdir}/bin/mkfontdir
+ mkdir -p "$out/share/X11/fonts"
+ font_regexp='.*\.\(ttf\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
+ find ${toString config.fonts.fonts} -regex "$font_regexp" \
+ -exec ln -sf -t "$out/share/X11/fonts" '{}' \;
+ cd "$out/share/X11/fonts"
+ ${optionalString cfg.decompressFonts ''
+ ${pkgs.gzip}/bin/gunzip -f *.gz
+ ''}
${pkgs.xorg.mkfontscale}/bin/mkfontscale
+ ${pkgs.xorg.mkfontdir}/bin/mkfontdir
cat $(find ${pkgs.xorg.fontalias}/ -name fonts.alias) >fonts.alias
'';
@@ -21,28 +25,43 @@ in
{
options = {
+ fonts.fontDir = {
- fonts = {
-
- enableFontDir = mkOption {
+ enable = mkOption {
type = types.bool;
default = false;
description = ''
Whether to create a directory with links to all fonts in
- /run/current-system/sw/share/X11-fonts.
+ /run/current-system/sw/share/X11/fonts.
+ '';
+ };
+
+ decompressFonts = mkOption {
+ type = types.bool;
+ default = config.programs.xwayland.enable;
+ description = ''
+ Whether to decompress fonts in
+ /run/current-system/sw/share/X11/fonts.
'';
};
};
-
};
- config = mkIf config.fonts.enableFontDir {
+ config = mkIf cfg.enable {
+ # This is enough to make a symlink because the xserver
+ # module already links all /share/X11 paths.
environment.systemPackages = [ x11Fonts ];
- environment.pathsToLink = [ "/share/X11-fonts" ];
+ services.xserver.filesSection = ''
+ FontPath "${x11Fonts}/share/X11/fonts"
+ '';
};
+ imports = [
+ (mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ])
+ ];
+
}
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 0aacd3e2edab..76263a321383 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -175,6 +175,7 @@
./programs/xfs_quota.nix
./programs/xonsh.nix
./programs/xss-lock.nix
+ ./programs/xwayland.nix
./programs/yabar.nix
./programs/zmap.nix
./programs/zsh/oh-my-zsh.nix
diff --git a/nixos/modules/programs/sway.nix b/nixos/modules/programs/sway.nix
index 364debddb0f1..038d76c6c921 100644
--- a/nixos/modules/programs/sway.nix
+++ b/nixos/modules/programs/sway.nix
@@ -86,8 +86,7 @@ in {
extraPackages = mkOption {
type = with types; listOf package;
default = with pkgs; [
- swaylock swayidle
- xwayland alacritty dmenu
+ swaylock swayidle alacritty dmenu
rxvt-unicode # For backward compatibility (old default terminal)
];
defaultText = literalExample ''
@@ -104,6 +103,7 @@ in {
Extra packages to be installed system wide.
'';
};
+
};
config = mkIf cfg.enable {
@@ -130,6 +130,7 @@ in {
programs.dconf.enable = mkDefault true;
# To make a Sway session available if a display manager like SDDM is enabled:
services.xserver.displayManager.sessionPackages = [ swayPackage ];
+ programs.xwayland.enable = mkDefault true;
};
meta.maintainers = with lib.maintainers; [ gnidorah primeos colemickens ];
diff --git a/nixos/modules/programs/xwayland.nix b/nixos/modules/programs/xwayland.nix
new file mode 100644
index 000000000000..7e9a424a7150
--- /dev/null
+++ b/nixos/modules/programs/xwayland.nix
@@ -0,0 +1,45 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.programs.xwayland;
+
+in
+
+{
+ options.programs.xwayland = {
+
+ enable = mkEnableOption ''
+ Xwayland X server allows running X programs on a Wayland compositor.
+ '';
+
+ defaultFontPath = mkOption {
+ type = types.str;
+ default = optionalString config.fonts.fontDir.enable
+ "/run/current-system/sw/share/X11/fonts";
+ description = ''
+ Default font path. Setting this option causes Xwayland to be rebuilt.
+ '';
+ };
+
+ package = mkOption {
+ type = types.path;
+ description = "The Xwayland package";
+ };
+
+ };
+
+ config = mkIf cfg.enable {
+
+ # Needed by some applications for fonts and default settings
+ environment.pathsToLink = [ "/share/X11" ];
+
+ environment.systemPackages = [ cfg.package ];
+
+ programs.xwayland.package = pkgs.xwayland.override (oldArgs: {
+ inherit (cfg) defaultFontPath;
+ });
+
+ };
+}
diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix
index 0552095ba955..8223c1f1e675 100644
--- a/nixos/modules/services/x11/xserver.nix
+++ b/nixos/modules/services/x11/xserver.nix
@@ -136,6 +136,7 @@ let
fi
done
+ echo '${cfg.filesSection}' >> $out
echo 'EndSection' >> $out
echo "$config" >> $out
@@ -366,6 +367,13 @@ in
'';
};
+ filesSection = mkOption {
+ type = types.lines;
+ default = "";
+ example = ''FontPath "/path/to/my/fonts"'';
+ description = "Contents of the first Files section of the X server configuration file.";
+ };
+
deviceSection = mkOption {
type = types.lines;
default = "";
diff --git a/pkgs/servers/x11/xorg/xwayland.nix b/pkgs/servers/x11/xorg/xwayland.nix
index a60025b79779..e10ba1069f05 100644
--- a/pkgs/servers/x11/xorg/xwayland.nix
+++ b/pkgs/servers/x11/xorg/xwayland.nix
@@ -1,4 +1,6 @@
-{ stdenv, wayland, wayland-protocols, xorgserver, xkbcomp, xkeyboard_config, epoxy, libxslt, libunwind, makeWrapper, egl-wayland }:
+{ stdenv, wayland, wayland-protocols, xorgserver, xkbcomp, xkeyboard_config
+, epoxy, libxslt, libunwind, makeWrapper, egl-wayland
+, defaultFontPath ? "" }:
with stdenv.lib;
@@ -19,7 +21,7 @@ xorgserver.overrideAttrs (oldAttrs: {
"--disable-xquartz"
"--disable-xwin"
"--enable-glamor"
- "--with-default-font-path="
+ "--with-default-font-path=${defaultFontPath}"
"--with-xkb-bin-directory=${xkbcomp}/bin"
"--with-xkb-path=${xkeyboard_config}/etc/X11/xkb"
"--with-xkb-output=$(out)/share/X11/xkb/compiled"