Adding a symlink or extra directory indirection for a package

I am trying to recompile ollama for use with an amd graphics card.
To do so, I am following the instructions from:
https://blog.rabu.me/ollama-running-on-an-amd-gpu/
https://github.com/jmorganca/ollama/issues/738

This has led me to create a shell.nix consisting of:

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
    
    buildInputs = with pkgs; [
        rocmPackages.rocm-smi
        rocmPackages.rocminfo
        rocmPackages.llvm.rocmClangStdenv
        rocmPackages.miopen-opencl
        rocmPackages.miopen-hip
        clblast
        go
        cmake
    ];

    shellHook = with pkgs; ''
        export ROCM_PATH="${rocmPackages.llvm.clang}"
        export CLBlast_DIR="${clblast}"
    '';
}

The problem is that my clang is at $ROCM_PATH/bin/clang rather than $ROCM_PATH/llvm/bin/clang
which results in this error:

CMake Error at CMakeLists.txt:2 (project):
  The CMAKE_C_COMPILER:

    /nix/store/94pj818ysk7aqlf8nnxj6z85j0mw980r-rocm-llvm-clang-wrapper-5.7.1/llvm/bin/clang

  is not a full path to an existing compiler tool.

Unless there is a more elegant way, how can I create an llvm symlink somewhere (preferrably in the ${rocmPackages.llvm.clang} directory) to point to ${rocmPackages.llvm.clang} so that the go generate will find the appropriate clang?

I realize this is probably a very easy answer for anyone who understands the nix language so I have been studying in hopes of asking less dumb questions.

It seems that I could create this link either by making a new derivation or by making an overlay of the current derivation and adding the link. I don’t really understand how to manipulate overlays as well as I would like yet, but hypothetically if I did understand that: Which would be considered the better way to go?

(Or am I still completely going the wrong way)

I finally took another large step in learning nix. I solved the specific problem I posted here, by creating a derivative that contained the link to provide the extra bit of indirection. I still have not delved into overlays. I also refactored this shell into a flake devshell. I was hoping that if I could get this to build, I could just move my devshell inputs into make a derivation for ollama-rocm.

I think I might finally be stuck at a place where I just don’t understand rocm well enough to continue, but I thought I would post the flake which gets the devshell for the compile much of the way through:

{
    inputs = {
        nixpkgs.url="github:NixOS/nixpkgs/23.11";
    };

    outputs = {self, nixpkgs}: 
    let
        system = "x86_64-linux";
    in
    {
        devShells.${system} = 
        let
            pkgs = nixpkgs.legacyPackages.${system};
        in
        {
            default = pkgs.mkShell rec {
                name = "rocm-shell";

                link = pkgs.runCommand "link" {} ''
                    mkdir $out
                    ln -s ${pkgs.rocmPackages.llvm.clang} $out/llvm
                '';


                nativeBuildInputs = with pkgs; [
                    rocmPackages.rocm-smi
                    rocmPackages.rocminfo
                    rocmPackages.llvm.rocmClangStdenv
                    rocmPackages.llvm.bintools
                    rocmPackages.llvm.clang
                    rocmPackages.miopen-opencl
                    rocmPackages.miopen-hip
                    rocmPackages.hipblas
                    rocmPackages.rocblas
                    rocmPackages.hipify
                    rocmPackages.hipcc
                    rocmPackages.hipsolver
                    rocmPackages.hip-common
                    rocmPackages.clr
                    rocmPackages.rocm-runtime
                    rocmPackages.rocm-device-libs
                    rocmPackages.rocm-cmake
                    clblast
                    go
                    cmake
                ];

                shellHook = with pkgs; ''
                    export ROCM_PATH="${link}"
                    export ROCM_DEVICE_LIB_PATH="${rocmPackages.rocm-device-libs}"
                    export CLBlast_DIR="${clblast}"
                '';

                # go generate -tags rocm ./...
                # go build -tags rocm
            };
        };
    };
}

I may have packages there I don’t need and I almost certainly am missing some that I do need. I think I can call this an answer to the question I actually asked though.

If anyone wishes to take on trying to complete this, using this devshell inside the git repository for ollama:

Just as commented at the bottom of the flake:
~/ollama$ go generate -tags rocm ./...

That doesn’t complete for me because it can’t find the rocm device library path, but theoretically if it did then the next step would be:
~/ollama$ go build -tags rocm