Overriding llvmPackage source with local checkout in flake for clang-tools package

I am trying to create a dev environment where I can use clang-tools from a locally modified LLVM checkout.
I am not trying to do anything with a special stdenv, I only want to add a customized clang-tools package to the dev env.

My current flake is (flake used via direnv, with --impure due to the path):

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs =
    {
      self,
      nixpkgs,
    }:
    let
      system = "x86_64-linux";
      overlays = [
        (final: prev: {
          llvmPackages_custom = prev.llvmPackages_git.override (prev: {
            src = /home/user/dev/llvm/;
            doCheck = false;
            dontUnpack = true;
          });
        })
      ];
      pkgs = import nixpkgs {
        inherit system overlays;
      };
    in
    {
      packages.${system}.default = pkgs.stdenv.mkDerivation {
        name = "test";
        src = ./.;
        buildInputs = [
          pkgs.llvmPackages_custom.clang-tools
          pkgs.spdlog
        ];

      };
    };
}

But it looks like this is not actually overriding the source like I want it to. Instead, it is just llvmPackages_git. I’ve also tried a few permutations of src vs monorepoSrc, override vs overrideAttrs, and llvmPackages_custom vs llvmPackages_custom.clang-tools with no success. I must be doing something wrong here. Can anyone tell me what the correct way to do this would be?

CC @Patryk27 as the maintainer of the clang-tools package. Do you know how I could do this? Or would someone else from the maintainers listed for clang-tools in the nixpkgs search know (I didn’t want to ping 8 people)?

Hi!

llvmPackages doesn’t have an argument called src, it’s monorepoSrc:

… so try doing monorepoSrc = /home/user/dev/llvm; :eyes:

Let me know if it works - if it still doesn’t, will try to figure it out.

Thanks for the quick reply. That sadly did not work (s/src = /monorepoSrc = ):

user@nixos ~/d/l/flake-test [1]> nix build .
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'test'
         whose name attribute is located at /nix/store/9x1a429wj6sy54bfr028820n5mgyvdri-source/pkgs/stdenv/generic/make-derivation.nix:482:13

       … while evaluating attribute 'buildInputs' of derivation 'test'
         at /nix/store/9x1a429wj6sy54bfr028820n5mgyvdri-source/pkgs/stdenv/generic/make-derivation.nix:537:13:
          536|             depsHostHost = elemAt (elemAt dependencies 1) 0;
          537|             buildInputs = elemAt (elemAt dependencies 1) 1;
             |             ^
          538|             depsTargetTarget = elemAt (elemAt dependencies 2) 0;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: expected a set but found a path: «unknown»/home/user/dev/llvm

Okie, approach v2.0:

monorepoSrc = (fetchGit /home/user/dev/llvm) // {
  passthru = {
    owner = "";
    repo = "";
    rev = "";
  };
};

We can’t use a plain path, because LLVM expects for monorepoSrc to be a derivation that builds the source (using fetchGit is the easiest way if you happen to use a Git-based checkout of LLVM), and the seemingly random owner, repo and rev come from here:

… and are probably used to build some sort of VERSION="..." string later compiled into LLVM for debugging purposes, I guess; but it seems they are not validated whatsoever, so empty strings are good as any.

I think this might be ‘working’, as in getting the right source, but I had to change llvmPackages_git to llvmPackages_21 because it complained about the major version, but I am now stuck at

