1{ config
2, lib
3, pkgs
4, ...
5}:
6let
7 cfg = config.programs.hyprland;
8
9 finalPortalPackage = cfg.portalPackage.override {
10 hyprland = cfg.finalPackage;
11 };
12in
13{
14 options.programs.hyprland = {
15 enable = lib.mkEnableOption null // {
16 description = ''
17 Whether to enable Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
18
19 You can manually launch Hyprland by executing {command}`Hyprland` on a TTY.
20
21 A configuration file will be generated in {file}`~/.config/hypr/hyprland.conf`.
22 See <https://wiki.hyprland.org> for more information.
23 '';
24 };
25
26 package = lib.mkPackageOption pkgs "hyprland" { };
27
28 finalPackage = lib.mkOption {
29 type = lib.types.package;
30 readOnly = true;
31 default = cfg.package.override {
32 enableXWayland = cfg.xwayland.enable;
33 };
34 defaultText = lib.literalExpression
35 "`programs.hyprland.package` with applied configuration";
36 description = ''
37 The Hyprland package after applying configuration.
38 '';
39 };
40
41 portalPackage = lib.mkPackageOption pkgs "xdg-desktop-portal-hyprland" { };
42
43 xwayland.enable = lib.mkEnableOption ("XWayland") // { default = true; };
44
45 systemd.setPath.enable = lib.mkEnableOption null // {
46 default = true;
47 example = false;
48 description = ''
49 Set environment path of systemd to include the current system's bin directory.
50 This is needed in Hyprland setups, where opening links in applications do not work.
51 Enabled by default.
52 '';
53 };
54 };
55
56 config = lib.mkIf cfg.enable {
57 environment.systemPackages = [ cfg.finalPackage ];
58
59 fonts.enableDefaultPackages = lib.mkDefault true;
60 hardware.opengl.enable = lib.mkDefault true;
61
62 programs = {
63 dconf.enable = lib.mkDefault true;
64 xwayland.enable = lib.mkDefault cfg.xwayland.enable;
65 };
66
67 security.polkit.enable = true;
68
69 services.displayManager.sessionPackages = [ cfg.finalPackage ];
70
71 xdg.portal = {
72 enable = lib.mkDefault true;
73 extraPortals = [ finalPortalPackage ];
74 configPackages = lib.mkDefault [ cfg.finalPackage ];
75 };
76
77 systemd = lib.mkIf cfg.systemd.setPath.enable {
78 user.extraConfig = ''
79 DefaultEnvironment="PATH=$PATH:/run/current-system/sw/bin:/etc/profiles/per-user/%u/bin:/run/wrappers/bin"
80 '';
81 };
82 };
83
84 imports = [
85 (lib.mkRemovedOptionModule
86 [ "programs" "hyprland" "xwayland" "hidpi" ]
87 "XWayland patches are deprecated. Refer to https://wiki.hyprland.org/Configuring/XWayland"
88 )
89 (lib.mkRemovedOptionModule
90 [ "programs" "hyprland" "enableNvidiaPatches" ]
91 "Nvidia patches are no longer needed"
92 )
93 (lib.mkRemovedOptionModule
94 [ "programs" "hyprland" "nvidiaPatches" ]
95 "Nvidia patches are no longer needed"
96 )
97 ];
98}