From 7a29afdd00132135697a75ed2d6e6c6dd993a0bc Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Thu, 22 Feb 2018 22:09:07 +0000 Subject: [PATCH] pkgs: libpulseaudio -> libcardiacarrest; nixos: override when running PA daemon This satisfies both people that want to purge every single bit of PulseAudio from their systems for ethical, religious, and/or security reasons and those who want to run the daemon for convenience reasons. This also significantly reduces closure size when not running PulseAudio daemon since `libcardiacarrest` is tiny. NOTE: With this in place I - built everything I use, Xfce, KDE, most of GNOME3, - tested everything I use, Xfce, KDE, official PulseAudio tools like pavucontrol, etc, - verified that some other things I don't want to build (like Chromium) would work with this by looking at their sources, and everything seems to work (i.e. gracefully fails to use PulseAudio). However, I'm almost sure this will break things I didn't build and test. PulseAudio API is huge and full of surprises, hence many application authors fail use it correctly (and they are not alone, even the likes of Mozilla fail to properly check for PA errors in Firefox). If this commit breaks your thing, please, don't just revert this, instead override `libpulseaudio` for your thing with `libpulseaudio-vanilla` and then let me know about it so that I could fix an "ignores return values" bug in your thing or add some missing pieces to `libcardiacarrest` to make your thing happy. Thank you. --- nixos/modules/config/pulseaudio.nix | 3 +++ pkgs/top-level/all-packages.nix | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/nixos/modules/config/pulseaudio.nix b/nixos/modules/config/pulseaudio.nix index a9c5fc75660d3..d457ae56cbd7f 100644 --- a/nixos/modules/config/pulseaudio.nix +++ b/nixos/modules/config/pulseaudio.nix @@ -228,6 +228,9 @@ in { source = writeText "libao.conf" "default_driver=pulse"; } ]; + environment.sessionVariables.LD_LIBRARY_PATH = + [ "${getLib overriddenPackage}/lib" ]; + # Allow PulseAudio to get realtime priority using rtkit. security.rtkit.enable = true; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 46906ea26838a..3e37ae82e2fb7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12423,7 +12423,21 @@ with pkgs; libpulseaudio = libpulseaudio-vanilla; # meta only }; - libpulseaudio = libpulseaudio-vanilla; + # See `longDescription` of `libcardiacarrest`. We use + # `libcardiacarrest` as our default `libpulse` implementation, NixOS + # then overrides it at run-time with `libpulseaudio-vanilla` via + # `LD_LIBRARY_PATH` when the user enables the daemon service. + # + # This way + # - users that don't run PulseAudio daemon benefit from smaller + # closure sizes, + # - users that don't run PulseAudio daemon and don't want to even + # link against `libpulseaudio-vanilla` for ethical, religious, + # and/or security reasons don't need to make any overrides and + # benefit from hydra cache, + # - while users that do run PulseAudio daemon don't really notice + # anything. + libpulseaudio = libcardiacarrest; tomcat_connectors = callPackage ../servers/http/apache-modules/tomcat-connectors { };