diff --git a/flake.nix b/flake.nix index 2f0a67ab..6b973b2d 100644 --- a/flake.nix +++ b/flake.nix @@ -28,11 +28,10 @@ ]); in { overlays.default = _: prev: rec { - wlroots-hyprland = prev.wlroots.overrideAttrs (__: { + wlroots-hyprland = prev.callPackage ./nix/wlroots.nix { version = mkDate (inputs.wlroots.lastModifiedDate or "19700101") + "_" + (inputs.wlroots.shortRev or "dirty"); src = inputs.wlroots; - }); - + }; hyprland = prev.callPackage ./nix/default.nix { stdenv = prev.gcc12Stdenv; version = "0.12.1beta" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); diff --git a/nix/default.nix b/nix/default.nix index f840da1a..27aaf6bc 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -24,6 +24,7 @@ enableXWayland ? true, hidpiXWayland ? true, legacyRenderer ? false, + nvidiaPatches ? false, version ? "git", }: let assertXWayland = lib.assertMsg (hidpiXWayland -> enableXWayland) '' @@ -68,11 +69,7 @@ in wayland wayland-protocols wayland-scanner - ( - if hidpiXWayland - then (import ./hidpi_wlroots.nix {inherit wlroots xwayland fetchpatch;}) - else wlroots.override {inherit enableXWayland;} - ) + (wlroots.override {inherit enableXWayland hidpiXWayland nvidiaPatches;}) xcbutilwm ] ++ lib.optional enableXWayland xwayland; diff --git a/nix/hidpi_wlroots.nix b/nix/hidpi_wlroots.nix deleted file mode 100644 index c0f7db55..00000000 --- a/nix/hidpi_wlroots.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - wlroots, - xwayland, - fetchpatch, -}: -(wlroots.overrideAttrs - (old: { - patches = - (old.patches or []) - ++ [ - (fetchpatch { - url = "https://gitlab.freedesktop.org/lilydjwg/wlroots/-/commit/6c5ffcd1fee9e44780a6a8792f74ecfbe24a1ca7.diff"; - sha256 = "sha256-Eo1pTa/PIiJsRZwIUnHGTIFFIedzODVf0ZeuXb0a3TQ="; - }) - (fetchpatch { - url = "https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/18595000f3a21502fd60bf213122859cc348f9af.diff"; - sha256 = "sha256-jvfkAMh3gzkfuoRhB4E9T5X1Hu62wgUjj4tZkJm0mrI="; - revert = true; - }) - ]; - })) -.override { - xwayland = xwayland.overrideAttrs (old: { - patches = - (old.patches or []) - ++ [ - ./xwayland-vsync.patch - ./xwayland-hidpi.patch - ]; - }); -} diff --git a/nix/wlroots.nix b/nix/wlroots.nix new file mode 100644 index 00000000..65b281aa --- /dev/null +++ b/nix/wlroots.nix @@ -0,0 +1,64 @@ +{ + version, + src, + # + wlroots, + xwayland, + fetchpatch, + lib, + 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) [ + (fetchpatch { + url = "https://gitlab.freedesktop.org/lilydjwg/wlroots/-/commit/6c5ffcd1fee9e44780a6a8792f74ecfbe24a1ca7.diff"; + sha256 = "sha256-Eo1pTa/PIiJsRZwIUnHGTIFFIedzODVf0ZeuXb0a3TQ="; + }) + (fetchpatch { + url = "https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/18595000f3a21502fd60bf213122859cc348f9af.diff"; + sha256 = "sha256-jvfkAMh3gzkfuoRhB4E9T5X1Hu62wgUjj4tZkJm0mrI="; + revert = true; + }) + ]); + postPatch = + (old.postPatch or "") + + ( + if nvidiaPatches + then '' + substituteInPlace render/gles2/renderer.c --replace "glFlush();" "glFinish();" + '' + else "" + ); + })) + .override { + xwayland = xwayland.overrideAttrs (old: { + patches = + (old.patches or []) + ++ (lib.optionals hidpiXWayland [ + ./xwayland-vsync.patch + ./xwayland-hidpi.patch + ]); + }); + }