Using a custom kernel for a Surface device

Hey there - new to using NixOS but thus far been getting on well but I’m now approaching a problem I’ve anticipated but not been able to work out how best to solve before getting started. I’m using a Surface Book 2, that poses some difficulties in getting the hardware all working. Luckily, there’s some excellent patches, firmware and configuration files being worked on.

Being new to Nix, I’m not sure how best to approach getting this working on my system. I’ve read that I can specify the specific kernel version (so that the correct patches can be applied) and that I can specify overrides with patches - so would the best approach for applying patches be to add the surface repository as a submodule of my configuration and specify the path of the patches from that? I’ve also had a look at the firmware-linux-nonfree package and reckon that I could create a package that does similar but from the surface repository. The other files from the repository can be specified manually with various options.

However, I’ve no idea if this is a good approach - I’m not super keen on having it included as a submodule and as part of a package, that would seem to require I keep those in sync. Further, manually specifying options for configuration makes it harder to keep the configuration in sync with the upstream repository (though, I expect I’ll have to bite the bullet on this one).

What is the recommended approach for handling a situation like this? Thanks.

You should write a custom kernel in an overlay.

This PR explains a bit how to configure a custom kernel:

You can also look for the function linuxManualConfig.

I just started re-checking the google results for “nixos surface”.
There’s been some work done on getting this working, see the nixos mention at , and come join us at freenode/##linux-surface.

1 Like