From fd031c029969f8efdc1b39d37cbafa252f9d9d0b Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 2 Aug 2022 18:39:28 +0200 Subject: [PATCH 1/3] pulseaudio: add darwin support --- ...ch => 0001-Make-gio-2.0-optional-15.patch} | 0 .../0001-Make-gio-2.0-optional-16.patch | 26 +++++++ ... => 0002-Ignore-SCM_CREDS-on-darwin.patch} | 0 .../0003-Disable-z-nodelete-on-darwin.patch | 26 ------- ...gnore-HAVE_CPUID_H-on-aarch64-darwin.patch | 26 +++++++ ...-Prefer-HAVE_CLOCK_GETTIME-on-darwin.patch | 13 ++++ .../0004-Prefer-clock_gettime.patch | 57 -------------- .../0005-Enable-CoreAudio-on-darwin.patch | 31 ++++++++ .../0005-Include-poll-posix.c-on-darwin.patch | 24 ------ ...Fix-libpulsecommon-sources-on-darwin.patch | 18 +++++ ...se-version-script-on-GNU-ish-linkers.patch | 29 ------- ...Adapt-undefined-link-args-per-linker.patch | 44 ----------- .../0007-Fix-link-args-on-darwin.patch | 75 +++++++++++++++++++ ...0008-Use-correct-semaphore-on-darwin.patch | 31 -------- pkgs/servers/pulseaudio/default.nix | 47 +++++++----- pkgs/top-level/all-packages.nix | 2 +- 16 files changed, 219 insertions(+), 230 deletions(-) rename pkgs/servers/pulseaudio/{0001-Make-gio-2.0-optional-when-gsettings-is-disabled.patch => 0001-Make-gio-2.0-optional-15.patch} (100%) create mode 100644 pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-16.patch rename pkgs/servers/pulseaudio/{0002-Ignore-SCM_CREDS-on-macOS.patch => 0002-Ignore-SCM_CREDS-on-darwin.patch} (100%) delete mode 100644 pkgs/servers/pulseaudio/0003-Disable-z-nodelete-on-darwin.patch create mode 100644 pkgs/servers/pulseaudio/0003-Ignore-HAVE_CPUID_H-on-aarch64-darwin.patch create mode 100644 pkgs/servers/pulseaudio/0004-Prefer-HAVE_CLOCK_GETTIME-on-darwin.patch delete mode 100644 pkgs/servers/pulseaudio/0004-Prefer-clock_gettime.patch create mode 100644 pkgs/servers/pulseaudio/0005-Enable-CoreAudio-on-darwin.patch delete mode 100644 pkgs/servers/pulseaudio/0005-Include-poll-posix.c-on-darwin.patch create mode 100644 pkgs/servers/pulseaudio/0006-Fix-libpulsecommon-sources-on-darwin.patch delete mode 100644 pkgs/servers/pulseaudio/0006-Only-use-version-script-on-GNU-ish-linkers.patch delete mode 100644 pkgs/servers/pulseaudio/0007-Adapt-undefined-link-args-per-linker.patch create mode 100644 pkgs/servers/pulseaudio/0007-Fix-link-args-on-darwin.patch delete mode 100644 pkgs/servers/pulseaudio/0008-Use-correct-semaphore-on-darwin.patch diff --git a/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-when-gsettings-is-disabled.patch b/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-15.patch similarity index 100% rename from pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-when-gsettings-is-disabled.patch rename to pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-15.patch diff --git a/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-16.patch b/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-16.patch new file mode 100644 index 000000000000..2a5ae040d9d4 --- /dev/null +++ b/pkgs/servers/pulseaudio/0001-Make-gio-2.0-optional-16.patch @@ -0,0 +1,26 @@ +From 72f3fe059f031f24c5ad026cb2fc16318f227c09 Mon Sep 17 00:00:00 2001 +From: Andrew Childs +Date: Tue, 19 Apr 2022 16:29:58 +0900 +Subject: [PATCH 1/8] Make gio-2.0 optional when gsettings is disabled + +Derived from https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/654 +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index c5135330f..340f58e17 100644 +--- a/meson.build ++++ b/meson.build +@@ -683,7 +683,7 @@ if get_option('daemon') + cdata.set('HAVE_ALSA_UCM', 1) + endif + +- gio_dep = dependency('gio-2.0', version : '>= 2.26.0') ++ gio_dep = dependency('gio-2.0', version : '>= 2.26.0', required : false) + if get_option('gsettings').enabled() + assert(gio_dep.found(), 'GSettings support needs glib I/O library (GIO)') + cdata.set('HAVE_GSETTINGS', 1) +-- +2.35.1 + diff --git a/pkgs/servers/pulseaudio/0002-Ignore-SCM_CREDS-on-macOS.patch b/pkgs/servers/pulseaudio/0002-Ignore-SCM_CREDS-on-darwin.patch similarity index 100% rename from pkgs/servers/pulseaudio/0002-Ignore-SCM_CREDS-on-macOS.patch rename to pkgs/servers/pulseaudio/0002-Ignore-SCM_CREDS-on-darwin.patch diff --git a/pkgs/servers/pulseaudio/0003-Disable-z-nodelete-on-darwin.patch b/pkgs/servers/pulseaudio/0003-Disable-z-nodelete-on-darwin.patch deleted file mode 100644 index 81b3ab927333..000000000000 --- a/pkgs/servers/pulseaudio/0003-Disable-z-nodelete-on-darwin.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 3f1abb55f4eb985fd0715b2b2ca45dcce3a56824 Mon Sep 17 00:00:00 2001 -From: Andrew Childs -Date: Tue, 19 Apr 2022 17:06:50 +0900 -Subject: [PATCH 3/8] Disable `-z nodelete` on darwin - -Not supported[citation needed]. ---- - meson.build | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/meson.build b/meson.build -index f7adf1413..d4bece11a 100644 ---- a/meson.build -+++ b/meson.build -@@ -404,7 +404,7 @@ cdata.set('MESON_BUILD', 1) - # so we request the nodelete flag to be enabled. - # On other systems, we don't really know how to do that, but it's welcome if somebody can tell. - # Windows doesn't support this flag. --if host_machine.system() != 'windows' -+if host_machine.system() != 'windows' and host_machine.system() != 'darwin' - nodelete_link_args = ['-Wl,-z,nodelete'] - else - nodelete_link_args = [] --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/0003-Ignore-HAVE_CPUID_H-on-aarch64-darwin.patch b/pkgs/servers/pulseaudio/0003-Ignore-HAVE_CPUID_H-on-aarch64-darwin.patch new file mode 100644 index 000000000000..ce0df74f8771 --- /dev/null +++ b/pkgs/servers/pulseaudio/0003-Ignore-HAVE_CPUID_H-on-aarch64-darwin.patch @@ -0,0 +1,26 @@ +diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c +index c383a61c0..3d0a68c2e 100644 +--- a/src/pulsecore/core-util.c ++++ b/src/pulsecore/core-util.c +@@ -110,7 +110,7 @@ + #include + #endif + +-#ifdef HAVE_CPUID_H ++#if defined(HAVE_CPUID_H) && !(defined(__APPLE__) && defined(__aarch64__)) + #include + #endif + +diff --git a/src/pulsecore/cpu-x86.c b/src/pulsecore/cpu-x86.c +index 317a0101e..d1eb95d2b 100644 +--- a/src/pulsecore/cpu-x86.c ++++ b/src/pulsecore/cpu-x86.c +@@ -24,7 +24,7 @@ + + #include + +-#ifdef HAVE_CPUID_H ++#if defined(HAVE_CPUID_H) && !(defined(__APPLE__) && defined(__aarch64__)) + #include + #endif + diff --git a/pkgs/servers/pulseaudio/0004-Prefer-HAVE_CLOCK_GETTIME-on-darwin.patch b/pkgs/servers/pulseaudio/0004-Prefer-HAVE_CLOCK_GETTIME-on-darwin.patch new file mode 100644 index 000000000000..0eeaf2a03a12 --- /dev/null +++ b/pkgs/servers/pulseaudio/0004-Prefer-HAVE_CLOCK_GETTIME-on-darwin.patch @@ -0,0 +1,13 @@ +diff --git a/src/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c +index 2c2e28631..b946a3fb1 100644 +--- a/src/pulsecore/core-rtclock.c ++++ b/src/pulsecore/core-rtclock.c +@@ -65,7 +65,7 @@ pa_usec_t pa_rtclock_age(const struct timeval *tv) { + + struct timeval *pa_rtclock_get(struct timeval *tv) { + +-#if defined(OS_IS_DARWIN) ++#if defined(OS_IS_DARWIN) && !defined(HAVE_CLOCK_GETTIME) + uint64_t val, abs_time = mach_absolute_time(); + Nanoseconds nanos; + diff --git a/pkgs/servers/pulseaudio/0004-Prefer-clock_gettime.patch b/pkgs/servers/pulseaudio/0004-Prefer-clock_gettime.patch deleted file mode 100644 index eb7bd1c62708..000000000000 --- a/pkgs/servers/pulseaudio/0004-Prefer-clock_gettime.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 0bd3b613ac3bf16a73b3223fa1b961da3a0db1b2 Mon Sep 17 00:00:00 2001 -From: Andrew Childs -Date: Tue, 19 Apr 2022 17:12:52 +0900 -Subject: [PATCH 4/8] Prefer clock_gettime - -Available in darwin since 10.12 (released in 2016). ---- - src/pulsecore/core-rtclock.c | 26 +++++++++++++------------- - 1 file changed, 13 insertions(+), 13 deletions(-) - -diff --git a/src/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c -index 2c2e28631..a08d4b391 100644 ---- a/src/pulsecore/core-rtclock.c -+++ b/src/pulsecore/core-rtclock.c -@@ -65,19 +65,7 @@ pa_usec_t pa_rtclock_age(const struct timeval *tv) { - - struct timeval *pa_rtclock_get(struct timeval *tv) { - --#if defined(OS_IS_DARWIN) -- uint64_t val, abs_time = mach_absolute_time(); -- Nanoseconds nanos; -- -- nanos = AbsoluteToNanoseconds(*(AbsoluteTime *) &abs_time); -- val = *(uint64_t *) &nanos; -- -- tv->tv_sec = val / PA_NSEC_PER_SEC; -- tv->tv_usec = (val % PA_NSEC_PER_SEC) / PA_NSEC_PER_USEC; -- -- return tv; -- --#elif defined(HAVE_CLOCK_GETTIME) -+#if defined(HAVE_CLOCK_GETTIME) - struct timespec ts; - - #ifdef CLOCK_MONOTONIC -@@ -109,6 +97,18 @@ struct timeval *pa_rtclock_get(struct timeval *tv) { - - return tv; - } -+#elif defined(OS_IS_DARWIN) -+ uint64_t val, abs_time = mach_absolute_time(); -+ Nanoseconds nanos; -+ -+ nanos = AbsoluteToNanoseconds(*(AbsoluteTime *) &abs_time); -+ val = *(uint64_t *) &nanos; -+ -+ tv->tv_sec = val / PA_NSEC_PER_SEC; -+ tv->tv_usec = (val % PA_NSEC_PER_SEC) / PA_NSEC_PER_USEC; -+ -+ return tv; -+ - #endif /* HAVE_CLOCK_GETTIME */ - - return pa_gettimeofday(tv); --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/0005-Enable-CoreAudio-on-darwin.patch b/pkgs/servers/pulseaudio/0005-Enable-CoreAudio-on-darwin.patch new file mode 100644 index 000000000000..bdf5ff2b9ca3 --- /dev/null +++ b/pkgs/servers/pulseaudio/0005-Enable-CoreAudio-on-darwin.patch @@ -0,0 +1,31 @@ +diff --git a/meson.build b/meson.build +index c5135330f..055567479 100644 +--- a/meson.build ++++ b/meson.build +@@ -185,6 +185,7 @@ endif + # rather than ending up in the config.h file? + if host_machine.system() == 'darwin' + cdata.set('OS_IS_DARWIN', 1) ++ cdata.set('HAVE_COREAUDIO', 1) + cdata.set('_DARWIN_C_SOURCE', '200112L') # Needed to get NSIG on Mac OS + elif host_machine.system() == 'windows' + cdata.set('OS_IS_WIN32', 1) +diff --git a/src/modules/meson.build b/src/modules/meson.build +index 1e12569dc..53a800927 100644 +--- a/src/modules/meson.build ++++ b/src/modules/meson.build +@@ -63,6 +63,14 @@ all_modules = [ + [ 'module-volume-restore', 'module-volume-restore.c' ], + ] + ++if host_machine.system() == 'darwin' ++ coreaudio_dep = dependency('appleframeworks', modules : ['AudioUnit', 'Cocoa', 'CoreServices', 'CoreAudio']) ++ all_modules += [ ++ [ 'module-coreaudio-detect', 'macosx/module-coreaudio-detect.c', [], [], [coreaudio_dep] ], ++ [ 'module-coreaudio-device', 'macosx/module-coreaudio-device.c', [], [], [coreaudio_dep] ], ++ ] ++endif ++ + if host_machine.system() == 'windows' + winmm_dep = meson.get_compiler('c').find_library('winmm') + ksuser_dep = meson.get_compiler('c').find_library('ksuser') diff --git a/pkgs/servers/pulseaudio/0005-Include-poll-posix.c-on-darwin.patch b/pkgs/servers/pulseaudio/0005-Include-poll-posix.c-on-darwin.patch deleted file mode 100644 index 4779fce2afd6..000000000000 --- a/pkgs/servers/pulseaudio/0005-Include-poll-posix.c-on-darwin.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 8dee473920d3a331b73a415b37e7e0b01f014110 Mon Sep 17 00:00:00 2001 -From: Andrew Childs -Date: Tue, 19 Apr 2022 17:22:23 +0900 -Subject: [PATCH 5/8] Include poll-posix.c on darwin - ---- - src/meson.build | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/meson.build b/src/meson.build -index e2860811b..5bd68cb12 100644 ---- a/src/meson.build -+++ b/src/meson.build -@@ -182,6 +182,7 @@ if host_machine.system() == 'windows' - else - libpulsecommon_sources += [ - 'pulsecore/mutex-posix.c', -+ 'pulsecore/poll-posix.c', - 'pulsecore/semaphore-posix.c', - 'pulsecore/thread-posix.c' - ] --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/0006-Fix-libpulsecommon-sources-on-darwin.patch b/pkgs/servers/pulseaudio/0006-Fix-libpulsecommon-sources-on-darwin.patch new file mode 100644 index 000000000000..67a21af46795 --- /dev/null +++ b/pkgs/servers/pulseaudio/0006-Fix-libpulsecommon-sources-on-darwin.patch @@ -0,0 +1,18 @@ +diff --git a/src/meson.build b/src/meson.build +index 9efb561d8..d181f4867 100644 +--- a/src/meson.build ++++ b/src/meson.build +@@ -179,6 +179,13 @@ if host_machine.system() == 'windows' + 'pulsecore/semaphore-win32.c', + 'pulsecore/thread-win32.c', + ] ++elif host_machine.system() == 'darwin' ++ libpulsecommon_sources += [ ++ 'pulsecore/mutex-posix.c', ++ 'pulsecore/poll-posix.c', ++ 'pulsecore/semaphore-osx.c', ++ 'pulsecore/thread-posix.c' ++ ] + else + libpulsecommon_sources += [ + 'pulsecore/mutex-posix.c', diff --git a/pkgs/servers/pulseaudio/0006-Only-use-version-script-on-GNU-ish-linkers.patch b/pkgs/servers/pulseaudio/0006-Only-use-version-script-on-GNU-ish-linkers.patch deleted file mode 100644 index 8b27b3e5ab77..000000000000 --- a/pkgs/servers/pulseaudio/0006-Only-use-version-script-on-GNU-ish-linkers.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 419258112b9d90d149ebbd5c657a36d8532b78a2 Mon Sep 17 00:00:00 2001 -From: Andrew Childs -Date: Tue, 19 Apr 2022 17:31:36 +0900 -Subject: [PATCH 6/8] Only use version-script on GNU-ish linkers - ---- - src/pulse/meson.build | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/pulse/meson.build b/src/pulse/meson.build -index c2128e087..a5e47867e 100644 ---- a/src/pulse/meson.build -+++ b/src/pulse/meson.build -@@ -74,7 +74,11 @@ run_target('update-map-file', - command : [ join_paths(meson.source_root(), 'scripts/generate-map-file.sh'), 'map-file', - [ libpulse_headers, 'simple.h', join_paths(meson.build_root(), 'src', 'pulse', 'version.h') ] ]) - --versioning_link_args = '-Wl,-version-script=' + join_paths(meson.source_root(), 'src', 'pulse', 'map-file') -+if meson.get_compiler('c').get_linker_id().startswith('ld.') -+ versioning_link_args = '-Wl,-version-script=' + join_paths(meson.source_root(), 'src', 'pulse', 'map-file') -+else -+ versioning_link_args = [] -+endif - - libpulse = shared_library('pulse', - libpulse_sources, --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/0007-Adapt-undefined-link-args-per-linker.patch b/pkgs/servers/pulseaudio/0007-Adapt-undefined-link-args-per-linker.patch deleted file mode 100644 index 6893df8a7e29..000000000000 --- a/pkgs/servers/pulseaudio/0007-Adapt-undefined-link-args-per-linker.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 6f132be835d5acb5db4301ea1818601504e47fae Mon Sep 17 00:00:00 2001 -From: Andrew Childs -Date: Tue, 19 Apr 2022 17:41:34 +0900 -Subject: [PATCH 7/8] Adapt undefined link args per linker - -TODO: Why is this required? Isn't it default? ---- - src/modules/meson.build | 13 ++++++++++++- - 1 file changed, 12 insertions(+), 1 deletion(-) - -diff --git a/src/modules/meson.build b/src/modules/meson.build -index be72c3b9b..0163b583f 100644 ---- a/src/modules/meson.build -+++ b/src/modules/meson.build -@@ -293,6 +293,17 @@ all_modules += [ - # FIXME: meson doesn't support multiple RPATH arguments currently - rpath_dirs = join_paths(privlibdir) + ':' + join_paths(modlibexecdir) - -+if meson.get_compiler('c').get_linker_id().startswith('ld.') -+ no_undefined_link_args = [ '-Wl,--no-undefined' ] -+elif meson.get_compiler('c').get_linker_id() == 'ld64' -+ # TODO: is this required? is this not default? -+ no_undefined_link_args = [ '-Wl,-undefined,error' ] -+else -+ # TODO: what platforms is this? what flag do they use? -+ no_undefined_link_args = [] -+endif -+ -+ - foreach m : all_modules - name = m[0] - sources = m[1] -@@ -310,7 +321,7 @@ foreach m : all_modules - install_rpath : rpath_dirs, - install_dir : modlibexecdir, - dependencies : [thread_dep, libpulse_dep, libpulsecommon_dep, libpulsecore_dep, libintl_dep, platform_dep, platform_socket_dep] + extra_deps, -- link_args : [nodelete_link_args, '-Wl,--no-undefined' ], -+ link_args : [nodelete_link_args, no_undefined_link_args ], - link_with : extra_libs, - name_prefix : '', - implicit_include_directories : false) --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/0007-Fix-link-args-on-darwin.patch b/pkgs/servers/pulseaudio/0007-Fix-link-args-on-darwin.patch new file mode 100644 index 000000000000..30a11adca085 --- /dev/null +++ b/pkgs/servers/pulseaudio/0007-Fix-link-args-on-darwin.patch @@ -0,0 +1,75 @@ +diff --git a/meson.build b/meson.build +index c5135330f..1b66a1fc4 100644 +--- a/meson.build ++++ b/meson.build +@@ -424,7 +424,7 @@ cdata.set('MESON_BUILD', 1) + # so we request the nodelete flag to be enabled. + # On other systems, we don't really know how to do that, but it's welcome if somebody can tell. + # Windows doesn't support this flag. +-if host_machine.system() != 'windows' ++if host_machine.system() not in ['windows', 'darwin'] + nodelete_link_args = ['-Wl,-z,nodelete'] + else + nodelete_link_args = [] +diff --git a/src/modules/echo-cancel/meson.build b/src/modules/echo-cancel/meson.build +index 641cd35e7..523bffac4 100644 +--- a/src/modules/echo-cancel/meson.build ++++ b/src/modules/echo-cancel/meson.build +@@ -10,12 +10,17 @@ libwebrtc_util_sources = [ + 'webrtc.cc' + ] + ++ignore_unresolved_symbols_link_args = ['-Wl,--unresolved-symbols=ignore-in-object-files'] ++if meson.get_compiler('c').get_linker_id() == 'ld64' ++ ignore_unresolved_symbols_link_args = [ '-Wl,-undefined,dynamic_lookup' ] ++endif ++ + libwebrtc_util = shared_library('webrtc-util', + libwebrtc_util_sources, + cpp_args : [pa_c_args, server_c_args], + include_directories : [configinc, topinc], + dependencies : [libpulse_dep, libpulsecommon_dep, libpulsecore_dep, libatomic_ops_dep, webrtc_dep, libintl_dep], +- link_args : [nodelete_link_args, '-Wl,--unresolved-symbols=ignore-in-object-files'], ++ link_args : [nodelete_link_args, ignore_unresolved_symbols_link_args], + install : true, + install_rpath : privlibdir, + install_dir : modlibexecdir, +diff --git a/src/modules/meson.build b/src/modules/meson.build +index 1e12569dc..66f3e46a4 100644 +--- a/src/modules/meson.build ++++ b/src/modules/meson.build +@@ -298,6 +298,11 @@ all_modules += [ + # FIXME: meson doesn't support multiple RPATH arguments currently + rpath_dirs = join_paths(privlibdir) + ':' + join_paths(modlibexecdir) + ++no_undefined_link_args = ['-Wl,--no-undefined'] ++if meson.get_compiler('c').get_linker_id() == 'ld64' ++ no_undefined_link_args = [ '-Wl,-undefined,error' ] ++endif ++ + foreach m : all_modules + name = m[0] + sources = m[1] +@@ -315,7 +320,7 @@ foreach m : all_modules + install_rpath : rpath_dirs, + install_dir : modlibexecdir, + dependencies : [thread_dep, libpulse_dep, libpulsecommon_dep, libpulsecore_dep, libintl_dep, platform_dep, platform_socket_dep] + extra_deps, +- link_args : [nodelete_link_args, '-Wl,--no-undefined' ], ++ link_args : [nodelete_link_args, no_undefined_link_args ], + link_with : extra_libs, + name_prefix : '', + implicit_include_directories : false) +diff --git a/src/pulse/meson.build b/src/pulse/meson.build +index 1b82c807c..938e4addd 100644 +--- a/src/pulse/meson.build ++++ b/src/pulse/meson.build +@@ -75,6 +75,9 @@ run_target('update-map-file', + [ libpulse_headers, 'simple.h', join_paths(meson.build_root(), 'src', 'pulse', 'version.h') ] ]) + + versioning_link_args = '-Wl,-version-script=' + join_paths(meson.source_root(), 'src', 'pulse', 'map-file') ++if meson.get_compiler('c').get_linker_id() == 'ld64' ++ versioning_link_args = [] ++endif + + libpulse = shared_library('pulse', + libpulse_sources, diff --git a/pkgs/servers/pulseaudio/0008-Use-correct-semaphore-on-darwin.patch b/pkgs/servers/pulseaudio/0008-Use-correct-semaphore-on-darwin.patch deleted file mode 100644 index 274534665628..000000000000 --- a/pkgs/servers/pulseaudio/0008-Use-correct-semaphore-on-darwin.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 1a840b6e517004c902dfbea3d358b344c9588978 Mon Sep 17 00:00:00 2001 -From: Andrew Childs -Date: Tue, 19 Apr 2022 17:49:08 +0900 -Subject: [PATCH 8/8] Use correct semaphore on darwin - ---- - src/meson.build | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/meson.build b/src/meson.build -index 5bd68cb12..041e2fab4 100644 ---- a/src/meson.build -+++ b/src/meson.build -@@ -183,9 +183,13 @@ else - libpulsecommon_sources += [ - 'pulsecore/mutex-posix.c', - 'pulsecore/poll-posix.c', -- 'pulsecore/semaphore-posix.c', - 'pulsecore/thread-posix.c' - ] -+ if host_machine.system() == 'darwin' -+ libpulsecommon_sources += [ 'pulsecore/semaphore-osx.c' ] -+ else -+ libpulsecommon_sources += [ 'pulsecore/semaphore-posix.c' ] -+ endif - endif - # FIXME: Do SIMD things - --- -2.35.1 - diff --git a/pkgs/servers/pulseaudio/default.nix b/pkgs/servers/pulseaudio/default.nix index 95ee97ef6c87..2a1bd3c70fbb 100644 --- a/pkgs/servers/pulseaudio/default.nix +++ b/pkgs/servers/pulseaudio/default.nix @@ -9,7 +9,7 @@ , x11Support ? false -, useSystemd ? true +, useSystemd ? stdenv.isLinux , # Whether to support the JACK sound system as a backend. jackaudioSupport ? false @@ -19,17 +19,20 @@ , airtunesSupport ? false -, bluetoothSupport ? true +, bluetoothSupport ? stdenv.isLinux , advancedBluetoothCodecs ? false , remoteControlSupport ? false , zeroconfSupport ? false +, alsaSupport ? stdenv.isLinux +, udevSupport ? stdenv.isLinux + , # Whether to build only the library. libOnly ? false -, AudioUnit, Cocoa, CoreServices +, AudioUnit, Cocoa, CoreServices, CoreAudio }: stdenv.mkDerivation rec { @@ -45,18 +48,15 @@ stdenv.mkDerivation rec { # Install sysconfdir files inside of the nix store, # but use a conventional runtime sysconfdir outside the store ./add-option-for-installation-sysconfdir.patch - ] ++ lib.optionals stdenv.isDarwin [ # https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/654 - ./0001-Make-gio-2.0-optional-when-gsettings-is-disabled.patch - + (./0001-Make-gio-2.0-optional-${lib.versions.major version}.patch) # TODO (not sent upstream) - ./0002-Ignore-SCM_CREDS-on-macOS.patch - ./0003-Disable-z-nodelete-on-darwin.patch - ./0004-Prefer-clock_gettime.patch - ./0005-Include-poll-posix.c-on-darwin.patch - ./0006-Only-use-version-script-on-GNU-ish-linkers.patch - ./0007-Adapt-undefined-link-args-per-linker.patch - ./0008-Use-correct-semaphore-on-darwin.patch + ./0002-Ignore-SCM_CREDS-on-darwin.patch + ./0003-Ignore-HAVE_CPUID_H-on-aarch64-darwin.patch + ./0004-Prefer-HAVE_CLOCK_GETTIME-on-darwin.patch + ./0005-Enable-CoreAudio-on-darwin.patch + ./0006-Fix-libpulsecommon-sources-on-darwin.patch + ./0007-Fix-link-args-on-darwin.patch ]; outputs = [ "out" "dev" ]; @@ -72,7 +72,7 @@ stdenv.mkDerivation rec { buildInputs = [ libtool libsndfile soxr speexdsp fftwFloat check ] ++ lib.optionals stdenv.isLinux [ glib dbus ] - ++ lib.optionals stdenv.isDarwin [ AudioUnit Cocoa CoreServices libintl ] + ++ lib.optionals stdenv.isDarwin [ AudioUnit Cocoa CoreServices CoreAudio libintl ] ++ lib.optionals (!libOnly) ( [ libasyncns webrtc-audio-processing ] ++ lib.optional jackaudioSupport libjack2 @@ -88,7 +88,7 @@ stdenv.mkDerivation rec { ); mesonFlags = [ - "-Dalsa=${if !libOnly then "enabled" else "disabled"}" + "-Dalsa=${if !libOnly && alsaSupport then "enabled" else "disabled"}" "-Dasyncns=${if !libOnly then "enabled" else "disabled"}" "-Davahi=${if zeroconfSupport then "enabled" else "disabled"}" "-Dbluez5=${if !libOnly && bluetoothSupport then "enabled" else "disabled"}" @@ -107,7 +107,7 @@ stdenv.mkDerivation rec { "-Dorc=disabled" "-Dsystemd=${if useSystemd && !libOnly then "enabled" else "disabled"}" "-Dtcpwrap=disabled" - "-Dudev=${if !libOnly then "enabled" else "disabled"}" + "-Dudev=${if !libOnly && udevSupport then "enabled" else "disabled"}" "-Dvalgrind=disabled" "-Dwebrtc-aec=${if !libOnly then "enabled" else "disabled"}" "-Dx11=${if x11Support then "enabled" else "disabled"}" @@ -118,7 +118,7 @@ stdenv.mkDerivation rec { "-Dudevrulesdir=${placeholder "out"}/lib/udev/rules.d" ] ++ lib.optional (stdenv.isLinux && useSystemd) "-Dsystemduserunitdir=${placeholder "out"}/lib/systemd/user" - ++ lib.optionals (stdenv.isDarwin) [ + ++ lib.optionals stdenv.isDarwin [ "-Ddbus=disabled" "-Dglib=disabled" "-Doss-output=disabled" @@ -144,10 +144,21 @@ stdenv.mkDerivation rec { wrapProgram $out/libexec/pulse/gsettings-helper \ --prefix XDG_DATA_DIRS : "$out/share/gsettings-schemas/${pname}-${version}" \ --prefix GIO_EXTRA_MODULES : "${lib.getLib dconf}/lib/gio/modules" + '' + # add .so symlinks for modules to be found under macOS + + lib.optionalString stdenv.isDarwin '' + for file in $out/${passthru.pulseDir}/modules/*.dylib; do + ln -s "''$file" "''${file%.dylib}.so" + ln -s "''$file" "$out/lib/pulseaudio/''$(basename ''$file .dylib).so" + done ''; passthru = { - pulseDir = "lib/pulse-" + lib.versions.majorMinor version; + pulseDir = + if (lib.versionAtLeast version "16.0") then + "lib/pulseaudio" + else + "lib/pulse-" + lib.versions.majorMinor version; }; meta = { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ade036609efe..5511bcb39002 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -22681,7 +22681,7 @@ with pkgs; hsphfpd = callPackage ../servers/pulseaudio/hsphfpd.nix { }; pulseaudio = callPackage ../servers/pulseaudio { - inherit (darwin.apple_sdk.frameworks) CoreServices AudioUnit Cocoa; + inherit (darwin.apple_sdk.frameworks) CoreServices AudioUnit Cocoa CoreAudio; }; qpaeq = libsForQt5.callPackage ../servers/pulseaudio/qpaeq.nix { }; From 60514b555d16027ba4f12da72291747e37f38f5d Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 2 Aug 2022 18:39:38 +0200 Subject: [PATCH 2/3] libcanberra: fix build on darwin --- .../libraries/libcanberra/default.nix | 22 +++++++++++-------- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pkgs/development/libraries/libcanberra/default.nix b/pkgs/development/libraries/libcanberra/default.nix index 91b720303199..6cdadeac296d 100644 --- a/pkgs/development/libraries/libcanberra/default.nix +++ b/pkgs/development/libraries/libcanberra/default.nix @@ -1,7 +1,7 @@ { stdenv, lib, fetchurl, fetchpatch, pkg-config, libtool , gtk2-x11, gtk3-x11 , gtkSupport ? null , libpulseaudio, gst_all_1, libvorbis, libcap -, Carbon, CoreServices +, Carbon, CoreServices, AppKit , withAlsa ? stdenv.isLinux, alsa-lib }: stdenv.mkDerivation rec { @@ -21,7 +21,7 @@ stdenv.mkDerivation rec { ] ++ (with gst_all_1; [ gstreamer gst-plugins-base ]) ++ lib.optional (gtkSupport == "gtk2") gtk2-x11 ++ lib.optional (gtkSupport == "gtk3") gtk3-x11 - ++ lib.optionals stdenv.isDarwin [Carbon CoreServices] + ++ lib.optionals stdenv.isDarwin [ Carbon CoreServices AppKit ] ++ lib.optional stdenv.isLinux libcap ++ lib.optional withAlsa alsa-lib; @@ -33,15 +33,19 @@ stdenv.mkDerivation rec { url = "http://git.0pointer.net/libcanberra.git/patch/?id=c0620e432650e81062c1967cc669829dbd29b310"; sha256 = "0rc7zwn39yxzxp37qh329g7375r5ywcqcaak8ryd0dgvg8m5hcx9"; }) + ] ++ lib.optionals stdenv.isDarwin [ + (fetchpatch { + url = "https://github.com/macports/macports-ports/raw/5a7965dfea7727d1ceedee46c7b0ccee9cb23468/audio/libcanberra/files/patch-configure.diff"; + sha256 = "sha256-pEJy1krciUEg5BFIS8FJ4BubjfS/nt9aqi6BLnS1+4M="; + extraPrefix = ""; + }) + (fetchpatch { + url = "https://github.com/macports/macports-ports/raw/5a7965dfea7727d1ceedee46c7b0ccee9cb23468/audio/libcanberra/files/dynamic_lookup-11.patch"; + sha256 = "sha256-nUjha2pKh5VZl0ZZzcr9NTo1TVuMqF4OcLiztxW+ofQ="; + extraPrefix = ""; + }) ]; - postPatch = lib.optionalString stdenv.isDarwin '' - patch -p0 < ${fetchpatch { - url = "https://raw.githubusercontent.com/macports/macports-ports/master/audio/libcanberra/files/patch-configure.diff"; - sha256 = "1f7h7ifpqvbfhqygn1b7klvwi80zmpv3538vbmq7ql7bkf1q8h31"; - }} - ''; - postInstall = '' for f in $out/lib/*.la; do sed 's|-lltdl|-L${libtool.lib}/lib -lltdl|' -i $f diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5511bcb39002..e2f29029d051 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18729,7 +18729,7 @@ with pkgs; libcamera = callPackage ../development/libraries/libcamera { }; libcanberra = callPackage ../development/libraries/libcanberra { - inherit (darwin.apple_sdk.frameworks) Carbon CoreServices; + inherit (darwin.apple_sdk.frameworks) Carbon CoreServices AppKit; }; libcanberra-gtk2 = pkgs.libcanberra.override { gtkSupport = "gtk2"; From aac52a923f909ca282e4f63e3860973e4eb61594 Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Tue, 2 Aug 2022 18:39:43 +0200 Subject: [PATCH 3/3] gsound: add darwin support --- pkgs/development/libraries/gsound/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/gsound/default.nix b/pkgs/development/libraries/gsound/default.nix index ddbfc307b2d1..7dbe5cd2bbfc 100644 --- a/pkgs/development/libraries/gsound/default.nix +++ b/pkgs/development/libraries/gsound/default.nix @@ -31,6 +31,6 @@ stdenv.mkDerivation rec { description = "Small library for playing system sounds"; maintainers = teams.gnome.members; license = licenses.gpl2; - platforms = platforms.linux; + platforms = platforms.unix; }; }