From 4c9a200c83a0da79d43331e74b46d0a505d3526b Mon Sep 17 00:00:00 2001 From: hexchen Date: Wed, 27 Jan 2021 05:24:12 +0000 Subject: [PATCH] sources: switch to upstream this involves moving the blackmagic package and module from hexchen's nixpkgs fork into this repo directly. --- modules/decklink.nix | 21 ++++++++ modules/default.nix | 1 + nix/sources.json | 20 +++---- pkgs/blackmagic-desktop-video/default.nix | 49 +++++++++++++++++ pkgs/decklink/default.nix | 66 +++++++++++++++++++++++ pkgs/default.nix | 27 ++++++++-- 6 files changed, 171 insertions(+), 13 deletions(-) create mode 100644 modules/decklink.nix create mode 100644 pkgs/blackmagic-desktop-video/default.nix create mode 100644 pkgs/decklink/default.nix diff --git a/modules/decklink.nix b/modules/decklink.nix new file mode 100644 index 0000000..d8d30c1 --- /dev/null +++ b/modules/decklink.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.hardware.decklink; + kernelPackages = config.boot.kernelPackages; +in +{ + options.hardware.decklink.enable = mkEnableOption "Enable hardware support for the Blackmagic Design Decklink audio/video interfaces."; + + config = mkIf cfg.enable { + boot.kernelModules = [ "blackmagic" "blackmagic-io" "snd_blackmagic-io" ]; + boot.extraModulePackages = [ kernelPackages.decklink ]; + systemd.services."DecklinkVideoHelper" = { + after = [ "syslog.target" "local-fs.target" ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig.ExecStart = "${pkgs.blackmagicDesktopVideo}/bin/DesktopVideoHelper -n"; + }; + }; +} diff --git a/modules/default.nix b/modules/default.nix index 22801f9..0051231 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -5,5 +5,6 @@ in { imports = [ "${sources.immae-nix}/modules/webapps/peertube.nix" ./nftnat + ./decklink.nix ]; } diff --git a/nix/sources.json b/nix/sources.json index 9f797e9..c55131e 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -45,27 +45,27 @@ "url_template": "/-/archive/.tar.gz" }, "nixpkgs": { - "branch": "hexchen-20.09", + "branch": "nixos-20.09", "description": "Nix Packages collection", "homepage": "", - "owner": "hexchen", + "owner": "nixos", "repo": "nixpkgs", - "rev": "4b1f1b356d874eae749f7e0d2d9ce9afbe977a88", - "sha256": "0dbhzb1kccsp6qwds93d7kchypj0b0spzkf8jah1lg4vjvxxi2v8", + "rev": "e4adbfbab8aadf9d80a93d40fb612cb910073af9", + "sha256": "0fs32adk4x5xg9m00nykhxhka927wrnwkjx59as673swh46hdvck", "type": "tarball", - "url": "https://github.com/hexchen/nixpkgs/archive/4b1f1b356d874eae749f7e0d2d9ce9afbe977a88.tar.gz", + "url": "https://github.com/nixos/nixpkgs/archive/e4adbfbab8aadf9d80a93d40fb612cb910073af9.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "nixpkgs-unstable": { - "branch": "hexchen-main", + "branch": "nixos-unstable", "description": "Nix Packages collection", "homepage": "", - "owner": "hexchen", + "owner": "nixos", "repo": "nixpkgs", - "rev": "9091f350c69d744aad6d9ab5994446bec9a51567", - "sha256": "1s8cw7wvnl0liv5rcs882h74lmqh72f01yrdg1h6kg51iwl7swws", + "rev": "891f607d5301d6730cb1f9dcf3618bcb1ab7f10e", + "sha256": "1cr39f0sbr0h5d83dv1q34mcpwnkwwbdk5fqlyqp2mnxghzwssng", "type": "tarball", - "url": "https://github.com/hexchen/nixpkgs/archive/9091f350c69d744aad6d9ab5994446bec9a51567.tar.gz", + "url": "https://github.com/nixos/nixpkgs/archive/891f607d5301d6730cb1f9dcf3618bcb1ab7f10e.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "pbb-nixfiles": { diff --git a/pkgs/blackmagic-desktop-video/default.nix b/pkgs/blackmagic-desktop-video/default.nix new file mode 100644 index 0000000..84a5dc3 --- /dev/null +++ b/pkgs/blackmagic-desktop-video/default.nix @@ -0,0 +1,49 @@ +{ stdenv, requireFile, lib, + libcxx, libcxxabi +}: + +stdenv.mkDerivation rec { + pname = "blackmagic-desktop-video"; + version = "11.6"; + + buildInputs = [ + libcxx libcxxabi + ]; + + src = requireFile { + name = "Blackmagic_Desktop_Video_Linux_11.6.tar.gz"; + url = "https://www.blackmagicdesign.com/support/download/d399ada95c2b49ffad3031bda413acb5/Linux"; + sha256 = "0qwm1b3gy0k7j1bimkxwwr77g8hrsybs9jp90b46kzcy06mcp380"; + }; + + setSourceRoot = '' + tar xf Blackmagic_Desktop_Video_Linux_11.6/other/x86_64/desktopvideo-11.6a26-x86_64.tar.gz + sourceRoot=$NIX_BUILD_TOP/desktopvideo-11.6a26-x86_64 + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{bin,share/doc,lib} + cp -r $sourceRoot/usr/share/doc/desktopvideo $out/share/doc + cp $sourceRoot/usr/lib/*.so $out/lib + ln -s ${libcxx}/lib/* ${libcxxabi}/lib/* $out/lib + cp $sourceRoot/usr/lib/blackmagic/DesktopVideo/libgcc_s.so.1 $out/lib/ + cp $sourceRoot/usr/lib/blackmagic/DesktopVideo/DesktopVideoHelper $out/bin/ + runHook postInstall + ''; + + postFixup = '' + patchelf --set-interpreter ${stdenv.cc.bintools.dynamicLinker} \ + --set-rpath "$out/lib:${lib.makeLibraryPath [ libcxx libcxxabi ]}" \ + $out/bin/DesktopVideoHelper + ''; + + meta = with stdenv.lib; { + homepage = "https://www.blackmagicdesign.com/support/family/capture-and-playback"; + maintainers = [ maintainers.hexchen ]; + license = licenses.unfree; + description = "Supporting applications for Blackmagic Decklink. Doesn't include the desktop applications, only the helper required to make the driver work."; + platforms = platforms.linux; + }; +} diff --git a/pkgs/decklink/default.nix b/pkgs/decklink/default.nix new file mode 100644 index 0000000..38988c7 --- /dev/null +++ b/pkgs/decklink/default.nix @@ -0,0 +1,66 @@ +{ stdenv, requireFile, fetchpatch, kernel }: + +stdenv.mkDerivation rec { + pname = "decklink"; + version = "11.6"; + + src = requireFile { + name = "Blackmagic_Desktop_Video_Linux_11.6.tar.gz"; + url = "https://www.blackmagicdesign.com/support/download/d399ada95c2b49ffad3031bda413acb5/Linux"; + sha256 = "0qwm1b3gy0k7j1bimkxwwr77g8hrsybs9jp90b46kzcy06mcp380"; + }; + + patches = [ + (fetchpatch { + name = "01-fix-makefile.patch"; + url = "https://aur.archlinux.org/cgit/aur.git/plain/01-fix-makefile.patch?h=decklink&id=8f19ef584c0603105415160d2ba4e8dfa47495ce"; + sha256 = "1pk8zfi0clmysla25jmcqnq7sx2bnjflrarhqkqbkl8crigyspf5"; + }) + (fetchpatch { + name = "02-fix-get_user_pages-and-mmap_lock.patch"; + url = "https://aur.archlinux.org/cgit/aur.git/plain/02-fix-get_user_pages-and-mmap_lock.patch?h=decklink&id=8f19ef584c0603105415160d2ba4e8dfa47495ce"; + sha256 = "08m4qwrk0vg8rix59y591bjih95d2wp6bmm1p37nyfvhi2n9jw2m"; + }) + (fetchpatch { + name = "03-fix-have_unlocked_ioctl.patch"; + url = "https://aur.archlinux.org/cgit/aur.git/plain/03-fix-have_unlocked_ioctl.patch?h=decklink&id=8f19ef584c0603105415160d2ba4e8dfa47495ce"; + sha256 = "0j9p62qa4mc6ir2v4fzrdapdrvi1dabrjrx1c295pwa3vmsi1x4f"; + }) + ]; + + KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"; + INSTALL_MOD_PATH = placeholder "out"; + + nativeBuildInputs = kernel.moduleBuildDependencies; + + setSourceRoot = '' + tar xf Blackmagic_Desktop_Video_Linux_11.6/other/x86_64/desktopvideo-11.6a26-x86_64.tar.gz + sourceRoot=$NIX_BUILD_TOP/desktopvideo-11.6a26-x86_64/usr/src + ''; + + buildPhase = '' + runHook preBuild + + make -C $sourceRoot/blackmagic-11.6a26 -j$NIX_BUILD_CORES + make -C $sourceRoot/blackmagic-io-11.6a26 -j$NIX_BUILD_CORES + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + make -C $KERNELDIR M=$sourceRoot/blackmagic-11.6a26 modules_install + make -C $KERNELDIR M=$sourceRoot/blackmagic-io-11.6a26 modules_install + + runHook postInstall + ''; + + meta = with stdenv.lib; { + homepage = "https://www.blackmagicdesign.com/support/family/capture-and-playback"; + maintainers = [ maintainers.hexchen ]; + license = licenses.unfree; + description = "Kernel module for the Blackmagic Design Decklink cards"; + platforms = platforms.linux; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 286a3b4..05e9f5c 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -10,8 +10,29 @@ let peertube = callPackage ./peertube { mylibs = import "${sources.immae-nix}/lib" { inherit pkgs; }; }; alps = callPackage ./alps {}; - inherit callPackage; - appendOverlays = overlays: (pkgs.appendOverlays overlays) // newpkgs; + docker = pkgs.docker.overrideAttrs (super: { + extraPath = super.extraPath + ":${pkgs.zfs}/bin"; + }); + + linuxPackagesFor = kernel: (pkgs.linuxPackagesFor kernel).extend (_: ksuper: { + decklink = callPackage ./decklink { kernel = ksuper.kernel; }; + }); + + blackmagicDesktopVideo = callPackage ./blackmagic-desktop-video { }; + + obs-studio = pkgs.obs-studio.overrideAttrs (_: rec { + wrapLibraries = with (pkgs // newpkgs); [ + xorg.libX11.out + libvlc + blackmagicDesktopVideo + libcxx + libcxxabi + ]; + postInstall = '' + wrapProgram $out/bin/obs \ + --prefix "LD_LIBRARY_PATH" : "${pkgs.lib.makeLibraryPath wrapLibraries}" + ''; + }); }; -in pkgs // newpkgs +in pkgs.extend(_: _: newpkgs)