error: builder for '/nix/store/ds3s71kichv3c7p5zln6xpmflfmyxyms-llvm-21.1.0-rc2.drv' failed with exit code 3;
       last 25 log lines:
       > -- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY - Failed
       > -- Performing Test HAVE_CXX_FLAG_COVERAGE
       > -- Performing Test HAVE_CXX_FLAG_COVERAGE - Success
       > -- Compiling and running to test HAVE_GNU_POSIX_REGEX
       > -- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
       > -- Compiling and running to test HAVE_POSIX_REGEX
       > -- Performing Test HAVE_POSIX_REGEX -- success
       > -- Compiling and running to test HAVE_STEADY_CLOCK
       > -- Performing Test HAVE_STEADY_CLOCK -- success
       > -- Compiling and running to test HAVE_PTHREAD_AFFINITY
       > -- Performing Test HAVE_PTHREAD_AFFINITY -- success
       > -- Configuring done (8.9s)
       > -- Generating done (1.6s)
       > CMake Warning:
       >   Manually-specified variables were not used by the project:
       >
       >     CMAKE_EXPORT_NO_PACKAGE_REGISTRY
       >     CMAKE_POLICY_DEFAULT_CMP0025
       >     LLVM_ENABLE_TERMINFO
       >
       > 
       > -- Build files have been written to: /build/llvm-src-21.1.0-rc2/llvm/build
       > cmake: enabled parallel building
       > cmake: enabled parallel installing
       > mismatch in the minor version! we have version 21.1.0-rc2 and expected the minor version to be '1'; the source has '0' instead
       For full logs, run:
         nix log /nix/store/ds3s71kichv3c7p5zln6xpmflfmyxyms-llvm-21.1.0-rc2.drv

Is this what you mean with VERSION?
Setting version in override to e.g., "21.1" errors out.

Current flake
{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs =
    {
      self,
      nixpkgs,
    }:
    let
      system = "x86_64-linux";
      overlays = [
        (final: prev: {
          llvmPackages_custom = prev.llvmPackages_21.override (prev: {
            monorepoSrc = (fetchGit /home/user/dev/llvm) // {
              passthru = {
                owner = "";
                repo = "";
                rev = "";
              };
            };
            doCheck = false;
            dontUnpack = true;
          });
        })
      ];
      pkgs = import nixpkgs {
        inherit system overlays;
      };
    in
    {
      packages.${system}.default = pkgs.stdenv.mkDerivation {
        name = "test";
        src = ./.;
        buildInputs = [
          pkgs.llvmPackages_custom.clang-tools
        ];

      };
    };
}

How about version = "21.0.0";, then? :eyes:

That worked (I do get a build error that’s unrelated to my changes though, not sure what the issue would be)

llvm> [381/4817] Building CXX object lib/MC/CMakeFiles/LLVMMC.dir/MCAsmInfoWasm.cpp.o
llvm> [382/4817] Building CXX object lib/IR/CMakeFiles/LLVMCore.dir/RuntimeLibcalls.cpp.o
llvm> FAILED: lib/IR/CMakeFiles/LLVMCore.dir/RuntimeLibcalls.cpp.o
llvm> /nix/store/354j0fc7cccsdlxq7zwbj9d6l59bx6p4-ccache-links-wrapper-4.11.3/bin/g++ -DLLVM_EXPORTS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/build/llvm-src-22.0.0-unstable-2025-07-28/llvm/build/lib/IR -I/build/llvm-src-22.0.0-unstable-2025-07-28/llvm/lib/IR -I/build/llvm-src-22.0.0-unstable-2025-07-28/llvm/build/include -I/build/llvm-src-22.0.0-unstable-2025-07-28/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -MD -MT lib/IR/CMakeFiles/LLVMCore.dir/RuntimeLibcalls.cpp.o -MF lib/IR/CMakeFiles/LLVMCore.dir/RuntimeLibcalls.cpp.o.d -o lib/IR/CMakeFiles/LLVMCore.dir/RuntimeLibcalls.cpp.o -c /build/llvm-src-22.0.0-unstable-2025-07-28/llvm/lib/IR/RuntimeLibcalls.cpp
llvm> In file included from /build/llvm-src-22.0.0-unstable-2025-07-28/llvm/lib/IR/RuntimeLibcalls.cpp:20:
llvm> /build/llvm-src-22.0.0-unstable-2025-07-28/llvm/build/include/llvm/IR/RuntimeLibcalls.inc:2565:26: error: 'const llvm::RTLIB::LibcallImpl llvm::RTLIB::RuntimeLibcallsInfo::DefaultLibcallImpls [814]' is not a static data member of 'struct llvm::RTLIB::RuntimeLibcallsInfo'
llvm>  2565 | const RTLIB::LibcallImpl llvm::RTLIB::RuntimeLibcallsInfo::DefaultLibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
llvm>       |                          ^~~~
llvm> /build/llvm-src-22.0.0-unstable-2025-07-28/llvm/build/include/llvm/IR/RuntimeLibcalls.inc: In member function 'void llvm::RTLIB::RuntimeLibcallsInfo::setTargetRuntimeLibcallSets(const llvm::Triple&, llvm::FloatABI::ABIType)':
llvm> /build/llvm-src-22.0.0-unstable-2025-07-28/llvm/build/include/llvm/IR/RuntimeLibcalls.inc:17171:3: error: 'initDefaultLibCallImpls' was not declared in this scope
llvm> 17171 |   initDefaultLibCallImpls();
llvm>       |   ^~~~~~~~~~~~~~~~~~~~~~~
llvm> [383/4817] Building CXX object lib/MC/CMakeFiles/LLVMMC.dir/MCAsmInfoXCOFF.cpp.o
llvm> [384/4817] Building CXX object lib/MC/CMakeFiles/LLVMMC.dir/MCInstrInfo.cpp.o
llvm> [385/4817] Building CXX object lib/MC/CMakeFiles/LLVMMC.dir/MCLabel.cpp.o

