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):
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)?
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
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.