summaryrefslogtreecommitdiff
path: root/overlays/v4l2loopback.nix
blob: 335f86a3a5a5edbfb40db64bd45f1cbd682cb177 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
      '';
    };
  });
}