1{
2 stdenv,
3 lib,
4 blackmagic-desktop-video,
5 kernel,
6}:
7stdenv.mkDerivation (finalAttrs: {
8 pname = "decklink";
9
10 # the download is a horrible curl mess. we reuse it between the kernel module
11 # and desktop service, since the version of the two have to match anyways.
12 # See pkgs/by-name/bl/blackmagic-desktop-video/package.nix for more.
13 inherit (blackmagic-desktop-video) src version;
14
15 KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build";
16 INSTALL_MOD_PATH = placeholder "out";
17
18 nativeBuildInputs = kernel.moduleBuildDependencies;
19
20 postUnpack =
21 let
22 arch = stdenv.hostPlatform.uname.processor;
23 in
24 ''
25 tar xf Blackmagic_Desktop_Video_Linux_${finalAttrs.version}/other/${arch}/desktopvideo-${finalAttrs.version}*-${arch}.tar.gz
26 bmVersion=$(ls -d $NIX_BUILD_TOP/desktopvideo-${finalAttrs.version}*-${arch}/usr/src | sed -e 's/.*desktopvideo-\([[:digit:]\.a-z]\+\).*/\1/')
27
28 moduleRoot=$NIX_BUILD_TOP/desktopvideo-$bmVersion-${arch}/usr/src
29 sourceRoot=$moduleRoot
30 '';
31
32 buildPhase = ''
33 runHook preBuild
34 make -C $moduleRoot/blackmagic-$bmVersion -j$NIX_BUILD_CORES
35 make -C $moduleRoot/blackmagic-io-$bmVersion -j$NIX_BUILD_CORES
36 runHook postBuild
37 '';
38
39 installPhase = ''
40 runHook preInstall
41 make -C $KERNELDIR M=$moduleRoot/blackmagic-$bmVersion modules_install
42 make -C $KERNELDIR M=$moduleRoot/blackmagic-io-$bmVersion modules_install
43 runHook postInstall
44 '';
45
46 meta = with lib; {
47 homepage = "https://www.blackmagicdesign.com/support/family/capture-and-playback";
48 maintainers = [ maintainers.naxdy ];
49 license = licenses.unfree;
50 description = "Kernel module for the Blackmagic Design Decklink cards";
51 sourceProvenance = with lib.sourceTypes; [ binaryFirmware ];
52 platforms = platforms.linux;
53 };
54})