summaryrefslogtreecommitdiff
path: root/nix/wlroots.nix
blob: 7b05d9ff40322ac3718455a4226778e013d416ae (plain)
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
{
  version,
  src,
  #
  wlroots,
  xwayland,
  fetchpatch,
  lib,
  hwdata,
  libliftoff,
  libdisplay-info,
  hidpiXWayland ? true,
  enableXWayland ? true,
  nvidiaPatches ? false,
}:
assert (lib.assertMsg (hidpiXWayland -> enableXWayland) ''
  wlroots-hyprland: cannot have hidpiXWayland when enableXWayland is false.
'');
  (wlroots.overrideAttrs
    (old: {
      inherit version src;
      pname =
        old.pname
        + "-hyprland"
        + (
          if hidpiXWayland
          then "-hidpi"
          else ""
        )
        + (
          if nvidiaPatches
          then "-nvidia"
          else ""
        );
      patches =
        (old.patches or [])
        ++ (lib.optionals (enableXWayland && hidpiXWayland) [
          # adapted from https://gitlab.freedesktop.org/lilydjwg/wlroots/-/commit/6c5ffcd1fee9e44780a6a8792f74ecfbe24a1ca7
          ./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";
            sha256 = "A9f1p5EW++mGCaNq8w7ZJfeWmvTfUm4iO+1KDcnqYX8=";
          })
        ]);
      postPatch =
        (old.postPatch or "")
        + (
          if nvidiaPatches
          then ''
            substituteInPlace render/gles2/renderer.c --replace "glFlush();" "glFinish();"
          ''
          else ""
        );
      buildInputs = old.buildInputs ++ [hwdata libliftoff libdisplay-info];

      NIX_CFLAGS_COMPILE = toString [
        "-Wno-error=maybe-uninitialized"
      ];
    }))
  .override {
    xwayland = xwayland.overrideAttrs (old: {
      patches =
        (old.patches or [])
        ++ (lib.optionals hidpiXWayland [
          ./xwayland-vsync.patch
          ./xwayland-hidpi.patch
        ]);
    });
  }