I’ll try my best to figure it out (unless you have ideas).

Thanks to @Patryk27, here is the flake that almost works:

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs =
    {
      self,
      nixpkgs,
    }:
    let
      system = "x86_64-linux";
      overlays = [
        (final: super: {
          llvmPackages_custom = super.llvmPackages_git.override (prev: {
            monorepoSrc = (fetchGit /home/user/dev/llvm) // {
              passthru = {
                owner = "";
                repo = "";
                rev = "";
              };
            };
            version = "22.0.0";
            doCheck = false;
            dontUnpack = true;
          });
        })
      ];
      pkgs = import nixpkgs {
        inherit system overlays;
      };
    in
    {
      packages.${system}.default = pkgs.stdenv.mkDerivation {
        name = "test";
        src = ./.;
        buildInputs = [
          pkgs.llvmPackages_custom.clang-tools
        ];

      };
    };
}

When you were making those changes to LLVM, have you added any new files to /home/user/dev/llvm?

fetchGit only fetches files that were committed or at least git added to the index.

I’ve tried to reproduce it locally, on my own copy of LLVM - and in my case the build succeeded:

error: builder for '/nix/store/xzjavw6lfqny1ryzrq7z34paja0nc7bj-test.drv' failed to produce output path for output 'out' at '/nix/store/xzjavw6lfqny1ryzrq7z34paja0nc7bj-test.drv.chroot/root/nix/store/c4ffavhnh9asal54bnmzgrzgk21d9jn4-test'

I mean, it failed, because that test derivation of yours doesn’t produce any output, but the LLVM itself built successfully.

I just tried it with a clean fetch from main (7fb8630e71c4) with no additinal changes and it also fails:

