Building arbitrary kernels

Hi, one thing I struggle to set up on nixos is an environment for bisecting
the kernel efficiently, i. e. a local tree (not tarball) with a certain commit
checked out and, crucially, build artifacts from earlier runs still present at
built time (incremental builds). What does one have to do to accomplish
this? It should be possible to emulate arbitrary commits to some extent
by picking a release kernel as the base and slapping gigantic diffs on it,
but that’s all but ergonomic. Building incrementally though, no idea.

Note that I’m not concerned with customizing the kernel by changing
the config or adding individual patches. That is fairly well supported and
documented.

I think there’s been some attempt to “break” the sandbox on some builds to aid with build times, but I’m not super familiar with it.

some links which may help:


https://nixos.org/nix-dev/2014-December/015154.html (this is probably out of date)

2019-11-08 (Friday), nixos1@discoursemail.com (Jon via NixOS Discourse):

I think there’s been some attempt to “break” the sandbox on
some builds to aid with build times, but I’m not super familiar
with it.

some links which may help:
https://github.com/NixOS/nixpkgs/blob/e5e374ebcc0de99736306bc428438ea79e5fe496/nixos/modules/programs/ccache.nix
https://nixos.org/nix-dev/2014-December/015154.html (this is probably out of date)

Yeah, things like ccache and distcc can improve build times but
I’d prefer a conventional in-tree build whose result would then
be picked up by nix-build.

I’ve been thinking about packaging the installed binaries as a
tarball and using that as input for nix, like I do with
proprietary stuff (google earth springs to mind). Though I
haven’t investigated yet how that would fit in with the remainder
of a nixos kernel package.

@layus talked about it at NixCon: https://cfp.nixcon.org/nixcon2019/talk/YJ7NYU/

1 Like

The issue with packaging your local build as a tarball is that you’ll have to rebuild everything that depends on the kernel from scratch still. Stuff like nvidia drivers and ZFS. Not a ton, but at least some.

hi, is this talk recorded? I did not find it on YouTube.

Yes, but not on its own: https://www.youtube.com/watch?v=aUG9aGYYCY8&t=2924s