I’m trying to use OBS Studio (OBS) on wayland, but for it to properly work I need to set the environment variable QT_QPA_PLATFORM = "wayland", so I did this in my configuration.nix as follows:
I’ve just found this thread through search and here’s an update with a common contemporary strategy to handle this as it took me some time to figure out so here’s a quick step-by-step:
create overlays.nix next to your configuration.nix and create an overlay for your package using @R-VdP suggestion to extend the postInstall script:
Here the original packaging of obs-studio is being modified and post installation script is being added that wraps the obs executable with an env variable. The wrapProgram tool is the key ingredient here and it’s really poorly documented but the --set key value just wraps executable with environment setting.
Then in your configuration.nix you need to set the nixpkgs.overlays value with your overlays.nix import:
nixpkgs.overlays = [
(import ./overlays.nix)
];
now when you rebuild with sudo nixos-rebuild switch the package will be reinstalled with a new postInstall script that adds the env variable!