The title is the question I guess: How to build any arbitrary kernel from a local git repo of the kernel source tree? I need to find a bug and git bisect through it. And I am contemplating whether I can do this reasonably well on NixOS or I need go grab something else for this…
That looks a bit more what I was looking for. How do you integrate that into your system config so you can build the kernel from a local git repo and boot it?
Assuming you want to bisect Kernel 6.1, you can simply check out nixpkgs, edit pkgs/os-specific/linux/kernel/linux-6.1.nix to point src to your checkout of the Kernel git and then build from your local nixpkgs checkout. That way you can bisect in your local kernel checkout and rebuild with the settings NixOS uses.
That is actually a really good idea, I will give it a try and see how it goes. It should also work if I just override the attribute set of my kernel 6.1 to pick up the local git repo, right? I will try using fetchgit and point it to my local path with url being set to something like url = "file:///path/to/linux/source/";
error: builder for '/nix/store/w96g4jncqalh1ihyxqrhnzxhgkk7qkbx-linux-config-5.16.10.drv' failed with exit code 1;
last 3 log lines:
> unpacking sources
> unpacking source archive file:///home/ap/Coding/c/linux-stable
> do not know how to unpack source archive file:///home/ap/Coding/c/linux-stable
For full logs, run 'nix log /nix/store/w96g4jncqalh1ihyxqrhnzxhgkk7qkbx-linux-config-5.16.10.drv'.
error: 1 dependencies of derivation '/nix/store/b277d2qzk2kcmc524dyav54y7lxbwbp1-linux-5.16.10.drv' failed to build
error: 1 dependencies of derivation '/nix/store/3ylrjx5y5lsfb88iwb8fhhrgrkljyvsm-nixos-system-archon-22.11.20230122.ab12540.drv' failed to build
Which is kinda what I was expecting, namely that it doesn’t want to take the git repository directly but is looking for an archive instead. Which of course does not exist. So yeah…
But now the build itself fails. Which is another problem entirely and I will open a new thread for this one I guess. But getting the right sources works now. Even though fetchgit did not want to fetch my local source tree for whatever reason…