[1533/4817] Building CXX object lib/Transforms/Coroutines/CMakeFiles/LLVMCoroutines.dir/Coroutines.cpp.o
[1534/4817] Building R600GenAsmWriter.inc...
[1535/4817] Building CXX object lib/Transforms/Coroutines/CMakeFiles/LLVMCoroutines.dir/CoroEarly.cpp.o
[1536/4817] Building CXX object lib/Transforms/Coroutines/CMakeFiles/LLVMCoroutines.dir/CoroFrame.cpp.o
[1537/4817] Building CXX object lib/ExecutionEngine/Orc/Shared/CMakeFiles/LLVMOrcShared.dir/SimpleRemoteEPCUtils.cpp.o
[1538/4817] Building CXX object lib/Transforms/CFGuard/CMakeFiles/LLVMCFGuard.dir/CFGuard.cpp.o
[1539/4817] Building CXX object lib/Transforms/HipStdPar/CMakeFiles/LLVMHipStdPar.dir/HipStdPar.cpp.o
[1540/4817] Building R600GenCallingConv.inc...
[1541/4817] Building R600GenSubtargetInfo.inc...
[1542/4817] Building R600GenMCCodeEmitter.inc...
[1543/4817] Building R600GenDAGISel.inc...
FAILED: lib/Target/AMDGPU/R600GenDAGISel.inc /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/AMDGPU/R600GenDAGISel.inc 
cd /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/AMDGPU && /nix/store/gcc4gk5ayaxpnxvm8pajsxpsw54wwqjj-llvm-tblgen-22.0.0-unstable-2025-08-03/bin/llvm-tblgen -gen-dag-isel -I/build/llvm-src-22.0.0-unstable-2025-08-03>
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/R600.td:40:
/build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/R600Instructions.td:1692:1: error: Type set is empty for each HW mode in 'anonymous_8907'
def : ExtractVerticalPat <R600_EXTRACT_ELT_V2, v2i32, i32>;
^
[1544/4817] Building R600GenDFAPacketizer.inc...
[1545/4817] Building HexagonGenAsmMatcher.inc...
[1546/4817] Building R600GenRegisterInfo.inc...
[1547/4817] Building HexagonGenCallingConv.inc...
[1548/4817] Building R600GenInstrInfo.inc...
FAILED: lib/Target/AMDGPU/R600GenInstrInfo.inc /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/AMDGPU/R600GenInstrInfo.inc 
cd /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/AMDGPU && /nix/store/gcc4gk5ayaxpnxvm8pajsxpsw54wwqjj-llvm-tblgen-22.0.0-unstable-2025-08-03/bin/llvm-tblgen -gen-instr-info -I/build/llvm-src-22.0.0-unstable-2025-08->
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/R600.td:40:
/build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/R600Instructions.td:1692:1: error: Type set is empty for each HW mode in 'anonymous_8907'
def : ExtractVerticalPat <R600_EXTRACT_ELT_V2, v2i32, i32>;
^
[1549/4817] Building HexagonGenAsmWriter.inc...
[1550/4817] Building HexagonGenDAGISel.inc...
FAILED: lib/Target/Hexagon/HexagonGenDAGISel.inc /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/Hexagon/HexagonGenDAGISel.inc 
cd /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/Hexagon && /nix/store/gcc4gk5ayaxpnxvm8pajsxpsw54wwqjj-llvm-tblgen-22.0.0-unstable-2025-08-03/bin/llvm-tblgen -gen-dag-isel -I/build/llvm-src-22.0.0-unstable-2025-08-0>
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/Hexagon/Hexagon.td:402:
/build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/Hexagon/HexagonPatterns.td:526:1: error: Type set is empty for each HW mode in 'anonymous_9818'
def: Pat<(v2i16 (sext V2I1:$Pu)), (S2_vtrunehb (C2_mask V2I1:$Pu))>;
^
[1551/4817] Building AMDGPUGenPostLegalizeGICombiner.inc...
[1552/4817] Building AMDGPUGenDisassemblerTables.inc...
[1553/4817] Building AMDGPUGenGlobalISel.inc...
FAILED: lib/Target/AMDGPU/AMDGPUGenGlobalISel.inc /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/AMDGPU/AMDGPUGenGlobalISel.inc 
cd /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/AMDGPU && /nix/store/gcc4gk5ayaxpnxvm8pajsxpsw54wwqjj-llvm-tblgen-22.0.0-unstable-2025-08-03/bin/llvm-tblgen -gen-global-isel -I/build/llvm-src-22.0.0-unstable-2025-08>
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/AMDGPUGISel.td:13:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/AMDGPU.td:2897:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstrInfo.td:3439:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstructions.td:26:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPInstructions.td:2195:
/build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPCInstructions.td:384:7: error: Type set is empty for each HW mode in 'V_CMP_F_F32_e64'
  def _e64 : VOP3_Pseudo<opName, P, getVOPCPat64<cond, P>.ret, /*IsVOP3P*/false, P.HasOpSel>,
      ^
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/AMDGPUGISel.td:13:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/AMDGPU.td:2897:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstrInfo.td:3439:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstructions.td:26:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPInstructions.td:2195:
/build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPCInstructions.td:587:20: note: instantiated from multiclass
defm V_CMP_F_F32 : VOPC_F32 <"v_cmp_f_f32">;
                   ^
