nixos/xwayland: add new module and allow configuring a default font path

- Add option `programs.xwayland.defaultFontPath`
- Modify sway to enable Xwayland
This commit is contained in:
Emilio Perez 2020-09-02 02:59:58 +01:00
parent f41f53dc49
commit 52f028f2d9
5 changed files with 58 additions and 7 deletions

View file

@ -4,13 +4,15 @@ with lib;
let
cfg = config.fonts.fontDir;
x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } ''
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 config.fonts.fontDir.decompressFonts ''
${optionalString cfg.decompressFonts ''
${pkgs.gzip}/bin/gunzip -f *.gz
''}
${pkgs.xorg.mkfontscale}/bin/mkfontscale
@ -36,7 +38,7 @@ in
decompressFonts = mkOption {
type = types.bool;
default = false;
default = config.programs.xwayland.enable;
description = ''
Whether to decompress fonts in
<filename>/run/current-system/sw/share/X11/fonts</filename>.
@ -46,7 +48,7 @@ in
};
};
config = mkIf config.fonts.fontDir.enable {
config = mkIf cfg.enable {
# This is enough to make a symlink because the xserver
# module already links all /share/X11 paths.

View file

@ -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

View file

@ -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 ];

View file

@ -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;
});
};
}

View file

@ -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"