haskellPackages.mkDerivation: avoid forcing stdenv.cc if missing

If we don't check `hasCC`, we run into trouble on pkgsCross.ghcjs, one
of the few platforms where `cc` will throw
(so `stdenv.cc.isClang or false would` not be enough).

Problem introduced in 8164b190 / #266172.

+2 -2
+2 -2
pkgs/development/haskell-modules/generic-builder.nix
··· 814 814 815 815 # Implicit pointer to integer conversions are errors by default since clang 15. 816 816 # Works around https://gitlab.haskell.org/ghc/ghc/-/issues/23456. 817 - // lib.optionalAttrs stdenv.cc.isClang { 817 + // lib.optionalAttrs (stdenv.hasCC && stdenv.cc.isClang) { 818 818 NIX_CFLAGS_COMPILE = "-Wno-error=int-conversion"; 819 819 } 820 820 821 821 # Ensure libc++abi is linked even when clang is invoked as just `clang` or `cc`. 822 822 # Works around https://github.com/NixOS/nixpkgs/issues/166205. 823 823 # This can be dropped once a fix has been committed to cc-wrapper. 824 - // lib.optionalAttrs (stdenv.cc.isClang && stdenv.cc.libcxx != null) { 824 + // lib.optionalAttrs (stdenv.hasCC && stdenv.cc.isClang && stdenv.cc.libcxx != null) { 825 825 NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}"; 826 826 } 827 827 )