From f2271180dd675cc48289b1f76fdfade532aa5441 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 27 May 2024 12:53:06 +0000 Subject: [PATCH] alsa-ucm-conf: split the patched alsa confs out into their own package --- .../common/programs/alsa-ucm-conf/default.nix | 40 +++++-------------- hosts/common/programs/assorted.nix | 2 + .../alsa-ucm-pinephone-manjaro/default.nix | 28 +++++++++++++ .../ucm2/PinePhone/HiFi.conf | 0 .../ucm2/PinePhone/PinePhone.conf | 0 .../ucm2/PinePhone/VoiceCall.conf | 0 .../alsa-ucm-pinephone-manjaro}/ucm2/ucm.conf | 0 pkgs/default.nix | 1 + 8 files changed, 41 insertions(+), 30 deletions(-) create mode 100644 pkgs/additional/alsa-ucm-pinephone-manjaro/default.nix rename {hosts/common/programs/alsa-ucm-conf => pkgs/additional/alsa-ucm-pinephone-manjaro}/ucm2/PinePhone/HiFi.conf (100%) rename {hosts/common/programs/alsa-ucm-conf => pkgs/additional/alsa-ucm-pinephone-manjaro}/ucm2/PinePhone/PinePhone.conf (100%) rename {hosts/common/programs/alsa-ucm-conf => pkgs/additional/alsa-ucm-pinephone-manjaro}/ucm2/PinePhone/VoiceCall.conf (100%) rename {hosts/common/programs/alsa-ucm-conf => pkgs/additional/alsa-ucm-pinephone-manjaro}/ucm2/ucm.conf (100%) diff --git a/hosts/common/programs/alsa-ucm-conf/default.nix b/hosts/common/programs/alsa-ucm-conf/default.nix index 5fd177fd..ccf96eff 100644 --- a/hosts/common/programs/alsa-ucm-conf/default.nix +++ b/hosts/common/programs/alsa-ucm-conf/default.nix @@ -16,38 +16,18 @@ in # upstream alsa ships with PinePhone audio configs, but they don't actually produce sound. # see: - # these audio files come from some revision of: - # - # - # 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 this method causes about 500 packages to be rebuilt (including qt5 and webkitgtk). - # - # note that with these files, the following audio device support: - # - headphones work. - # - "internal earpiece" works. - # - "internal speaker" doesn't work (but that's probably because i broke the ribbon cable) - # - "analog output" doesn't work. - packageUnwrapped = pkgs.alsa-ucm-conf.overrideAttrs (upstream: { - postPatch = (upstream.postPatch or "") + '' - cp ${./ucm2/PinePhone}/* ucm2/Allwinner/A64/PinePhone/ + # we can substitute working UCM conf in two ways: + # 1. nixpkgs' override for the `alsa-ucm-conf` package + # - that forces a rebuild of ~500 packages (including webkitgtk). + # 2. set ALSA_CONFIG_UCM2 = /path/to/ucm2 in the relevant places + # - e.g. pulsewire service. + # - easy to miss places, though. + packageUnwrapped = pkgs.alsa-ucm-pinephone-manjaro.override { + inherit (cfg.config) preferEarpiece; + }; - # fix the self-contained ucm files i source from to have correct path within the alsa-ucm-conf source tree - substituteInPlace ucm2/Allwinner/A64/PinePhone/PinePhone.conf \ - --replace-fail 'HiFi.conf' '/Allwinner/A64/PinePhone/HiFi.conf' - substituteInPlace ucm2/Allwinner/A64/PinePhone/PinePhone.conf \ - --replace-fail 'VoiceCall.conf' '/Allwinner/A64/PinePhone/VoiceCall.conf' - '' + lib.optionalString cfg.config.preferEarpiece '' - # decrease the priority of the internal speaker so that sounds are routed - # to the earpiece by default. - # this is just personal preference. - substituteInPlace ucm2/Allwinner/A64/PinePhone/{HiFi.conf,VoiceCall.conf} \ - --replace-fail 'PlaybackPriority 300' 'PlaybackPriority 100' - ''; - }); - - sandbox.enable = false; #< only provides #out/share/alsa + sandbox.enable = false; #< only provides $out/share/alsa # alsa-lib package only looks in its $out/share/alsa to find runtime config data, by default. # but ALSA_CONFIG_UCM2 is an env var that can override that. diff --git a/hosts/common/programs/assorted.nix b/hosts/common/programs/assorted.nix index 742be180..4a3b1ff0 100644 --- a/hosts/common/programs/assorted.nix +++ b/hosts/common/programs/assorted.nix @@ -829,6 +829,8 @@ in smartmontools.sandbox.autodetectCliPaths = "existing"; smartmontools.sandbox.capabilities = [ "sys_rawio" ]; + # snapshot camera, based on libcamera + # TODO: enable dma heaps for more efficient buffer sharing: snapshot = {}; sops.sandbox.method = "bwrap"; # TODO:sandbox: untested diff --git a/pkgs/additional/alsa-ucm-pinephone-manjaro/default.nix b/pkgs/additional/alsa-ucm-pinephone-manjaro/default.nix new file mode 100644 index 00000000..59e4e63f --- /dev/null +++ b/pkgs/additional/alsa-ucm-pinephone-manjaro/default.nix @@ -0,0 +1,28 @@ +# these audio files come from some revision of: +# - +# note that with these files, the following audio device support: +# - headphones work. +# - "internal earpiece" works. +# - "internal speaker" doesn't work (but that's probably because i broke the ribbon cable) +# - "analog output" doesn't work. +{ alsa-ucm-conf +, lib +, preferEarpiece ? false +}: +alsa-ucm-conf.overrideAttrs (upstream: { + 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 + substituteInPlace ucm2/Allwinner/A64/PinePhone/PinePhone.conf \ + --replace-fail 'HiFi.conf' '/Allwinner/A64/PinePhone/HiFi.conf' + substituteInPlace ucm2/Allwinner/A64/PinePhone/PinePhone.conf \ + --replace-fail 'VoiceCall.conf' '/Allwinner/A64/PinePhone/VoiceCall.conf' + '' + lib.optionalString preferEarpiece '' + # decrease the priority of the internal speaker so that sounds are routed + # to the earpiece by default. + # this is just personal preference. + substituteInPlace ucm2/Allwinner/A64/PinePhone/{HiFi.conf,VoiceCall.conf} \ + --replace-fail 'PlaybackPriority 300' 'PlaybackPriority 100' + ''; +}) diff --git a/hosts/common/programs/alsa-ucm-conf/ucm2/PinePhone/HiFi.conf b/pkgs/additional/alsa-ucm-pinephone-manjaro/ucm2/PinePhone/HiFi.conf similarity index 100% rename from hosts/common/programs/alsa-ucm-conf/ucm2/PinePhone/HiFi.conf rename to pkgs/additional/alsa-ucm-pinephone-manjaro/ucm2/PinePhone/HiFi.conf diff --git a/hosts/common/programs/alsa-ucm-conf/ucm2/PinePhone/PinePhone.conf b/pkgs/additional/alsa-ucm-pinephone-manjaro/ucm2/PinePhone/PinePhone.conf similarity index 100% rename from hosts/common/programs/alsa-ucm-conf/ucm2/PinePhone/PinePhone.conf rename to pkgs/additional/alsa-ucm-pinephone-manjaro/ucm2/PinePhone/PinePhone.conf diff --git a/hosts/common/programs/alsa-ucm-conf/ucm2/PinePhone/VoiceCall.conf b/pkgs/additional/alsa-ucm-pinephone-manjaro/ucm2/PinePhone/VoiceCall.conf similarity index 100% rename from hosts/common/programs/alsa-ucm-conf/ucm2/PinePhone/VoiceCall.conf rename to pkgs/additional/alsa-ucm-pinephone-manjaro/ucm2/PinePhone/VoiceCall.conf diff --git a/hosts/common/programs/alsa-ucm-conf/ucm2/ucm.conf b/pkgs/additional/alsa-ucm-pinephone-manjaro/ucm2/ucm.conf similarity index 100% rename from hosts/common/programs/alsa-ucm-conf/ucm2/ucm.conf rename to pkgs/additional/alsa-ucm-pinephone-manjaro/ucm2/ucm.conf diff --git a/pkgs/default.nix b/pkgs/default.nix index 184fd0ea..518b3f0a 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -20,6 +20,7 @@ let sane-lib = import ../modules/lib final'; ### ADDITIONAL PACKAGES + alsa-ucm-pinephone-manjaro = callPackage ./additional/alsa-ucm-pinephone-manjaro { }; blast-ugjka = callPackage ./additional/blast-ugjka { }; bootpart-uefi-x86_64 = callPackage ./additional/bootpart-uefi-x86_64 { }; cargoDocsetHook = callPackage ./additional/cargo-docset/hook.nix { };