|
14 | 14 | system: |
15 | 15 | let |
16 | 16 | pkgs = import nixpkgs { inherit system; }; |
| 17 | + llvmPackages = pkgs.llvmPackages_21; |
| 18 | + # We want to use Clang instead of GCC because it seems to behave better |
| 19 | + # with LLDB, so we use `mkShell` with the LLVM stdenv |
| 20 | + mkShell = pkgs.mkShell.override { stdenv = llvmPackages.stdenv; }; |
| 21 | + # We must use the clangd from `clang-tools` package so that it is |
| 22 | + # wrapped properly. This is harder than it seems becase there is a |
| 23 | + # clangd in clang-unwrapped, which would normally come first thanks to |
| 24 | + # the cc-wrapper/setup-hook adding ${clang-unwrapped}/bin to PATH very |
| 25 | + # early in `mkDerivation` setup. We work around this using a shell hook |
| 26 | + # (below) as that executes very late in shell instantiation and can |
| 27 | + # therefore override cc-wrapper. |
| 28 | + # |
| 29 | + # See https://github.com/NixOS/nixpkgs/issues/76486 for the upstream bug. |
| 30 | + clangd-only = ( |
| 31 | + pkgs.linkFarm "clangd-only" [ |
| 32 | + { |
| 33 | + name = "bin/clangd"; |
| 34 | + # New enough to support `HeaderInsertion: Never` in `.clangd`. |
| 35 | + path = "${llvmPackages.clang-tools}/bin/clangd"; |
| 36 | + } |
| 37 | + ] |
| 38 | + ); |
17 | 39 | in |
18 | 40 | { |
19 | | - # We want to use Clang instead of GCC because it seems to behave better |
20 | | - # with LLDB, so we use `mkShellNoCC` here instead of `mkShell` because |
21 | | - # the latter brings in GCC by default on Linux. |
22 | | - devShell = pkgs.mkShellNoCC { |
| 41 | + devShell = mkShell { |
23 | 42 | buildInputs = [ |
24 | | - # We must list clangd before the `clang` package to make sure it |
25 | | - # comes earlier on the `PATH`, and we must get it from the |
26 | | - # `clang-tools` package so that it is wrapped properly. |
27 | | - (pkgs.linkFarm "clangd-21" [ |
28 | | - { |
29 | | - name = "bin/clangd"; |
30 | | - # New enough to support `HeaderInsertion: Never` in `.clangd`. |
31 | | - path = "${pkgs.llvmPackages_21.clang-tools}/bin/clangd"; |
32 | | - } |
33 | | - ]) |
| 43 | + # Pull in only clang-format from clang-tools 17. This matches the |
| 44 | + # version used in CI. |
34 | 45 | (pkgs.linkFarm "clang-format-17" [ |
35 | 46 | { |
36 | 47 | name = "bin/clang-format"; |
37 | | - # Match the clang-format version used in CI. |
38 | 48 | path = "${pkgs.llvmPackages_17.clang-tools}/bin/clang-format"; |
39 | 49 | } |
40 | 50 | ]) |
41 | 51 |
|
42 | | - pkgs.clang |
43 | 52 | pkgs.cmake |
44 | 53 | pkgs.gersemi |
45 | | - pkgs.lldb |
| 54 | + llvmPackages.lldb |
46 | 55 | pkgs.ninja |
47 | 56 | pkgs.nixfmt-rfc-style |
48 | 57 | pkgs.prettier |
|
51 | 60 | pkgs.vulkan-loader # Ensure this gets built to use in library path. |
52 | 61 | pkgs.xorg.libX11 |
53 | 62 | ]; |
| 63 | + |
54 | 64 | LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ |
55 | 65 | # In addition to this, running the Vulkan tests on Linux distros |
56 | 66 | # other than NixOS may require the use of nixGL: |
57 | 67 | # https://github.com/nix-community/nixGL |
58 | 68 | pkgs.vulkan-loader |
| 69 | + # Needed for the prebuilt LLVM |
| 70 | + pkgs.libz |
| 71 | + pkgs.zstd |
| 72 | + # Despite requiring this packages (slang) to be built with Clang, |
| 73 | + # the prebuilt libslang-llvm.so is actually linked against GCC's |
| 74 | + # libstdc++.so.6 |
| 75 | + pkgs.stdenv.cc.cc.lib |
59 | 76 | ]; |
| 77 | + |
| 78 | + # Use a shell hook to make sure the wrapped clangd is in the path |
| 79 | + # before the unwrapped one included by llvmPackages.stdenv |
| 80 | + shellHook = '' |
| 81 | + PATH="${clangd-only}/bin:$PATH" |
| 82 | + ''; |
60 | 83 | }; |
61 | 84 | } |
62 | 85 | ); |
|
0 commit comments