final: prev: {
  linuxPackages_latest = prev.linuxPackages_latest.extend (self: super: {
    v4l2loopback = super.stdenv.mkDerivation rec {
      name = "v4l2loopback-${version}-${self.kernel.version}";
      version = "f62fb9076b6313e5eb82fdcaceadb6b3052f346e";

      src = prev.fetchFromGitHub {
        owner = "umlaeute";
        repo = "v4l2loopback";
        rev = "${version}";
        sha256 = "VRFtimQQtT8vd1dx5KtUDkmXo3DSOybhNLcAIxQba44=";
        fetchSubmodules = true;
      };

      hardeningDisable = [ "format" "pic" ];

      preBuild = ''
        substituteInPlace Makefile --replace "modules_install" "INSTALL_MOD_PATH=$out modules_install"
        sed -i '/depmod/d' Makefile
        export PATH=${final.kmod}/sbin:$PATH
      '';

      nativeBuildInputs = self.kernel.moduleBuildDependencies;
      buildInputs = [ final.kmod ];

      makeFlags = [
        "KERNELRELEASE=${self.kernel.modDirVersion}"
        "KERNEL_DIR=${self.kernel.dev}/lib/modules/${self.kernel.modDirVersion}/build"
      ];

      postInstall = ''
        mkdir -p $out/bin
        install -m0755 utils/v4l2loopback-ctl $out/bin
      '';
    };
  });
}