From 52ad5515a037c76a4e77b4fb53e2511ec7c09c13 Mon Sep 17 00:00:00 2001
From: Anderson Torres <torres.anderson.85@protonmail.com>
Date: Fri, 19 Jan 2024 10:24:24 -0300
Subject: [PATCH] live555: 2023.06.14 -> 2023.06.16

- Patch to accept CFLAGS in Darwin platforms
- Set C++ standard to c++20
---
 pkgs/by-name/li/live555/package.nix | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/pkgs/by-name/li/live555/package.nix b/pkgs/by-name/li/live555/package.nix
index 3cbbd1566d70..884c7d88064e 100644
--- a/pkgs/by-name/li/live555/package.nix
+++ b/pkgs/by-name/li/live555/package.nix
@@ -1,6 +1,7 @@
 { lib
 , darwin
 , fetchurl
+, fetchpatch
 , openssl
 , stdenv
 , vlc
@@ -8,7 +9,7 @@
 
 stdenv.mkDerivation (finalAttrs: {
   pname = "live555";
-  version = "2023.06.14";
+  version = "2023.06.16";
 
   src = fetchurl {
     urls = [
@@ -17,9 +18,17 @@ stdenv.mkDerivation (finalAttrs: {
       "https://download.videolan.org/contrib/live555/live.${finalAttrs.version}.tar.gz"
       "mirror://sourceforge/slackbuildsdirectlinks/live.${finalAttrs.version}.tar.gz"
     ];
-    hash = "sha256-PaXSJwz8LwezgXWVga9g2S5kK+YPSRVnrhaH/5UT0mE=";
+    hash = "sha256-DBtKTklgj3AUA2lU0xsF14EmJtSR3iFL24I6nQTE9T8=";
   };
 
+  patches = [
+    (fetchpatch {
+      name = "cflags-when-darwin.patch";
+      url = "https://github.com/rgaufman/live555/commit/16701af5486bb3a2d25a28edaab07789c8a9ce57.patch?full_index=1";
+      hash = "sha256-IDSdByBu/EBLsUTBe538rWsDwH61RJfAEhvT68Nb9rU=";
+    })
+  ];
+
   nativeBuildInputs = lib.optionals stdenv.isDarwin [
     darwin.cctools
   ];
@@ -30,6 +39,10 @@ stdenv.mkDerivation (finalAttrs: {
 
   strictDeps = true;
 
+  # Since NIX_CFLAGS_COMPILE does not differentiate C and C++ toolchains, we
+  # set CXXFLAGS directly
+  env.CXXFLAGS = "-std=c++20";
+
   postPatch = ''
     substituteInPlace config.macosx-catalina \
       --replace '/usr/lib/libssl.46.dylib' "${lib.getLib openssl}/lib/libssl.dylib" \