How to wrap all my electron apps with args?

Total noob question, in derivations with an executable in them, how can I wrap an executable with command line arguments, also maybe add the arguments to the .desktop file (if needed)?

My specific scenario I am trying to work threw is that I want to try to wrap all my electron apps with --enable-features=UseOzonePlatform --platform=wayland to see what would happen if I force them to run using Wayland. A few specifically are discord, spotify, and slack.

I know most (if not all) of my electron apps are now built using a common electron derivation, and just pulled from other sources, so I know I might have to specify each derivation to override.

I just need help on how to override specific derivations to add the args.

If it matters, I include the derivations in my home-manager config in the end.

First time posting, hope this stops my lurking spree :grin:.

may help you.

The magic for this function happens here

https://github.com/NixOS/nixpkgs/blob/2d3dd64808ab2d1a631c1f05556fbe59a7143d86/pkgs/build-support/setup-hooks/make-wrapper.sh

and has lots of good info in there

for examples on how it’s used.

Hi!

If I want to wrap my Brave package without modifying it, how would I go about doing that in my configuration.nix? (Is it even possible?) A lot of NixOS users are not nixpkgs hackers, your examples are exclusively within the build process of packages. I do not wish to recompile the entirety of Brave(Chromium) every time update my system just to force Wayland onto apps that refuse it without encouragement.

EDIT: Or should i just make a new derivation that takes brave as a build input, creates a desktop file referencing it and call it “Braveland”? or something like that?

EDIT2: I know in the Brave case this can be solved with feature flags in configuration, but the topic mentions some would like to do this to all electron apps to use Wayland rather than XWayland.

In this specific case there’s now a way to do that built-in.

To avoid recompiling, I’m using symlinkJoin, for example:

pkgs.symlinkJoin {
  name = "tdesktop";
  paths = [ pkgs.tdesktop ];
  buildInputs = [ pkgs.makeWrapper ];
  postBuild = ''
    wrapProgram $out/bin/telegram-desktop --set QT_QPA_PLATFORM xcb
   '';
}
2 Likes