1{ lib, stdenv, fetchFromGitHub, fetchpatch, kernel, kmod, looking-glass-client }:
2
3stdenv.mkDerivation rec {
4 pname = "kvmfr";
5 version = looking-glass-client.version;
6
7 src = looking-glass-client.src;
8 sourceRoot = "source/module";
9 hardeningDisable = [ "pic" "format" ];
10 nativeBuildInputs = kernel.moduleBuildDependencies;
11
12 patches = lib.optional (kernel.kernelAtLeast "5.16") (fetchpatch {
13 name = "kvmfr-5.16.patch";
14 url = "https://github.com/gnif/LookingGlass/commit/a9b5302a517e19d7a2da114acf71ef1e69cfb497.patch";
15 sha256 = "017nxlk2f7kyjp6llwa74dbczdb1jk8v791qld81dxhzkm9dyqqx";
16 stripLen = 1;
17 })
18 ++ lib.optional (kernel.kernelAtLeast "5.18") (fetchpatch {
19 name = "kvmfr-5.18.patch";
20 url = "https://github.com/gnif/LookingGlass/commit/c7029f95042fe902843cb6acbfc75889e93dc210.patch";
21 sha256 = "sha256-6DpL17XWj8BKpiBdKdCPC51MWKLIo6PixQ9UaygT2Zg=";
22 stripLen = 1;
23 });
24
25 makeFlags = [
26 "KVER=${kernel.modDirVersion}"
27 "KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
28 ];
29
30 installPhase = ''
31 install -D kvmfr.ko -t "$out/lib/modules/${kernel.modDirVersion}/kernel/drivers/misc/"
32 '';
33
34 meta = with lib; {
35 description = "Optional kernel module for LookingGlass";
36 longDescription = ''
37 This kernel module implements a basic interface to the IVSHMEM device for LookingGlass when using LookingGlass in VM->VM mode
38 Additionally, in VM->host mode, it can be used to generate a shared memory device on the host machine that supports dmabuf
39 '';
40 homepage = "https://github.com/gnif/LookingGlass";
41 license = licenses.gpl2Plus;
42 maintainers = with maintainers; [ j-brn ];
43 platforms = [ "x86_64-linux" ];
44 broken = kernel.kernelOlder "5.3";
45 };
46}