From b7fa787f585b448bde7dd03f2214fb294bc9674c Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Wed, 19 Mar 2025 00:14:25 -0700 Subject: [PATCH] freebsd.v4l-compat: init This is an adaptation of a script in freebsd-ports which generates freebsd-compatible headers based on linux upstream. --- .../bsd/freebsd/pkgs/v4l-compat.nix | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 pkgs/os-specific/bsd/freebsd/pkgs/v4l-compat.nix diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/v4l-compat.nix b/pkgs/os-specific/bsd/freebsd/pkgs/v4l-compat.nix new file mode 100644 index 000000000000..f0e7bb9e91f5 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/v4l-compat.nix @@ -0,0 +1,60 @@ +{ lib, stdenv, fetchurl }: +let + types_h = fetchurl { + url = "https://raw.githubusercontent.com/freebsd/freebsd-ports/3da53417998c611f340d75e45962da2fa912add5/multimedia/libv4l/files/types.h"; + hash = "sha256-vbw82kxDC02vFhqdK3klh52pk/ecL+HwmmgQYYMEV9w="; + }; + videodev_h = fetchurl { + url = "https://raw.githubusercontent.com/freebsd/freebsd-ports/3da53417998c611f340d75e45962da2fa912add5/multimedia/libv4l/files/videodev.h"; + hash = "sha256-tcSZeBkaRo+K6i/tUYjhgQdEAuMhstvWsyVydIevAU4="; + }; +in +stdenv.mkDerivation rec { + pname = "v4l-compat"; + version = "5.8"; + + src = fetchurl { + url = "mirror://kernel/linux/kernel/v${lib.versions.major version}.x/linux-${version}.tar.xz"; + hash = "sha256-5/dRhqoGQhFK+PGdmVWZNzAMonrK90UbNtT5sPhc8fU="; + }; + allFiles = [ + "linux/cec.h" + "linux/cec-funcs.h" + "linux/const.h" + "linux/dvb/audio.h" + "linux/dvb/ca.h" + "linux/dvb/dmx.h" + "linux/dvb/frontend.h" + "linux/dvb/net.h" + "linux/dvb/osd.h" + "linux/dvb/version.h" + "linux/dvb/video.h" + "linux/ivtv.h" + "linux/lirc.h" + "linux/media.h" + "linux/media-bus-format.h" + "linux/v4l2-common.h" + "linux/v4l2-controls.h" + "linux/v4l2-mediabus.h" + "linux/v4l2-subdev.h" + "linux/videodev2.h" + ]; + + buildPhase = ":"; + + installPhase = '' + for f in $allFiles; do + mkdir -p $(dirname $out/include/$f) + cp include/uapi/$f $out/include/$f + done + cp ${types_h} $out/include/linux/types.h + cp ${videodev_h} $out/include/linux/videodev.h + ''; + + meta = { + description = "Video4Linux header files for FreeBSD"; + maintainers = [ lib.maintainers.rhelmot ]; + platforms = lib.platforms.freebsd; + license = lib.licenses.gpl2Only; + }; +}