Commit d94b20d8 authored by Anderson Torres's avatar Anderson Torres
Browse files

vlc: refactor

- Remove xorg indirection
- Reorder lists
- Use new rec-less overlay style overridable recursive attributes (operative
  since https://github.com/NixOS/nixpkgs/pull/119942)
- Put env vars under `env`
- Remove `null`ities
- Remove `with lib;` (following rationale from
  https://nix.dev/recipes/best-practices#with-scopes)
parent e46ab54b
Loading
Loading
Loading
Loading
+63 −44
Original line number Diff line number Diff line
@@ -14,8 +14,15 @@
, flac
, fluidsynth
, freefont_ttf
, freetype
, fribidi
, gnutls
, libSM
, libXext
, libXinerama
, libXpm
, libXv
, libXvMC
, libarchive
, libass
, libbluray
@@ -31,6 +38,7 @@
, libkate
, libmad
, libmatroska
, libmicrodns
, libmodplug
, libmtp
, liboggz
@@ -56,6 +64,11 @@
, ncurses
, perl
, pkg-config
, protobuf
, qtbase
, qtsvg
, qtwayland
, qtx11extras
, removeReferencesTo
, samba
, schroedinger
@@ -64,14 +77,20 @@
, systemd
, taglib
, unzip
, xorg
, wayland
, wayland-protocols
, wrapGAppsHook
, wrapQtAppsHook
, xcbutilkeysyms
, zlib
, chromecastSupport ? true, libmicrodns, protobuf

, chromecastSupport ? true
, jackSupport ? false
, onlyLibVLC ? false
, skins2Support ? !onlyLibVLC, freetype
, waylandSupport ? true, wayland, wayland-protocols
, withQt5 ? true, qtbase, qtsvg, qtwayland, qtx11extras, wrapQtAppsHook, wrapGAppsHook
, skins2Support ? !onlyLibVLC
, waylandSupport ? true
, withQt5 ? true
, withLibcaca ? true
}:

# chromecastSupport requires TCP port 8010 to be open for it to work.
@@ -81,15 +100,29 @@
let
  inherit (lib) optionalString optional optionals;
in
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "${optionalString onlyLibVLC "lib"}vlc";
  version = "3.0.18";

  src = fetchurl {
    url = "http://get.videolan.org/vlc/${version}/vlc-${version}.tar.xz";
    sha256 = "sha256-VwlEOcNl2KqLm0H6MIDMDu8r7+YCW7XO9yKszGJa7ew=";
    url = "http://get.videolan.org/vlc/${finalAttrs.version}/vlc-${finalAttrs.version}.tar.xz";
    hash = "sha256-VwlEOcNl2KqLm0H6MIDMDu8r7+YCW7XO9yKszGJa7ew=";
  };

  nativeBuildInputs = [
    autoreconfHook
    perl
    pkg-config
    removeReferencesTo
    unzip
    wrapGAppsHook
  ]
  ++ optionals withQt5 [ wrapQtAppsHook ]
  ++ optionals waylandSupport [
    wayland
    wayland-protocols
  ];

  # VLC uses a *ton* of libraries for various pieces of functionality, many of
  # which are not included here for no other reason that nobody has mentioned
  # needing them
@@ -106,10 +139,13 @@ stdenv.mkDerivation rec {
    fluidsynth
    fribidi
    gnutls
    libSM
    libXpm
    libXv
    libXvMC
    libarchive
    libass
    libbluray
    libcaca
    libcddb
    libdc1394
    libdvbpsi
@@ -121,8 +157,8 @@ stdenv.mkDerivation rec {
    libkate
    libmad
    libmatroska
    libmtp
    libmodplug
    libmtp
    liboggz
    libopus
    libplacebo
@@ -149,46 +185,29 @@ stdenv.mkDerivation rec {
    srt
    systemd
    taglib
    xcbutilkeysyms
    zlib
  ]
  ++ (with xorg; [
    libSM
    libXpm
    libXv
    libXvMC
    xcbutilkeysyms
  ])
  ++ optional withLibcaca libcaca
  ++ optional (!stdenv.hostPlatform.isAarch && !onlyLibVLC) live555
  ++ optional jackSupport libjack2
  ++ optionals chromecastSupport [ libmicrodns protobuf ]
  ++ optionals skins2Support (with xorg; [
  ++ optionals skins2Support [
    freetype
    libXext
    libXinerama
    libXpm
  ])
  ]
  ++ optionals waylandSupport [ wayland wayland-protocols ]
  ++ optionals withQt5 [ qtbase qtsvg qtx11extras ]
  ++ optional (waylandSupport && withQt5) qtwayland;

  nativeBuildInputs = [
    autoreconfHook
    perl
    pkg-config
    removeReferencesTo
    unzip
    wrapGAppsHook
  ]
  ++ optionals withQt5 [ wrapQtAppsHook ]
  ++ optionals waylandSupport [ wayland wayland-protocols ];

  enableParallelBuilding = true;

  env = {
    LIVE555_PREFIX = if stdenv.hostPlatform.isAarch then null else live555;

    # vlc depends on a c11-gcc wrapper script which we don't have so we need to
    # set the path to the compiler
    BUILDCC = "${stdenv.cc}/bin/gcc";
  };

  patches = [
    # patch to build with recent live555
@@ -210,9 +229,9 @@ stdenv.mkDerivation rec {
      /usr/share/fonts/truetype/freefont ${freefont_ttf}/share/fonts/truetype
  '';

  enableParallelBuilding = true;

  # to prevent double wrapping of Qtwrap and Gwrap
  dontWrapGApps = true;
  dontWrapGApps = true; # to prevent double wrapping of Qtwrap and Gwrap

  preFixup = ''
    qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
@@ -259,11 +278,11 @@ stdenv.mkDerivation rec {
    cp -R share/hrtfs $out/share/vlc
  '';

  meta = with lib; {
  meta = {
    description = "Cross-platform media player and streaming server";
    homepage = "http://www.videolan.org/vlc/";
    license = licenses.lgpl21Plus;
    maintainers = with maintainers; [ AndersonTorres ];
    platforms = platforms.linux;
    license = lib.licenses.lgpl21Plus;
    maintainers = with lib.maintainers; [ AndersonTorres ];
    platforms = lib.platforms.linux;
  };
}
})
+1 −5
Original line number Diff line number Diff line
@@ -35596,15 +35596,11 @@ with pkgs;
    # Newest libcaca changed the API, and libvlc didn't catch it. Until next
    # version arrives, it is safer to disable it.
    # Upstream thread: https://code.videolan.org/videolan/vlc/-/issues/26389
    libcaca = null;
    withLibcaca = false;
  };
  libvlc = vlc.override {
    withQt5 = false;
    qtbase = null;
    qtsvg = null;
    qtx11extras = null;
    wrapQtAppsHook = null;
    onlyLibVLC = true;
  };