git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/xwayland: add new module and allow configuring a default font path

- Add option `programs.xwayland.defaultFontPath` - Modify sway to enable Xwayland

commit52f028f2d9f398e891f4a23056ec9e16c4beb409 authorEmilio Perez <emilio.perez-juarez@diamond.ac.uk> dateWed 2 Sep 2020, 02:59 (6 years ago) parentf41f53d
5 files changed+58−7
nixos/modules/config/fonts/fontdir.nix+5−3 nixos/modules/module-list.nix+1 nixos/modules/programs/sway.nix+3−2 nixos/modules/programs/xwayland.nix+45 pkgs/servers/x11/xorg/xwayland.nix+4−2
nixos/modules/config/fonts/fontdir.nix+5−3
@@ -4,13 +4,15 @@ with lib;
44
55let
66
7+ cfg = config.fonts.fontDir;
8+
79 x11Fonts = pkgs.runCommand "X11-fonts" { preferLocalBuild = true; } ''
810 mkdir -p "$out/share/X11/fonts"
911 font_regexp='.*\.\(ttf\|otf\|pcf\|pfa\|pfb\|bdf\)\(\.gz\)?'
1012 find ${toString config.fonts.fonts} -regex "$font_regexp" \
1113 -exec ln -sf -t "$out/share/X11/fonts" '{}' \;
1214 cd "$out/share/X11/fonts"
13− ${optionalString config.fonts.fontDir.decompressFonts ''
15+ ${optionalString cfg.decompressFonts ''
1416 ${pkgs.gzip}/bin/gunzip -f *.gz
1517 ''}
1618 ${pkgs.xorg.mkfontscale}/bin/mkfontscale
@@ -36,7 +38,7 @@ in
3638
3739 decompressFonts = mkOption {
3840 type = types.bool;
39− default = false;
41+ default = config.programs.xwayland.enable;
4042 description = ''
4143 Whether to decompress fonts in
4244 <filename>/run/current-system/sw/share/X11/fonts</filename>.
@@ -46,7 +48,7 @@ in
4648 };
4749 };
4850
49− config = mkIf config.fonts.fontDir.enable {
51+ config = mkIf cfg.enable {
5052
5153 # This is enough to make a symlink because the xserver
5254 # module already links all /share/X11 paths.
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+}
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"