Code change:
<ins> { libsForQt5 , stdenv , lib , fetchFromGitHub , cmake , nix-update-script , fetchpatch , grim , makeBinaryWrapper , enableWlrSupport ? false }: stdenv.mkDerivation { pname = "flameshot"; # wlr screenshotting is currently only available on unstable version (>12.1.0) version = "12.1.0-unstable-2024-07-02"; src = fetchFromGitHub { owner = "flameshot-org"; repo = "flameshot"; rev = "ccb5a27b136a633911b3b1006185530d9beeea5d"; hash = "sha256-JIXsdVUR/4183aJ0gvNGYPTyCzX7tCrk8vRtR8bcdhE="; }; patches = [ # https://github.com/flameshot-org/flameshot/pull/3166 # fixes fractional scaling calculations on wayland (fetchpatch { name = "10-fix-wayland.patch"; url = "https://github.com/flameshot-org/flameshot/commit/5fea9144501f7024344d6f29c480b000b2dcd5a6.patch"; hash = "sha256-SnjVbFMDKD070vR4vGYrwLw6scZAFaQA4b+MbI+0W9E="; }) ]; passthru = { updateScript = nix-update-script { extraArgs = [ "--version=branch" ]; }; }; cmakeFlags = [ (lib.cmakeBool "USE_WAYLAND_CLIPBOARD" true) (lib.cmakeBool "USE_WAYLAND_GRIM" enableWlrSupport) ]; nativeBuildInputs = [ cmake libsForQt5.qttools libsForQt5.qtsvg libsForQt5.wrapQtAppsHook makeBinaryWrapper ]; buildInputs = [ libsForQt5.qtbase libsForQt5.kguiaddons ]; dontWrapQtApps = true; postFixup = '' wrapProgram $out/bin/flameshot  ${lib.optionalString enableWlrSupport "--prefix PATH : ${lib.makeBinPath [ grim ]}"}  ''${qtWrapperArgs[@]} ''; meta = with lib; { description = "Powerful yet simple to use screenshot software"; homepage = "https://github.com/flameshot-org/flameshot"; mainProgram = "flameshot"; maintainers = with maintainers; [ scode oxalica ]; license = licenses.gpl3Plus; platforms = platforms.linux ++ platforms.darwin; }; } </ins>

Related discussion:
text: flameshot has two backends, one that works in KDE, and one that works in wlroots-based compositors, but the flag USEWAYLANDGRIM must be set in order to enable it. Steps to reproduce the behavior: to use flameshot in wlroots-based compositor like sway It works [nix-shell:~]$ env XDGCURRENTDESKTOP=sway XDGSESSIONDESKTOP=sway QTQPAPLATFORM=wayland flameshot gui flameshot: error: Unable to capture screen flameshot: error: Unable to capture screen Wayland does not support QWindow::requestActivate() flameshot: info: Screenshot aborted. Add any other context about the problem here. Please run and paste the result. Add a :+1: [reaction] to [issues you find important]. [reaction]: [issues you find important]:
The flag upstream:
It turns out that this flag is not yet available in a release. To use it, I created the following package override: and now flameshot works! For home-manager I also the following:
Not sure I'd call this a bug if there's no release with this code, though it seems like it will be some time before the next release:
I can confirm that the overlay above works for me. There's a small caveat: should be available in the PATH, otherwise the setup will be a little more janky.
Whether or not there's a release, it's still a bug. There were more attempts to fix this 2-3 years back, but as you can read in that linked issue, the authors are currently not working on updates. Since there's no official release, it might not make sense to issue an interim package update, but as long as I have my working flameshot, I'm happy. I just wanted to share this with others who run into the same problem
I hadn't noticed that... I've just updated buildInputs (to add grim) and removed grim from my default home-manager environment... I think that should take care of it, but I'll test to be sure.
After using for awhile, I can confirm. You need to add grim into your environment in order for this to work consistently.
I can't seem to get that to work on GNOME see
Yes, grim is for wlroots-based compositors, not mutter.
Unrelated to this issue then?