{ lib, pkgs, ... }: let # GNOME/mutter!3797, pinned because the MR is still under development. mutterTearingRevision = "a8d56d423edde9e6d76f6b9cab663d82c65cf1a2"; mutterTearingPatch = pkgs.fetchurl { url = "https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3797.diff"; hash = "sha256-3up5PsHX+BSQRKb9JS5bnJLPaTGmvV55M18tKkepIng="; }; in { nixpkgs.overlays = [ (final: prev: { mutter = prev.mutter.overrideAttrs (old: { pname = "mutter-tearing"; # The MR currently targets Mutter 51. Apply it to the packaged Mutter # 50 source, then resolve the four small context conflicts separately. prePatch = '' ${old.prePatch or ""} set +e patch --batch -p1 --forward < ${mutterTearingPatch} mr_status=$? set -e if [ "$mr_status" -ne 0 ]; then reject_count="$(find . -name '*.rej' -type f | wc -l)" if [ "$reject_count" -ne 3 ]; then echo "Unexpected number of Mutter !3797 rejects: $reject_count" >&2 exit 1 fi fi patch --batch -p1 --forward < ${./mutter-50-tearing-compat.patch} find . -name '*.rej' -type f -delete ''; passthru = (old.passthru or { }) // { tearingMr = 3797; tearingRevision = mutterTearingRevision; }; }); }) ]; # Mutter keeps tearing support behind an experimental runtime switch. environment.sessionVariables.MUTTER_DEBUG_EXPERIMENTAL_FEATURES = lib.mkDefault "tearing"; }