Need help with creating module compiling zfs kernel module against custom kernel


Basically what the title says; I would appreciate any help in creating my own module which compiles the ZFS kernel module for the linux-surface kernel module by jakeday and qzed. I unfortunately have almost no idea where to begin, except for this reddit thread, which provides a way to override a nixpkg with a custom version.

Thank you kindly for the help!

I’m assuming using the following in the configuration file won’t work, due to both the kernelPackages not including the nixos-surface value and the zfs value not having the correct build implementation in pkgs, correct?

{ config, ... }:
  imports = [ ./hardware-configuration ./nixos-surface/surface.nix ];
  boot.kernelPackages = [ surface ];
  boot.extraModulePackages = with config.boot.kernelPackages; [ zfs ];