[1554/4817] Building AMDGPUGenMCCodeEmitter.inc...
[1555/4817] Building AMDGPUGenAsmWriter.inc...
[1556/4817] Building AMDGPUGenInstrInfo.inc...
FAILED: lib/Target/AMDGPU/AMDGPUGenInstrInfo.inc /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/AMDGPU/AMDGPUGenInstrInfo.inc 
cd /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/AMDGPU && /nix/store/gcc4gk5ayaxpnxvm8pajsxpsw54wwqjj-llvm-tblgen-22.0.0-unstable-2025-08-03/bin/llvm-tblgen -gen-instr-info -I/build/llvm-src-22.0.0-unstable-2025-08->
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/AMDGPU.td:2897:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstrInfo.td:3439:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstructions.td:26:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPInstructions.td:2195:
/build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPCInstructions.td:384:7: error: Type set is empty for each HW mode in 'V_CMP_F_F32_e64'
  def _e64 : VOP3_Pseudo<opName, P, getVOPCPat64<cond, P>.ret, /*IsVOP3P*/false, P.HasOpSel>,
      ^
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/AMDGPU.td:2897:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstrInfo.td:3439:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstructions.td:26:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPInstructions.td:2195:
/build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPCInstructions.td:587:20: note: instantiated from multiclass
defm V_CMP_F_F32 : VOPC_F32 <"v_cmp_f_f32">;
                   ^
[1557/4817] Building AMDGPUGenMCPseudoLowering.inc...
[1558/4817] Building AMDGPUGenPreLegalizeGICombiner.inc...
[1559/4817] Building AMDGPUGenCallingConv.inc...
[1560/4817] Building AMDGPUGenRegBankGICombiner.inc...
[1561/4817] Building AMDGPUGenSubtargetInfo.inc...
[1562/4817] Building AMDGPUGenAsmMatcher.inc...
[1563/4817] Building AMDGPUGenRegisterInfo.inc...
[1564/4817] Building AMDGPUGenSearchableTables.inc...
[1565/4817] Building AMDGPUGenDAGISel.inc...
FAILED: lib/Target/AMDGPU/AMDGPUGenDAGISel.inc /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/AMDGPU/AMDGPUGenDAGISel.inc 
cd /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/build/lib/Target/AMDGPU && /nix/store/gcc4gk5ayaxpnxvm8pajsxpsw54wwqjj-llvm-tblgen-22.0.0-unstable-2025-08-03/bin/llvm-tblgen -gen-dag-isel -I/build/llvm-src-22.0.0-unstable-2025-08-03>
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/AMDGPU.td:2897:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstrInfo.td:3439:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstructions.td:26:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPInstructions.td:2195:
/build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPCInstructions.td:384:7: error: Type set is empty for each HW mode in 'V_CMP_F_F32_e64'
  def _e64 : VOP3_Pseudo<opName, P, getVOPCPat64<cond, P>.ret, /*IsVOP3P*/false, P.HasOpSel>,
      ^
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/AMDGPU.td:2897:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstrInfo.td:3439:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/SIInstructions.td:26:
Included from /build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPInstructions.td:2195:
/build/llvm-src-22.0.0-unstable-2025-08-03/llvm/lib/Target/AMDGPU/VOPCInstructions.td:587:20: note: instantiated from multiclass
defm V_CMP_F_F32 : VOPC_F32 <"v_cmp_f_f32">;
                   ^
[1566/4817] Building AMDGPUGenRegisterBank.inc...
ninja: build stopped: subcommand failed.

