Avoid building clang-tools-extra targets


I’m trying to build a program that has dependencies on LLVM and Clang. The platform I’m running on is darwin.

My derivation.nix is:

{ stdenv, meson, ninja, llvm_8, clang_8 }:

stdenv.mkDerivation rec {
  name = "program_name";
  version = "1.3.0";

  src = ./.;

  nativeBuildInputs = [ meson ninja ];
  buildInputs = [ llvm_8 clang_8 ];

and my default.nix is

    pkgs   ? import <nixpkgs> {},
    stdenv ? pkgs.stdenv
rec {
  myProject = stdenv.mkDerivation {
    name = "xyz";
    buildInputs = with pkgs; [
      (callPackage ./deriv.nix { /* stdenv = stdenv; */ })

Clang is built from source when I call nix-shell and the build fails on some missing header from clang-doc.

I don’t need any of the clang-tools-extra binaries, including clang-doc, so is there a way to modify the clang package to avoid building them?

I am not on darwin so maybe you could paste the full error and indicate your version of nixpkgs too.
you could override the clang derivation to filter out the clang-tools-extra derivation.
some pseudocode

clang.overrideAttrs (oldAttrs: {
propagatedBuildInputs = filter (x: x != pkgs.clang-tools-extra ) oldAttrs.propagatedBuildInput;

Here is the stdout when I run nix-shell with the files above. I will see if I can get that override to work.


An issue was filed for the root cause of this bug.