2022-07-27 17:32:42 +03:00
|
|
|
self: {
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
cfg = config.wayland.windowManager.hyprland;
|
2023-01-18 11:37:56 +03:00
|
|
|
defaultHyprlandPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
|
2022-08-29 16:51:39 +03:00
|
|
|
enableXWayland = cfg.xwayland.enable;
|
|
|
|
hidpiXWayland = cfg.xwayland.hidpi;
|
2022-12-18 14:43:56 +03:00
|
|
|
nvidiaPatches = cfg.nvidiaPatches;
|
2022-07-27 17:32:42 +03:00
|
|
|
};
|
|
|
|
in {
|
|
|
|
options.wayland.windowManager.hyprland = {
|
|
|
|
enable = lib.mkEnableOption "hyprland wayland compositor";
|
2022-12-20 00:39:37 +03:00
|
|
|
|
2022-07-27 17:32:42 +03:00
|
|
|
package = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr package;
|
|
|
|
default = defaultHyprlandPackage;
|
|
|
|
description = ''
|
|
|
|
Hyprland package to use. Will override the 'xwayland' option.
|
|
|
|
|
|
|
|
Defaults to the one provided by the flake. Set it to
|
|
|
|
<literal>pkgs.hyprland</literal> to use the one provided by nixpkgs or
|
|
|
|
if you have an overlay.
|
|
|
|
|
|
|
|
Set to null to not add any Hyprland package to your path. This should
|
|
|
|
be done if you want to use the NixOS module to install Hyprland.
|
|
|
|
'';
|
|
|
|
};
|
2022-12-20 00:39:37 +03:00
|
|
|
|
2022-07-27 17:32:42 +03:00
|
|
|
systemdIntegration = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = pkgs.stdenv.isLinux;
|
|
|
|
description = ''
|
|
|
|
Whether to enable <filename>hyprland-session.target</filename> on
|
|
|
|
hyprland startup. This links to <filename>graphical-session.target</filename>.
|
|
|
|
Some important environment variables will be imported to systemd
|
|
|
|
and dbus user environment before reaching the target, including
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem><para><literal>DISPLAY</literal></para></listitem>
|
|
|
|
<listitem><para><literal>WAYLAND_DISPLAY</literal></para></listitem>
|
|
|
|
<listitem><para><literal>HYPRLAND_INSTANCE_SIGNATURE</literal></para></listitem>
|
|
|
|
<listitem><para><literal>XDG_CURRENT_DESKTOP</literal></para></listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
'';
|
|
|
|
};
|
2022-12-20 00:39:37 +03:00
|
|
|
|
|
|
|
disableAutoreload = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = false;
|
|
|
|
defaultText = lib.literalExpression "false";
|
|
|
|
example = lib.literalExpression "true";
|
|
|
|
description = ''
|
|
|
|
Whether to disable automatically reloading Hyprland's configuration when
|
|
|
|
rebuilding the Home Manager profile.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-08-29 16:51:39 +03:00
|
|
|
xwayland = {
|
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Enable XWayland.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
hidpi = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Enable HiDPI XWayland.
|
|
|
|
'';
|
|
|
|
};
|
2022-07-27 17:32:42 +03:00
|
|
|
};
|
|
|
|
|
2022-12-18 14:43:56 +03:00
|
|
|
nvidiaPatches = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = false;
|
|
|
|
defaultText = lib.literalExpression "false";
|
2023-01-24 20:20:50 +03:00
|
|
|
example = lib.literalExpression "true";
|
2022-12-18 14:43:56 +03:00
|
|
|
description = ''
|
|
|
|
Patch wlroots for better Nvidia support.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-07-27 17:32:42 +03:00
|
|
|
extraConfig = lib.mkOption {
|
2022-12-14 15:07:10 +03:00
|
|
|
type = lib.types.nullOr lib.types.lines;
|
2022-07-27 17:32:42 +03:00
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Extra configuration lines to add to ~/.config/hypr/hyprland.conf.
|
|
|
|
'';
|
|
|
|
};
|
2022-09-03 23:15:58 +03:00
|
|
|
|
2022-09-09 15:40:30 +03:00
|
|
|
recommendedEnvironment = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = true;
|
|
|
|
defaultText = lib.literalExpression "true";
|
|
|
|
example = lib.literalExpression "false";
|
|
|
|
description = ''
|
|
|
|
Whether to set the recommended environment variables.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-09-03 23:15:58 +03:00
|
|
|
imports = [
|
|
|
|
(
|
|
|
|
lib.mkRenamedOptionModule
|
|
|
|
["wayland" "windowManager" "hyprland" "xwayland"]
|
|
|
|
["wayland" "windowManager" "hyprland" "xwayland" "enable"]
|
|
|
|
)
|
|
|
|
];
|
2022-07-27 17:32:42 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
home.packages =
|
|
|
|
lib.optional (cfg.package != null) cfg.package
|
2022-08-29 16:51:39 +03:00
|
|
|
++ lib.optional cfg.xwayland.enable pkgs.xwayland;
|
2022-07-27 17:32:42 +03:00
|
|
|
|
2022-09-09 15:40:30 +03:00
|
|
|
home.sessionVariables = lib.mkIf cfg.recommendedEnvironment {
|
2022-09-07 13:05:14 +03:00
|
|
|
NIXOS_OZONE_WL = "1";
|
2022-09-07 00:45:24 +03:00
|
|
|
};
|
|
|
|
|
2022-12-14 15:07:10 +03:00
|
|
|
xdg.configFile."hypr/hyprland.conf" = lib.mkIf (cfg.extraConfig != null) {
|
2022-07-27 17:32:42 +03:00
|
|
|
text =
|
2022-08-14 23:09:39 +03:00
|
|
|
(lib.optionalString cfg.systemdIntegration ''
|
2022-11-03 14:21:49 +03:00
|
|
|
exec-once=${pkgs.dbus}/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP && systemctl --user start hyprland-session.target
|
2022-08-29 16:51:39 +03:00
|
|
|
'')
|
2022-07-27 17:32:42 +03:00
|
|
|
+ cfg.extraConfig;
|
|
|
|
|
|
|
|
onChange = let
|
|
|
|
hyprlandPackage =
|
|
|
|
if cfg.package == null
|
|
|
|
then defaultHyprlandPackage
|
|
|
|
else cfg.package;
|
2022-12-20 00:39:37 +03:00
|
|
|
in
|
2022-12-21 10:58:44 +03:00
|
|
|
lib.mkIf (!cfg.disableAutoreload) ''( # execute in subshell so that `shopt` won't affect other scripts
|
|
|
|
shopt -s nullglob # so that nothing is done if /tmp/hypr/ does not exist or is empty
|
|
|
|
for instance in /tmp/hypr/*; do
|
|
|
|
HYPRLAND_INSTANCE_SIGNATURE=''${instance##*/} ${hyprlandPackage}/bin/hyprctl reload config-only \
|
|
|
|
|| true # ignore dead instance(s)
|
|
|
|
done
|
|
|
|
)'';
|
2022-07-27 17:32:42 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.user.targets.hyprland-session = lib.mkIf cfg.systemdIntegration {
|
|
|
|
Unit = {
|
|
|
|
Description = "hyprland compositor session";
|
|
|
|
Documentation = ["man:systemd.special(7)"];
|
|
|
|
BindsTo = ["graphical-session.target"];
|
|
|
|
Wants = ["graphical-session-pre.target"];
|
|
|
|
After = ["graphical-session-pre.target"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.user.targets.tray = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Home Manager System Tray";
|
|
|
|
Requires = ["graphical-session-pre.target"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|