Qt5 with Clang on NixOS?

Greetings folks. I’m trying to test a Qt5 package of a project I’m working on with Clang, but I can’t manage to get it to actually use Clang instead of GCC.

I’ve tried

libsForQt5.callPackage ../path/to/derivation {
  stdenv = clangStdenv;
};

and as suggested in a GitHub issue

mkDerivationWith clangStdenv.mkDerivation rec {

but both versions keep using GCC.

Our project file detects the Qt5-configured compiler & version thereof for error workarounds and I wanted to test building it under Clang, but the attempts above, while pulling in llvm-related stuff, both print “GCC”, “9.2.0” and enter non-clang blocks.

  clang {
    message("Qt configured with Clang")
    [print version]
  }
  else {
    message("Qt configured with GCC")
    [print version]
  }
Project MESSAGE: Qt configured with GCC
Project MESSAGE: Compiler is version 9.2.0

Adding -d to qmakeFlags shows that the build indeed loads linux-g++ mkspecs instead of linux-clang ones:

DEBUG 1: visiting file /nix/store/683fblqihpz1wbrhibwbp02aq684plm7-qtbase-5.12.7-dev/mkspecs/linux-g++/qmake.conf
[…]
DEBUG 1: visiting file /nix/store/683fblqihpz1wbrhibwbp02aq684plm7-qtbase-5.12.7-dev/mkspecs/common/g++-base.conf
DEBUG 1: /nix/store/683fblqihpz1wbrhibwbp02aq684plm7-qtbase-5.12.7-dev/mkspecs/common/g++-base.conf:13: QMAKE_CC := gcc
DEBUG 1: /nix/store/683fblqihpz1wbrhibwbp02aq684plm7-qtbase-5.12.7-dev/mkspecs/common/g++-base.conf:18: QMAKE_CXX := g++

So I figure that I need to override qt5 itself to use Clang. I tried overriding just the stdenv for qt5 to clangStdenv for a start but that errors when it tries to build macOS-specific modules on x86_64-linux?

bt1cn@NixTop:~/devel/nixpkgs
↪ nix-build -E 'let pkgs = import ./. {}; in pkgs.qt5.override { stdenv = pkgs.clangStdenv; }'
error: Package ‘qtmacextras-5.12.7’ in /home/bt1cn/devel/nixpkgs/pkgs/development/libraries/qt-5/qtModule.nix:54 is not supported on ‘x86_64-linux’, refusing to evaluate.

Am I understand something incorrectly about how to do this or what would the proper way of building Qt5 (packages) on NixOS with Clang be, if it’s even currently supported? I don’t fiddle around with this sorta stuff alot, so apologies if I missed the obvious. :sweat_smile: