nix-shell -p llvmPackages_8.stdenv doesn't have clang8 set in env

424 Views Asked by At

I'm trying to build a C++ project that requires a rather old version of clang, namely version 8. That project doesn't have any default.nix or shell.nix.

I tried:

> nix-shell -p llvmPackages_8.stdenv
[nix-shell:~/git/the-project]$ clang --version
clang version 11.1.0
Target: x86_64-apple-darwin
Thread model: posix
InstalledDir: /nix/store/s759kzdnl4p740wj1965bcygwn88n4xx-clang-11.1.0/bin

As you can see the clang version is not the one I expected it to be. I also tried

  • nix-shell -p llvmPackages_8.stdenv -p clang_8
  • nix-shell -p clangStdenv
  • nix-shell -p clangStdenv -p clang_8

Am I getting something wrong with nix-shell?

1

There are 1 best solutions below

1
lugggas On BEST ANSWER

I found it out my self. This is how I overcame the problem. I created a shell.nix in the repo with this content:

with import <nixpkgs> {};
llvmPackages.libcxxStdenv.mkDerivation {
  name = "env";
  nativeBuildInputs = [ clang-tools ];
  buildInputs = [ cmake openssl_1_1 python ] ++ lib.optionals libcxxStdenv.isDarwin (with darwin.apple_sdk.frameworks; [
    Cocoa
    CoreServices
  ]);
}