nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 67 lines 2.4 kB view raw
1{ 2 stdenv, 3 lib, 4 blackmagic-desktop-video, 5 kernel, 6 fetchpatch, 7}: 8stdenv.mkDerivation (finalAttrs: { 9 pname = "decklink"; 10 11 # the download is a horrible curl mess. we reuse it between the kernel module 12 # and desktop service, since the version of the two have to match anyways. 13 # See pkgs/by-name/bl/blackmagic-desktop-video/package.nix for more. 14 inherit (blackmagic-desktop-video) src version; 15 16 patches = 17 (lib.optionals (lib.versionAtLeast kernel.modDirVersion "6.13") [ 18 # needed for version 14.4.x to build for kernel 6.13 19 (fetchpatch { 20 name = "01-update-makefiles"; 21 url = "https://aur.archlinux.org/cgit/aur.git/plain/01-update-makefiles.patch?h=decklink"; 22 hash = "sha256-l3iu0fG/QJMdGI/WSlNn+qjF4nK25JxoiwhPrMGTqE4="; 23 }) 24 ]) 25 ++ (lib.optionals (lib.versionAtLeast kernel.modDirVersion "6.15") [ 26 # needed for version 14.4.x to build for kernel 6.15 27 ./02-rename-timer-delete.patch 28 ]); 29 30 KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"; 31 INSTALL_MOD_PATH = placeholder "out"; 32 33 nativeBuildInputs = kernel.moduleBuildDependencies; 34 35 postUnpack = 36 let 37 arch = stdenv.hostPlatform.uname.processor; 38 in 39 '' 40 tar xf Blackmagic_Desktop_Video_Linux_${lib.head (lib.splitString "a" finalAttrs.version)}/other/${arch}/desktopvideo-${finalAttrs.version}-${arch}.tar.gz 41 moduleRoot=$NIX_BUILD_TOP/desktopvideo-${finalAttrs.version}-${stdenv.hostPlatform.uname.processor}/usr/src 42 sourceRoot=$moduleRoot 43 ''; 44 45 buildPhase = '' 46 runHook preBuild 47 make -C $moduleRoot/blackmagic-${finalAttrs.version} -j$NIX_BUILD_CORES 48 make -C $moduleRoot/blackmagic-io-${finalAttrs.version} -j$NIX_BUILD_CORES 49 runHook postBuild 50 ''; 51 52 installPhase = '' 53 runHook preInstall 54 make -C $KERNELDIR M=$moduleRoot/blackmagic-${finalAttrs.version} modules_install 55 make -C $KERNELDIR M=$moduleRoot/blackmagic-io-${finalAttrs.version} modules_install 56 runHook postInstall 57 ''; 58 59 meta = with lib; { 60 homepage = "https://www.blackmagicdesign.com/support/family/capture-and-playback"; 61 maintainers = [ maintainers.naxdy ]; 62 license = licenses.unfree; 63 description = "Kernel module for the Blackmagic Design Decklink cards"; 64 sourceProvenance = with lib.sourceTypes; [ binaryFirmware ]; 65 platforms = platforms.linux; 66 }; 67})