Nix nativeStdenv on RHEL7

Hello,

I currently have a use case where I would like to use NixPkg on RHEL, but
continue to compile with the RedHat toolchains and the RHEL7 ABI, so that the
packages built by Nix are interoperable with the operating system packages and
proprietary vendor packages targeting the platform.

I see that pkgs/stdenv/default.nix has a switch where – for certain
architectures such as FreeBSD, PowerPC, or Cygwin – it will set stdenv to the
stagesNative stdenv, which uses the system tools at /usr/{bin,lib} for CC, libc,
and bintools. This actually does what I want (possibly using
/opt/rh/devtoolset-N instead, but that looks easy enough to tweak once I get the
basics), except I can’t figure out how to call NixPkgs with an overlay that
replaces stdenv with nativeStdenv. The booter seems to switch on the localSystem
arg and default to nativeStdenv if it doesn’t recognize the system, but if I
mess with that parameter I end up failing to detect CPU type and endianness
elsewhere.

Does anyone know how to do this? Ideally I’d like to do it in an import argument
or overlay, so that I can continue to use NixPkgs as-is without modifying the
source tree to change pkgs/stdenv/default.nix.

1 Like

IIRC overlays can’t change stdenv and the way it’s bootstrapped. I may be wrong; it’s a really vague memory.