Skip to content

Instantly share code, notes, and snippets.

@FliegendeWurst
Forked from gtgteq/droidcam.nix
Last active February 25, 2021 09:38
Show Gist options
  • Save FliegendeWurst/6d696644d5517593ef9cb4f06e715ffb to your computer and use it in GitHub Desktop.
Save FliegendeWurst/6d696644d5517593ef9cb4f06e715ffb 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/03d6de8d5628663c75a6e266c4ae6a26a2bbe682.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/03d6de8d5628663c75a6e266c4ae6a26a2bbe682.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_5_4;
    };
    droidcam = pkgs.callPackage ./droidcam.nix {};
in {
  boot.kernelPackages = pkgs.linuxPackages_5_4;
  boot.extraModulePackages = [ v4l2loopback-dc ];
  environment.systemPackages = [ droidcam ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment