summaryrefslogtreecommitdiff
path: root/modules/root/x11.nix
blob: b7b23aea61503fdad012b3802b4b5c637ddbcbbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ pkgs, lib, config, ... }: {
	options = {
		xserver.enable = lib.mkEnableOption "enables xserver";
	};

	config = lib.mkIf config.xserver.enable {
		services.xserver.enable = true;
		services.xserver.displayManager.startx.enable = true;
		services.libinput.enable = true;  # Enable touchpad support

		# Apply startx patch to create serverauth file in /tmp instead of home directory
		nixpkgs.overlays = with pkgs; [
			(final: prev: {
				xorg = prev.xorg // {
					xinit = (prev.xorg.xinit.overrideAttrs (oldAttrs: rec {
						version = "1.4.4";
						patchtag = "${version}-1";  # Archlinux xinit package tagged release to fetch patch from
						# Override src since is hardcoded to 1.4.2
						src = prev.fetchurl {
							url = "mirror://xorg/individual/app/xinit-${version}.tar.xz";
							sha256 = "sha256-QKR8ehZMf5gc43h7Szf35BH7QyMdzeVD1wCUB12s/vk=";
						};
						patches = [
							(prev.fetchpatch {
								url = "https://gitlab.archlinux.org/archlinux/packaging/packages/xorg-xinit/-/raw/${patchtag}/06_move_serverauthfile_into_tmp.diff";
								sha256 = "1whzs5bw7ph12r3abs1g9fydibkr291jh56a0zp17d4x070jnkda";
							})
						];
					}));
				};
			})
		];

		# Install basic X utilities
		environment.systemPackages = with pkgs; [
			unclutter
			xcape
			xclip
			xdotool
			xorg.setxkbmap
			xorg.xinput
			xorg.xkill
			xorg.xrandr
			xorg.xset
			xwallpaper
		];

		# Enable TearFree option by default
		# Not all video drivers support this option
		services.xserver.deviceSection = ''
			Option "TearFree" "true"
		'';
	};
}