{
  description = "A very basic flake";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

  outputs =
    {
      self,
      nixpkgs,
    }:
    let
      system = "x86_64-linux";
      overlays = [
        (self: super: {
          ccacheWrapper = super.ccacheWrapper.override {
            extraConfig = ''
              export CCACHE_COMPRESS=1
              export CCACHE_DIR="/var/cache/ccache"
              export CCACHE_UMASK=007
              export CCACHE_SLOPPINESS=random_seed
              if [ ! -d "$CCACHE_DIR" ]; then
                echo "====="
                echo "Directory '$CCACHE_DIR' does not exist"
                echo "Please create it with:"
                echo "  sudo mkdir -m0770 '$CCACHE_DIR'"
                echo "  sudo chown root:nixbld '$CCACHE_DIR'"
                echo "====="
                exit 1
              fi
              if [ ! -w "$CCACHE_DIR" ]; then
                echo "====="
                echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)"
                echo "Please verify its access permissions"
                echo "====="
                exit 1
              fi
            '';
          };
        })
        (final: super: {
          llvmPackages_custom = super.llvmPackages_git.override (prev: {
            monorepoSrc = (fetchGit /home/user/dev/llvm) // {
              passthru = {
                owner = "";
                repo = "";
                rev = "";
              };
            };
            version = "22.0.0";
            doCheck = false;
            dontUnpack = true;
            stdenv = super.ccacheStdenv;
          });
        })
      ];
      pkgs = import nixpkgs {
        inherit system overlays;
      };
    in
    {
      packages.${system}.default = pkgs.stdenv.mkDerivation {
        name = "test";
        src = ./.;
        buildInputs = [
          pkgs.llvmPackages_custom.clang-tools
        ];
      };
    };
}

I mean, it failed, because that test derivation of yours doesn’t produce any output, but the LLVM itself built successfully.

All I need is a dev env where I can test changes I made to tools on external projects (e.g., fmtlib). I’m not trying to package anything, so direnv with use flake /home/user/dev/flake-test --impure is what I am using (just with more packages in buildInputs for the set of projects I want to test).

Okie, let me try to build this flake as well and we’ll see :eyes:

Got the same error, interesting - let’s see what’s going on…

Okie, another approach - could you try this?

(final: super: {
  llvm_custom = super.llvmPackages_git.llvm.override (prev: {
    src = /home/user/dev/llvm-project;
  });

  llvmPackages_custom = super.llvmPackages_git.override (prev: {
    llvm = final.llvm_custom;
  });
})

(possibly with doCheck = false; to avoid running those tons of tests)

That successfully builds the project (but not with the specified path, it builds the git version specified in nixpkgs, explained in the next post), but sadly ignores the doCheck:

      overlays = [
        (self: super: {
          ccacheWrapper = super.ccacheWrapper.override {
            extraConfig = ''
              export CCACHE_COMPRESS=1
              export CCACHE_DIR="/var/cache/ccache"
              export CCACHE_UMASK=007
              export CCACHE_SLOPPINESS=random_seed
              if [ ! -d "$CCACHE_DIR" ]; then
                echo "====="
                echo "Directory '$CCACHE_DIR' does not exist"
                echo "Please create it with:"
                echo "  sudo mkdir -m0770 '$CCACHE_DIR'"
                echo "  sudo chown root:nixbld '$CCACHE_DIR'"
                echo "====="
                exit 1
              fi
              if [ ! -w "$CCACHE_DIR" ]; then
                echo "====="
                echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)"
                echo "Please verify its access permissions"
                echo "====="
                exit 1
              fi
            '';
          };
        })
        (final: super: {
          llvm_custom = super.llvmPackages_git.llvm.override (prev: {
            src = /home/user/dev/llvm-project;
            doCheck = false;
            stdenv = super.ccacheStdenv;
          });
          llvmPackages_custom = super.llvmPackages_git.override (prev: {
            llvm = final.llvm_custom;
            doCheck = false;
            stdenv = super.ccacheStdenv;
          });
        })
      ];

building llvm-22.0.0-unstable-2025-08-03 (checkPhase): PASS ...

Alright, so this one actually built the llvmPackages_git version, not the specified one. I noticed that the date in the package name was from a week ago and confirmed it in nixpkgs (either way my changes were not present):

which clang-tidy
/nix/store/jsjydl7sc4gr9j96iqvs7r4cvbpjkban-clang-tools-22.0.0-unstable-2025-08-03/bin/clang-tidy

Using monorepoSrc again did also not work

Were you able to get llvm overridden I’m trying to do something similar but with this fork. I tried all sorts of things including this fork of nixpkgs. No matter what I try it builds the original llvm (if I override llvmPackages_21 it’s clang 21, if I try llvmPackages_git it’ll be what’s in the git version, currently 22.0.0). The changes and flake I’m trying to do this in is here