Include custom environment variable into wrapper

The Wiki has detailed variants of a solution. Building on the answer I found on StackOverflow I suggest (without testing it or knowing anything about the packages in question):

{ 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.

2 Likes