2022-07-27 16:32:42 +02:00
|
|
|
self: {
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
cfg = config.wayland.windowManager.hyprland;
|
2023-01-18 09:37:56 +01:00
|
|
|
defaultHyprlandPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
|
2022-08-29 15:51:39 +02:00
|
|
|
enableXWayland = cfg.xwayland.enable;
|
2023-08-01 23:49:46 +02:00
|
|
|
inherit (cfg) enableNvidiaPatches;
|
2022-07-27 16:32:42 +02:00
|
|
|
};
|
|
|
|
in {
|
2023-07-21 14:55:56 +02:00
|
|
|
disabledModules = ["services/window-managers/hyprland.nix"];
|
|
|
|
|
2023-04-05 14:06:30 +02:00
|
|
|
meta.maintainers = [lib.maintainers.fufexan];
|
|
|
|
|
2022-07-27 16:32:42 +02:00
|
|
|
options.wayland.windowManager.hyprland = {
|
2023-04-05 14:06:30 +02:00
|
|
|
enable =
|
|
|
|
lib.mkEnableOption null
|
|
|
|
// {
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Whether to enable Hyprland, the dynamic tiling Wayland compositor
|
|
|
|
that doesn't sacrifice on its looks.
|
|
|
|
|
|
|
|
You can manually launch Hyprland by executing {command}`Hyprland` on
|
|
|
|
a TTY.
|
|
|
|
|
|
|
|
See <https://wiki.hyprland.org> for more information.
|
|
|
|
'';
|
|
|
|
};
|
2022-12-19 22:39:37 +01:00
|
|
|
|
2022-07-27 16:32:42 +02:00
|
|
|
package = lib.mkOption {
|
|
|
|
type = with lib.types; nullOr package;
|
|
|
|
default = defaultHyprlandPackage;
|
2023-04-05 14:06:30 +02:00
|
|
|
defaultText = lib.literalExpression ''
|
|
|
|
hyprland.packages.''${pkgs.stdenv.hostPlatform.system}.default.override {
|
|
|
|
enableXWayland = config.wayland.windowManager.hyprland.xwayland.enable;
|
2023-08-01 23:49:46 +02:00
|
|
|
inherit (config.wayland.windowManager.hyprland) enableNvidiaPatches;
|
2023-04-05 14:06:30 +02:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Hyprland package to use. Will override the 'xwayland' and
|
2023-08-01 23:49:46 +02:00
|
|
|
'enableNvidiaPatches' options.
|
2022-07-27 16:32:42 +02:00
|
|
|
|
|
|
|
Defaults to the one provided by the flake. Set it to
|
2023-04-05 14:06:30 +02:00
|
|
|
{package}`pkgs.hyprland` to use the one provided by nixpkgs or
|
2022-07-27 16:32:42 +02:00
|
|
|
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-19 22:39:37 +01:00
|
|
|
|
2023-05-02 08:32:23 +02:00
|
|
|
plugins = lib.mkOption {
|
|
|
|
type = with lib.types; listOf (either package path);
|
|
|
|
default = [];
|
|
|
|
description = lib.mdDoc ''
|
2023-06-07 20:18:39 +02:00
|
|
|
List of Hyprland plugins to use. Can either be packages or
|
2023-05-02 08:32:23 +02:00
|
|
|
absolute plugin paths.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-07-27 16:32:42 +02:00
|
|
|
systemdIntegration = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = pkgs.stdenv.isLinux;
|
2023-04-05 14:06:30 +02:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Whether to enable {file}`hyprland-session.target` on
|
2023-06-07 20:18:39 +02:00
|
|
|
Hyprland startup. This links to {file}`graphical-session.target`.
|
2022-07-27 16:32:42 +02:00
|
|
|
Some important environment variables will be imported to systemd
|
|
|
|
and dbus user environment before reaching the target, including
|
2023-04-05 14:06:30 +02:00
|
|
|
- {env}`DISPLAY`
|
|
|
|
- {env}`HYPRLAND_INSTANCE_SIGNATURE`
|
|
|
|
- {env}`WAYLAND_DISPLAY`
|
|
|
|
- {env}`XDG_CURRENT_DESKTOP`
|
2022-07-27 16:32:42 +02:00
|
|
|
'';
|
|
|
|
};
|
2022-12-19 22:39:37 +01:00
|
|
|
|
2023-04-05 14:06:30 +02:00
|
|
|
disableAutoreload =
|
|
|
|
lib.mkEnableOption null
|
|
|
|
// {
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Whether to disable automatically reloading Hyprland's configuration when
|
|
|
|
rebuilding the Home Manager profile.
|
2022-08-29 15:51:39 +02:00
|
|
|
'';
|
|
|
|
};
|
2022-07-27 16:32:42 +02:00
|
|
|
|
2023-08-01 23:49:46 +02:00
|
|
|
xwayland.enable = lib.mkEnableOption (lib.mdDoc "XWayland") // {default = true;};
|
2022-12-18 12:43:56 +01:00
|
|
|
|
2023-08-01 23:49:46 +02:00
|
|
|
enableNvidiaPatches = lib.mkEnableOption (lib.mdDoc "patching wlroots for better Nvidia support.");
|
2023-04-05 14:06:30 +02:00
|
|
|
|
2022-07-27 16:32:42 +02:00
|
|
|
extraConfig = lib.mkOption {
|
2022-12-14 13:07:10 +01:00
|
|
|
type = lib.types.nullOr lib.types.lines;
|
2022-07-27 16:32:42 +02:00
|
|
|
default = "";
|
2023-04-05 14:06:30 +02:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Extra configuration lines to add to {file}`~/.config/hypr/hyprland.conf`.
|
2022-09-09 14:40:30 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-04-05 14:06:30 +02:00
|
|
|
recommendedEnvironment =
|
|
|
|
lib.mkEnableOption null
|
|
|
|
// {
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
Whether to set the recommended environment variables.
|
|
|
|
'';
|
|
|
|
};
|
2022-07-27 16:32:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2023-05-03 11:23:41 +02:00
|
|
|
warnings =
|
2023-08-12 14:22:37 +02:00
|
|
|
if (cfg.systemdIntegration || cfg.plugins != []) && cfg.extraConfig == null
|
|
|
|
then [
|
|
|
|
''
|
|
|
|
You have enabled hyprland.systemdIntegration or listed plugins in hyprland.plugins.
|
|
|
|
Your Hyprland config will be linked by home manager.
|
|
|
|
Set hyprland.extraConfig or unset hyprland.systemdIntegration and hyprland.plugins to remove this warning.
|
|
|
|
''
|
|
|
|
]
|
2023-05-03 11:23:41 +02:00
|
|
|
else [];
|
|
|
|
|
2022-07-27 16:32:42 +02:00
|
|
|
home.packages =
|
|
|
|
lib.optional (cfg.package != null) cfg.package
|
2022-08-29 15:51:39 +02:00
|
|
|
++ lib.optional cfg.xwayland.enable pkgs.xwayland;
|
2022-07-27 16:32:42 +02:00
|
|
|
|
2023-04-05 14:06:30 +02:00
|
|
|
home.sessionVariables =
|
|
|
|
lib.mkIf cfg.recommendedEnvironment {NIXOS_OZONE_WL = "1";};
|
2022-09-06 23:45:24 +02:00
|
|
|
|
2023-05-02 08:32:23 +02:00
|
|
|
xdg.configFile."hypr/hyprland.conf" = lib.mkIf (cfg.systemdIntegration || cfg.extraConfig != null || cfg.plugins != []) {
|
2022-07-27 16:32:42 +02:00
|
|
|
text =
|
2022-08-14 22:09:39 +02:00
|
|
|
(lib.optionalString cfg.systemdIntegration ''
|
2022-11-03 12:21:49 +01: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 15:51:39 +02:00
|
|
|
'')
|
2023-05-02 08:32:23 +02:00
|
|
|
+ lib.concatStrings (builtins.map (entry: let
|
2023-08-12 14:22:37 +02:00
|
|
|
plugin =
|
|
|
|
if lib.types.package.check entry
|
|
|
|
then "${entry}/lib/lib${entry.pname}.so"
|
|
|
|
else entry;
|
|
|
|
in "plugin = ${plugin}\n")
|
|
|
|
cfg.plugins)
|
|
|
|
+ (
|
|
|
|
if cfg.extraConfig != null
|
|
|
|
then cfg.extraConfig
|
|
|
|
else ""
|
|
|
|
);
|
2022-07-27 16:32:42 +02:00
|
|
|
|
|
|
|
onChange = let
|
|
|
|
hyprlandPackage =
|
|
|
|
if cfg.package == null
|
|
|
|
then defaultHyprlandPackage
|
|
|
|
else cfg.package;
|
2022-12-19 22:39:37 +01:00
|
|
|
in
|
2023-04-05 14:06:30 +02: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 16:32:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.user.targets.hyprland-session = lib.mkIf cfg.systemdIntegration {
|
|
|
|
Unit = {
|
2023-06-07 20:18:39 +02:00
|
|
|
Description = "Hyprland compositor session";
|
2022-07-27 16:32:42 +02:00
|
|
|
Documentation = ["man:systemd.special(7)"];
|
|
|
|
BindsTo = ["graphical-session.target"];
|
|
|
|
Wants = ["graphical-session-pre.target"];
|
|
|
|
After = ["graphical-session-pre.target"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-08-01 23:49:46 +02:00
|
|
|
|
|
|
|
imports = [
|
|
|
|
(lib.mkRemovedOptionModule ["wayland" "windowManager" "hyprland" "xwayland" "hidpi"]
|
|
|
|
"Support for this option has been removed. Refer to https://wiki.hyprland.org/Configuring/XWayland for more info")
|
|
|
|
];
|
2022-07-27 16:32:42 +02:00
|
|
|
}
|