alsa-ucm-conf: patch custom PinePhone conf into the upstream package rather than shipping *only* the PinePhone configs

this is more to faciliate a goal of eventually not shipping any custom audio profiles

i.e. stay close to how upstream does things until we reach that goal

-mnote that this doesn't actually override the alsa-ucm-conf nix package (yet).

doing so is costly
This commit is contained in:
Colin 2023-06-01 09:19:45 +00:00
parent aa60838551
commit c6e16ebc13
9 changed files with 54 additions and 8 deletions

View File

@ -77,14 +77,11 @@
# enable rotation sensor
hardware.sensor.iio.enable = true;
# from https://gitlab.manjaro.org/manjaro-arm/packages/community/phosh/alsa-ucm-pinephone
# mobile-nixos does this same thing, with *slightly different settings*.
# i trust manjaro more because the guy maintaining that is actively trying to upstream into alsa-ucm-conf.
# an alternative may be to build a custom alsa with the PinePhone config patch applied:
# - <https://github.com/alsa-project/alsa-ucm-conf/pull/134>
# that would make this be not device-specific
environment.variables.ALSA_CONFIG_UCM2 = "${./ucm2}";
systemd.services.pulseaudio.environment.ALSA_CONFIG_UCM2 = "${./ucm2}";
# inject specialized alsa configs via the environment.
# specifically, this gets the pinephone headphones & internal earpiece working.
# see pkgs/patched/alsa-ucm-conf for more info
environment.variables.ALSA_CONFIG_UCM2 = "${pkgs.alsa-ucm-conf-sane}/share/alsa/ucm2";
systemd.services.pulseaudio.environment.ALSA_CONFIG_UCM2 = "${pkgs.alsa-ucm-conf-sane}/share/alsa/ucm2";
hardware.opengl.driSupport = true;
}

View File

@ -0,0 +1,14 @@
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index d188ecdda55..69174ba7dc7 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -26607,7 +26607,8 @@ with pkgs;
tinyalsa = callPackage ../os-specific/linux/tinyalsa { };
- inherit (callPackage ../os-specific/linux/alsa-project { })
+ alsa-project = callPackage ../os-specific/linux/alsa-project { };
+ inherit (alsa-project)
alsa-firmware
alsa-lib
alsa-oss

View File

@ -150,6 +150,9 @@ in [
hash = "sha256-9XKPNg7TewicfbMgiASpYysTs5aduIVP+4onz+noc/0=";
})
# make alsa-project members overridable
./2023-05-31-toplevel-alsa.patch
# for raspberry pi: allow building u-boot for rpi 4{,00}
# TODO: remove after upstreamed: https://github.com/NixOS/nixpkgs/pull/176018
# (it's a dupe of https://github.com/NixOS/nixpkgs/pull/112677 )

View File

@ -19,6 +19,7 @@ let
sane-lib = import ../modules/lib final';
### ADDITIONAL PACKAGES
alsa-ucm-conf-sane = callPackage ./patched/alsa-ucm-conf { inherit (unpatched) alsa-ucm-conf; };
bonsai = unpatched.bonsai or (callPackage ./additional/bonsai { });
bootpart-uefi-x86_64 = callPackage ./additional/bootpart-uefi-x86_64 { };
browserpass-extension = callPackage ./additional/browserpass-extension { };
@ -63,6 +64,13 @@ let
# - pkgs.callPackage draws from the _final_ package set.
# - unpatched.XYZ draws (selectively) from the _unpatched_ package set.
# see <overlays/pkgs.nix>
# XXX patching this is... really costly.
# prefer to set ALSA_CONFIG_UCM2 = "${pkgs.alsa-ucm-conf-sane}/share/alsa/ucm2" if possible instead.
# alsa-project = unpatched.alsa-project.overrideScope' (sself: ssuper: {
# alsa-ucm-conf = sself.callPackage ./patched/alsa-ucm-conf { inherit (ssuper) alsa-ucm-conf; };
# });
browserpass = callPackage ./patched/browserpass { inherit (unpatched) browserpass; };
# mozilla keeps nerfing itself and removing configuration options

View File

@ -0,0 +1,24 @@
{ alsa-ucm-conf }:
alsa-ucm-conf.overrideAttrs (upstream: {
# upstream alsa ships with PinePhone audio configs, but they don't actually produce sound.
# see: <https://github.com/alsa-project/alsa-ucm-conf/pull/134>
# these audio files come from some revision of:
# - <https://gitlab.manjaro.org/manjaro-arm/packages/community/phosh/alsa-ucm-pinephone>
#
# alternative to patching is to plumb `ALSA_CONFIG_UCM2 = "${./ucm2}"` environment variable into the relevant places
# e.g. `systemd.services.pulseaudio.environment`.
# that leaves more opportunity for gaps (i.e. missing a service),
# on the other hand thie method causes about 500 packages to be rebuilt
#
# note that with these files, the following audio device support:
# - headphones work.
# - "internal earpiece" works.
# - "internal speaker" doesn't work.
# - "analog output" doesn't work.
postPatch = upstream.postPatch or "" + ''
cp ${./ucm2/PinePhone}/* ucm2/Allwinner/A64/PinePhone/
# fix the self-contained ucm files i source from to have correct path within the alsa-ucm-conf source tree
sed -i 's:"HiFi.conf":"/Allwinner/A64/PinePhone/HiFi.conf":' ucm2/Allwinner/A64/PinePhone/PinePhone.conf
sed -i 's:"VoiceCall.conf":"/Allwinner/A64/PinePhone/VoiceCall.conf":' ucm2/Allwinner/A64/PinePhone/PinePhone.conf
'';
})