summary refs log tree commit diff
path: root/pkgs/applications/window-managers/hyprwm/hyprland/wlroots.nix
blob: 75502800dd71c9274ec23744ac51e99576b5c457 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{ fetchFromGitLab
, hyprland
, wlroots
, xwayland
, fetchpatch
, lib
, libdisplay-info
, libliftoff
, hwdata
, hidpiXWayland ? true
, enableXWayland ? true
, nvidiaPatches ? false
}:
let
  libdisplay-info-new = libdisplay-info.overrideAttrs (old: {
    version = "0.1.1+date=2023-03-02";
    src = fetchFromGitLab {
      domain = "gitlab.freedesktop.org";
      owner = "emersion";
      repo = old.pname;
      rev = "147d6611a64a6ab04611b923e30efacaca6fc678";
      sha256 = "sha256-/q79o13Zvu7x02SBGu0W5yQznQ+p7ltZ9L6cMW5t/o4=";
    };
  });

  libliftoff-new = libliftoff.overrideAttrs (old: {
    version = "0.5.0-dev";
    src = fetchFromGitLab {
      domain = "gitlab.freedesktop.org";
      owner = "emersion";
      repo = old.pname;
      rev = "d98ae243280074b0ba44bff92215ae8d785658c0";
      sha256 = "sha256-DjwlS8rXE7srs7A8+tHqXyUsFGtucYSeq6X0T/pVOc8=";
    };

    NIX_CFLAGS_COMPILE = toString [
      "-Wno-error=sign-conversion"
    ];
  });
in
assert (lib.assertMsg (hidpiXWayland -> enableXWayland) ''
  wlroots-hyprland: cannot have hidpiXWayland when enableXWayland is false.
'');
(wlroots.overrideAttrs
  (old: {
    version = "0.17.0-dev";

    src = fetchFromGitLab {
      domain = "gitlab.freedesktop.org";
      owner = "wlroots";
      repo = "wlroots";
      rev = "6830bfc17fd94709e2cdd4da0af989f102a26e59";
      hash = "sha256-GGEjkQO9m7YLYIXIXM76HWdhjg4Ye+oafOtyaFAYKI4=";
    };

    pname =
      old.pname
      + "-hyprland"
      + (
        if hidpiXWayland
        then "-hidpi"
        else ""
      )
      + (
        if nvidiaPatches
        then "-nvidia"
        else ""
      );

    patches =
      (old.patches or [ ])
      ++ (lib.optionals (enableXWayland && hidpiXWayland) [
        "${hyprland.src}/nix/wlroots-hidpi.patch"
        (fetchpatch {
          url = "https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/18595000f3a21502fd60bf213122859cc348f9af.diff";
          sha256 = "sha256-jvfkAMh3gzkfuoRhB4E9T5X1Hu62wgUjj4tZkJm0mrI=";
          revert = true;
        })
      ])
      ++ (lib.optionals nvidiaPatches [
        (fetchpatch {
          url = "https://aur.archlinux.org/cgit/aur.git/plain/0001-nvidia-format-workaround.patch?h=hyprland-nvidia-screenshare-git&id=2830d3017d7cdd240379b4cc7e5dd6a49cf3399a";
          sha256 = "A9f1p5EW++mGCaNq8w7ZJfeWmvTfUm4iO+1KDcnqYX8=";
        })
      ]);

    postPatch =
      (old.postPatch or "")
      + (
        if nvidiaPatches
        then ''
          substituteInPlace render/gles2/renderer.c --replace "glFlush();" "glFinish();"
        ''
        else ""
      );

    buildInputs =
      old.buildInputs
      ++ [
        hwdata
        libdisplay-info-new
        libliftoff-new
      ];
  })).override {
  xwayland = xwayland.overrideAttrs (old: {
    patches =
      (old.patches or [ ])
      ++ (lib.optionals hidpiXWayland [
        "${hyprland.src}/nix/xwayland-vsync.patch"
        "${hyprland.src}/nix/xwayland-hidpi.patch"
      ]);
  });
}