Skip to content

Instantly share code, notes, and snippets.

@gtgteq
Created April 3, 2020 08:03
Show Gist options
  • Save gtgteq/a3bae1c09c95196f6e2a767d08f62ad8 to your computer and use it in GitHub Desktop.
Save gtgteq/a3bae1c09c95196f6e2a767d08f62ad8 to your computer and use it in GitHub Desktop.
droidcam.nix
{ stdenv, fetchzip, pkgconfig, ffmpeg, gtk2-x11, libjpeg }:
stdenv.mkDerivation rec {
pname = "droidcam";
version = "0";
src = fetchzip {
url = "https://github.com/aramg/droidcam/archive/b49842a02611f8ddc6b9342ef74e299abd1c4090.zip";
sha256 = "05kd5ihwb3fldmalv67jgpw4x0z0q39lfis69r7yh03qiqlviymk";
};
sourceRoot = "source/linux";
buildInputs = [ pkgconfig ];
nativeBuildInputs = [ ffmpeg gtk2-x11 libjpeg ];
postPatch = ''
sed -i -e 's:/opt/libjpeg-turbo/include:${libjpeg.out}/include:' Makefile
sed -i -e 's:/opt/libjpeg-turbo/lib`getconf LONG_BIT`/libturbojpeg.a:${libjpeg.out}/lib/libturbojpeg.so:' Makefile
'';
installPhase = ''
mkdir -p $out/bin
cp droidcam droidcam-cli $out/bin/
'';
meta = with stdenv.lib; {
description = "DroidCam Linux client";
homepage = https://github.com/aramg/droidcam;
};
}
{ stdenv, fetchzip, kernel }:
stdenv.mkDerivation rec {
pname = "v4l2loopback-dc";
version = "0";
src = fetchzip {
url = "https://github.com/aramg/droidcam/archive/b49842a02611f8ddc6b9342ef74e299abd1c4090.zip";
sha256 = "05kd5ihwb3fldmalv67jgpw4x0z0q39lfis69r7yh03qiqlviymk";
};
sourceRoot = "source/linux/v4l2loopback";
KVER = "${kernel.modDirVersion}";
KBUILD_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
nativeBuildInputs = kernel.moduleBuildDependencies;
postPatch = ''
sed -i -e 's:/lib/modules/`uname -r`/build:${KBUILD_DIR}:g' Makefile
'';
installPhase = ''
mkdir -p $out/lib/modules/${KVER}/kernels/media/video
cp v4l2loopback-dc.ko $out/lib/modules/${KVER}/kernels/media/video/
'';
meta = with stdenv.lib; {
description = "DroidCam kernel module v4l2loopback-dc";
homepage = https://github.com/aramg/droidcam;
};
}

configuration.nix:

let v4l2loopback-dc = pkgs.callPackage ./v4l2loopback-dc.nix {
      kernel = pkgs.linux_4_19;
    };
    droidcam = pkgs.callPackage ./droidcam.nix {};
in {
  boot.kernelPackages = pkgs.linuxPackages_4_19;
  boot.extraModulePackages = [ v4l2loopback-dc ];
  environment.systemPackages = [ droidcam ];
}
@gtgteq
Copy link
Author

gtgteq commented Nov 27, 2020

README.md is all. Paste your configuration.nix.

@peterwilli
Copy link

peterwilli commented Apr 13, 2021

I updated this driver to the Linux kernel 5.4 and added support for Droidcam 1.7.2 in case you'd like the latest version (at this time of writing).
Thanks for your's, it saved me a lot of time!

https://gist.github.com/peterwilli/b61da8e2ddafe010f7178553135dc3d3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment