summaryrefslogtreecommitdiff
path: root/overlays/v4l2loopback.nix
blob: bb59961f1ebd21321147c8632fad1a5d54adcc6e (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
{ final, prev, sources, ... }: {
  linuxPackages_latest = prev.linuxPackages_latest.extend (self: super: {
    v4l2loopback = super.stdenv.mkDerivation rec {
      name = "v4l2loopback-${version}-${self.kernel.version}";
      inherit (sources.v4l2loopback) version src;

      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
      '';
    };
  });
}