blob: cd041ad85f91b59551700e4f902a7c4d4613b85e (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.hyprland;
wayland-lib = import ./lib.nix { inherit lib; };
in
{
options.programs.hyprland = {
enable = lib.mkEnableOption ''
Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
You can manually launch Hyprland by executing {command}`start-hyprland` on a TTY.
A configuration file will be generated in {file}`~/.config/hypr/hyprland.conf`.
See <https://wiki.hyprland.org> for more information'';
package =
lib.mkPackageOption pkgs "hyprland" {
extraDescription = ''
If the package is not overridable with `enableXWayland`, then the module option
{option}`xwayland` will have no effect.
'';
}
// {
apply =
p:
wayland-lib.genFinalPackage p {
enableXWayland = cfg.xwayland.enable;
};
};
portalPackage =
lib.mkPackageOption pkgs "xdg-desktop-portal-hyprland" {
extraDescription = ''
If the package is not overridable with `hyprland`, then the Hyprland package
used by the portal may differ from the one set in the module option {option}`package`.
'';
}
// {
apply =
p:
wayland-lib.genFinalPackage p {
hyprland = cfg.package;
};
};
xwayland.enable = lib.mkEnableOption "XWayland" // {
default = true;
};
withUWSM = lib.mkEnableOption null // {
description = ''
Launch Hyprland with the UWSM (Universal Wayland Session Manager) session manager.
This has improved systemd support and is recommended for most users.
This automatically starts appropriate targets like `graphical-session.target`,
and `wayland-session@Hyprland.target`.
::: {.note}
Some changes may need to be made to Hyprland configs depending on your setup, see
[Hyprland wiki](https://wiki.hyprland.org/Useful-Utilities/Systemd-start/#uwsm).
:::
'';
};
systemd.setPath.enable = lib.mkEnableOption null // {
default = lib.versionOlder cfg.package.version "0.41.2";
defaultText = lib.literalExpression ''lib.versionOlder cfg.package.version "0.41.2"'';
example = false;
description = ''
Set environment path of systemd to include the current system's bin directory.
This is needed in Hyprland setups, where opening links in applications do not work.
Enabled by default for Hyprland versions older than 0.41.2.
'';
};
};
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
environment = {
systemPackages = [ cfg.package ];
# Allows lua stub file to be accessed from /run/current-system/sw/share/hypr
pathsToLink = [ "/share/hypr" ];
};
# Hyprland needs permissions to give itself SCHED_RR on startup:
# https://github.com/hyprwm/Hyprland/blob/main/src/init/initHelpers.cpp
security.wrappers.Hyprland = {
owner = "root";
group = "root";
capabilities = "cap_sys_nice+ep";
source = lib.getExe cfg.package;
};
xdg.portal = {
enable = true;
extraPortals = [ cfg.portalPackage ];
configPackages = lib.mkDefault [ cfg.package ];
};
# To make the Hyprland session available in DM
services.displayManager.sessionPackages = [ cfg.package ];
systemd = lib.mkIf cfg.systemd.setPath.enable {
user.settings.Manager = {
DefaultEnvironment = "PATH=/run/wrappers/bin:/etc/profiles/per-user/%u/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:$PATH";
};
};
}
(lib.mkIf (cfg.withUWSM) {
programs.uwsm.enable = true;
})
(import ./wayland-session.nix {
inherit lib pkgs;
enableXWayland = cfg.xwayland.enable;
enableWlrPortal = false; # Hyprland has its own portal, wlr is not needed
})
]
);
imports = [
(lib.mkRemovedOptionModule [
"programs"
"hyprland"
"xwayland"
"hidpi"
] "XWayland patches are deprecated. Refer to https://wiki.hyprland.org/Configuring/XWayland")
(lib.mkRemovedOptionModule [
"programs"
"hyprland"
"enableNvidiaPatches"
] "Nvidia patches are no longer needed")
(lib.mkRemovedOptionModule [
"programs"
"hyprland"
"nvidiaPatches"
] "Nvidia patches are no longer needed")
];
meta.teams = [ lib.teams.hyprland ];
}
|