Nix: remove hidpi from modules

This commit is contained in:
Mihai Fufezan 2023-08-02 00:49:46 +03:00 committed by Mihai Fufezan
parent e510c6a7fc
commit 2650224c1f
2 changed files with 50 additions and 66 deletions

View file

@ -7,8 +7,7 @@ self: {
cfg = config.wayland.windowManager.hyprland;
defaultHyprlandPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
enableXWayland = cfg.xwayland.enable;
hidpiXWayland = cfg.xwayland.hidpi;
inherit (cfg) nvidiaPatches;
inherit (cfg) enableNvidiaPatches;
};
in {
disabledModules = ["services/window-managers/hyprland.nix"];
@ -36,13 +35,12 @@ in {
defaultText = lib.literalExpression ''
hyprland.packages.''${pkgs.stdenv.hostPlatform.system}.default.override {
enableXWayland = config.wayland.windowManager.hyprland.xwayland.enable;
hidpiXWayland = config.wayland.windowManager.hyprland.xwayland.hidpi;
inherit (config.wayland.windowManager.hyprland) nvidiaPatches;
inherit (config.wayland.windowManager.hyprland) enableNvidiaPatches;
}
'';
description = lib.mdDoc ''
Hyprland package to use. Will override the 'xwayland' and
'nvidiaPatches' options.
'enableNvidiaPatches' options.
Defaults to the one provided by the flake. Set it to
{package}`pkgs.hyprland` to use the one provided by nixpkgs or
@ -86,19 +84,9 @@ in {
'';
};
xwayland = {
enable = lib.mkEnableOption (lib.mdDoc "XWayland") // {default = true;};
hidpi =
lib.mkEnableOption null
// {
description = lib.mdDoc ''
Enable HiDPI XWayland, based on [XWayland MR 733](https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/733).
See <https://wiki.hyprland.org/Nix/Options-Overrides/#xwayland-hidpi> for more info.
'';
};
};
xwayland.enable = lib.mkEnableOption (lib.mdDoc "XWayland") // {default = true;};
nvidiaPatches = lib.mkEnableOption (lib.mdDoc "patching wlroots for better Nvidia support.");
enableNvidiaPatches = lib.mkEnableOption (lib.mdDoc "patching wlroots for better Nvidia support.");
extraConfig = lib.mkOption {
type = lib.types.nullOr lib.types.lines;
@ -181,4 +169,9 @@ in {
};
};
};
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")
];
}

View file

@ -7,15 +7,12 @@ inputs: {
with lib; let
cfg = config.programs.hyprland;
defaultHyprlandPackage = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.default.override {
enableXWayland = cfg.xwayland.enable;
hidpiXWayland = cfg.xwayland.hidpi;
inherit (cfg) nvidiaPatches;
finalPortalPackage = cfg.portalPackage.override {
hyprland-share-picker = inputs.xdph.packages.${pkgs.system}.hyprland-share-picker.override {
hyprland = cfg.finalPackage;
};
};
in {
# disables Nixpkgs Hyprland module to avoid conflicts
disabledModules = ["programs/hyprland.nix"];
options.programs.hyprland = {
enable =
mkEnableOption null
@ -30,47 +27,34 @@ in {
'';
};
package = mkOption {
type = types.path;
default = defaultHyprlandPackage;
defaultText = literalExpression ''
hyprland.packages.''${pkgs.stdenv.hostPlatform.system}.default.override {
enableXWayland = config.programs.hyprland.xwayland.enable;
hidpiXWayland = config.programs.hyprland.xwayland.hidpi;
inherit (config.programs.hyprland) nvidiaPatches;
}
'';
example = literalExpression "pkgs.hyprland";
package = mkPackageOptionMD inputs.packages.${pkgs.system} "hyprland" {};
finalPackage = mkOption {
type = types.package;
readOnly = true;
default = cfg.package.override {
enableXWayland = cfg.xwayland.enable;
enableNvidiaPatches = cfg.enableNvidiaPatches;
};
defaultText =
literalExpression
"`programs.hyprland.package` with applied configuration";
description = mdDoc ''
The Hyprland package to use.
Setting this option will make {option}`programs.hyprland.xwayland` and
{option}`programs.hyprland.nvidiaPatches` not work.
The Hyprland package after applying configuration.
'';
};
xwayland = {
enable = mkEnableOption (mdDoc "XWayland") // {default = true;};
hidpi =
mkEnableOption null
// {
description = mdDoc ''
Enable HiDPI XWayland, based on [XWayland MR 733](https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/733).
See <https://wiki.hyprland.org/Nix/Options-Overrides/#xwayland-hidpi> for more info.
'';
};
};
portalPackage = mkPackageOptionMD inputs.xdph.packages.${pkgs.system} "xdg-desktop-portal-hyprland" {};
nvidiaPatches = mkEnableOption (mdDoc "patching wlroots for better Nvidia support");
xwayland.enable = mkEnableOption (mdDoc "support for XWayland") // {default = true;};
enableNvidiaPatches = mkEnableOption null // {
description = mdDoc "Whether to apply patches to wlroots for better Nvidia support.";
};
};
config = mkIf cfg.enable {
environment = {
systemPackages = [cfg.package];
sessionVariables = {
NIXOS_OZONE_WL = mkDefault "1";
};
};
environment.systemPackages = [cfg.finalPackage];
fonts =
if versionOlder config.system.stateVersion "23.11"
@ -81,22 +65,29 @@ in {
programs = {
dconf.enable = mkDefault true;
xwayland.enable = mkDefault true;
xwayland.enable = mkDefault cfg.xwayland.enable;
};
security.polkit.enable = true;
services.xserver.displayManager.sessionPackages = [cfg.package];
services.xserver.displayManager.sessionPackages = [cfg.finalPackage];
xdg.portal = {
enable = mkDefault true;
extraPortals = lib.mkIf (cfg.package != null) [
(inputs.xdph.packages.${pkgs.stdenv.hostPlatform.system}.xdg-desktop-portal-hyprland.override {
hyprland-share-picker = inputs.xdph.packages.${pkgs.stdenv.hostPlatform.system}.hyprland-share-picker.override {
hyprland = cfg.package;
};
})
];
extraPortals = [finalPortalPackage];
};
};
imports = with lib; [
(
mkRemovedOptionModule
["programs" "hyprland" "xwayland" "hidpi"]
"XWayland patches are deprecated. Refer to https://wiki.hyprland.org/Configuring/XWayland"
)
(
mkRenamedOptionModule
["programs" "hyprland" "nvidiaPatches"]
["programs" "hyprland" "enableNvidiaPatches"]
)
];
}