Trouble Patching LLVM source code for ROCm

I am trying to apply a patch to the version of LLVM that we ship as part of ROCm as part of rocmPackages.composable_kernel: compress output by mschwaig · Pull Request #299589 · NixOS/nixpkgs · GitHub.

I have to do this inside a base.nix file, which gets reused for different derivations that build things located inside of different subdirectories of the source directory.

If I try to apply the patch it basically does not find any of the existing files in question:

|diff --git a/clang/docs/ClangOffloadBundler.rst b/clang/docs/ClangOffloadBundler.rst
|index 432da787249b..d47997bf718d 100644
|--- a/clang/docs/ClangOffloadBundler.rst
|+++ b/clang/docs/ClangOffloadBundler.rst
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 86
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/clang/include/clang/Driver/OffloadBundler.h b/clang/include/clang/Driver/OffloadBundler.h
|index fe263f0540b9..fc96f200414d 100644
|--- a/clang/include/clang/Driver/OffloadBundler.h
|+++ b/clang/include/clang/Driver/OffloadBundler.h
--------------------------
File to patch: 
Skip this patch? [y] 
Skipping patch.
3 out of 3 hunks ignored
can't find file to patch at input line 153
Perhaps you used the wrong -p or --strip option?

It looks like due to

  sourceRoot = "${finalAttrs.src.name}/${targetDir}";

I am in the derivation-specific subdirectory and I need to get out of that, for the duration of the patch phase, but if I try that I get permission errors:

@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/p4a8g4qva95m58g4j1ppx5afqhjgd8xw-source
source root is source/llvm
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
applying patch /nix/store/gza2ccdykx35bmaqmf3z25cx5g6wfk2g-add-compression-to-clang-offload-bundler.patch
File clang/docs/ClangOffloadBundler.rst is read-only; trying to patch anyway
patch: **** Can't create temporary file clang/docs/ClangOffloadBundler.rst.ouZXLnJ : Permission denied

You can find my code at

and to build this I run

nix build .#rocmPackages.composable_kernel

I would appreciate any hints about what is going wrong here.

Thanks, I just could not believe the source is actually missing the write permission.