Why does nix flake devShell always include clang?

I have a flake.nix file that does not introduce any dependency (I believe). But clang appears in the $PATH of the devShell anyway. Why? How to remove it?

{
  description = "desc";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils, ... }:
    flake-utils.lib.eachDefaultSystem (
      system:
        let
          pkgs = import nixpkgs { inherit system; };
        in
          {
            devShell = pkgs.mkShell {};
          }
    );
}
ļŒ“ /tmp/test$ which -a clang
/nix/store/km02igh4pshp20d0wn89rf5jjfxcm8v5-clang-wrapper-11.1.0/bin/clang
/nix/store/bvd1g0lir3phx8d0l297ihsx8xg8dba6-clang-11.1.0/bin/clang
/usr/bin/clang
/Library/Developer/CommandLineTools/usr/bin/clang

Note that I’m using nix-darwin and the default clang from nixpkgs-unstable channel is exactly 11.1.0 for now. This problem of unexpected clang does not appear on NixOS 21.11

As far as I understand this is because of Darwin, on a Linux machine it would probably be gcc.

This is just how the stdenv is defined for those systems.

2 Likes

correct. stdenv on Darwin will have the clang toolchain. You can do gccStdenv to force a gcc environment on mac.

3 Likes

Woah. Just tested on NixOS and there is gcc.

Thank you guys and I found a solution to use stdenvNoCC from Jon Exclude gcc toolchain for a nix-shell? - #4 by jonringer :smiley:

3 Likes