title: How can I build self-hosted clang in nix?
body: <p>I'm trying to build a self-hosted clang in nix.</p>
  <p>By reference to other pages (<a href="https://nixos.wiki/wiki/Using_Clang_instead_of_GCC" rel="nofollow noreferrer">NixOS Wiki: Using Clang instead of GCC</a>) and threads (<a href="https://discourse.nixos.org/t/use-clang-without-gccs-c-standard-library/9884/4" rel="nofollow noreferrer">Nix discourse: Use Clang without GCC's C++ standard library</a>), I tried (variations on):</p>
  <pre><code>nix-build -E &quot;with import &lt;nixpkgs&gt; {}; pkgs.clang-tools.override{ stdenv = pkgs.clangStdenv.override (x: {cc = x.cc.override(_: {libcxx = llvmPackages.libcxx;}); }); }&quot;
  </code></pre>
  <p>But this appears to not be working:</p>
  <pre><code>$ nix-build -E &quot;with import &lt;nixpkgs&gt; {}; pkgs.clang-tools.override{ stdenv = pkgs.clangStdenv.override (x: {cc = x.cc.override(_: {libcxx = llvmPackages.libcxx;}); }); }&quot;
  /nix/store/45whyxm1y5mjf5g12c0wjvjcmrxxqdaz-clang-tools-10.0.1
  $ tail -n 1 /nix/store/45whyxm1y5mjf5g12c0wjvjcmrxxqdaz-clang-tools-10.0.1/bin/clangd
  exec -a &quot;$0&quot; /nix/store/6pzqj9q656vc1msa675k75hmhsrfizsy-clang-10.0.1/bin/$(basename $0) &quot;$@&quot;
  $ ldd /nix/store/6pzqj9q656vc1msa675k75hmhsrfizsy-clang-10.0.1/bin/clangd | grep gcc
  libstdc++.so.6 =&gt; /nix/store/c10296m7xgm3ksibcklb2xf48jr635x3-gcc-9.3.0-lib/lib/libstdc++.so.6 (0x00007f55d359b000)
  libgcc_s.so.1 =&gt; /nix/store/0c7c96gikmzv87i7lv3vq5s1cmfjd6zf-glibc-2.31-74/lib/libgcc_s.so.1 (0x00007f55d343e000)
  </code></pre>
  <p>Am I missing a step?  Or mis-interpreting the output of ldd?  I realize that <code>clangd</code> is itself a script, I did reproduce the environment that creates, but it makes no difference (and I wouldn't expect it to).  I've excised that from my example above for simplicity.</p>