about summary refs log tree commit diff
path: root/nixos/modules/programs/wayland/hyprland.nix
blob: c963429f2e2a96c8aeba9f0c9badda54c327c844 (plain) (blame)
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
{ config
, lib
, pkgs
, ...
}:
let
  cfg = config.programs.hyprland;

  finalPortalPackage = cfg.portalPackage.override {
    hyprland = cfg.finalPackage;
  };
in
{
  options.programs.hyprland = {
    enable = lib.mkEnableOption null // {
      description = ''
        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.

        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" { };

    finalPackage = lib.mkOption {
      type = lib.types.package;
      readOnly = true;
      default = cfg.package.override {
        enableXWayland = cfg.xwayland.enable;
      };
      defaultText = lib.literalExpression
        "`programs.hyprland.package` with applied configuration";
      description = ''
        The Hyprland package after applying configuration.
      '';
    };

    portalPackage = lib.mkPackageOption pkgs "xdg-desktop-portal-hyprland" { };

    xwayland.enable = lib.mkEnableOption ("XWayland") // { default = true; };

    systemd.setPath.enable = lib.mkEnableOption null // {
      default = true;
      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.
      '';
    };
  };

  config = lib.mkIf cfg.enable {
    environment.systemPackages = [ cfg.finalPackage ];

    fonts.enableDefaultPackages = lib.mkDefault true;
    hardware.opengl.enable = lib.mkDefault true;

    programs = {
      dconf.enable = lib.mkDefault true;
      xwayland.enable = lib.mkDefault cfg.xwayland.enable;
    };

    security.polkit.enable = true;

    services.displayManager.sessionPackages = [ cfg.finalPackage ];

    xdg.portal = {
      enable = lib.mkDefault true;
      extraPortals = [ finalPortalPackage ];
      configPackages = lib.mkDefault [ cfg.finalPackage ];
    };

    systemd = lib.mkIf cfg.systemd.setPath.enable {
      user.extraConfig = ''
        DefaultEnvironment="PATH=$PATH:/run/current-system/sw/bin:/etc/profiles/per-user/%u/bin:/run/wrappers/bin"
      '';
    };
  };

  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"
    )
  ];
}