Hey,
I already searched a lot but most of the stuff I found looks too complicated. I want to place a custom environment variable into the wrapper of programs like “signal-desktop” and “atom”. For example GDK_BACKEND=x11. I would like to put this “fix” into my configuration.nix file.
I guess this is possible by using overlays or derivations, but I’m not sure how to use them
{ config, pkgs, ...}:
let
atom-overlay = self: super: {
# override derivation attributes
atom = super.atom.overrideAttrs (old: {
# add `makeWrapper` to existing dependencies
buildInputs = old.buildInputs ++ [ pkgs.makeWrapper ];
# wrap the binary in a script where the appropriate env var is set
postInstall = old.postInstall or "" + ''
wrapProgram "$out/bin/atom" --set GDK_BACKEND x11
'';
})
};
in
{
# add the overlay to your nixpkgs in the system configuration
config.nixpkgs.overlays = [ atom-overlay ];
}
Rebuilding should not be a problem for GUI applications, as I would expect nothing to depend on them.
Just for reference, here is a previous discussion of the general problem with wrappers.