diff options
author | Thomas Watson <twatson52@icloud.com> | 2023-12-22 22:12:43 -0600 |
---|---|---|
committer | Thomas Watson <twatson52@icloud.com> | 2023-12-22 22:12:43 -0600 |
commit | 77756b63cf0f7d3eb8fc5de92c90da239e64ddb2 (patch) | |
tree | b89c0a689a61ec10b5afc23dd15f2bb918c13906 /apple-silicon-support | |
parent | f42146573100d62c1ec341095f504eb48121f759 (diff) | |
download | nixlib-77756b63cf0f7d3eb8fc5de92c90da239e64ddb2.tar nixlib-77756b63cf0f7d3eb8fc5de92c90da239e64ddb2.tar.gz nixlib-77756b63cf0f7d3eb8fc5de92c90da239e64ddb2.tar.bz2 nixlib-77756b63cf0f7d3eb8fc5de92c90da239e64ddb2.tar.lz nixlib-77756b63cf0f7d3eb8fc5de92c90da239e64ddb2.tar.xz nixlib-77756b63cf0f7d3eb8fc5de92c90da239e64ddb2.tar.zst nixlib-77756b63cf0f7d3eb8fc5de92c90da239e64ddb2.zip |
modules/sound: update to enable speaker support
Diffstat (limited to 'apple-silicon-support')
-rw-r--r-- | apple-silicon-support/modules/sound/default.nix | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/apple-silicon-support/modules/sound/default.nix b/apple-silicon-support/modules/sound/default.nix index 5713f1aa18ec..6fc8d70d810c 100644 --- a/apple-silicon-support/modules/sound/default.nix +++ b/apple-silicon-support/modules/sound/default.nix @@ -1,20 +1,67 @@ { config, pkgs, lib, ... }: { + imports = [ + # disable pulseaudio as the Asahi sound infrastructure can't use it. + # if we disable it only if setupAsahiSound is enabled, then infinite + # recursion results as pulseaudio enables config.sound by default. + { config.hardware.pulseaudio.enable = false; } + ]; + options.hardware.asahi = { - setupAlsaUcm = lib.mkOption { + setupAsahiSound = lib.mkOption { type = lib.types.bool; default = config.sound.enable; description = '' - Enable the Asahi-specific ALSA UCM2 configs in the global environment - so that headphone jack input and output work properly. + Set up the Asahi DSP components so that the speakers and headphone jack + work properly and safely. ''; }; }; - config = lib.mkIf config.hardware.asahi.setupAlsaUcm { - environment.variables = { - ALSA_CONFIG_UCM2 = "${pkgs.alsa-ucm-conf-asahi}/share/alsa/ucm2"; + config = let + lsp-plugins = pkgs.lsp-plugins; # the lsp-plugins we use + + lsp-plugins-is-patched = (lsp-plugins.overrideAttrs (old: { + passthru = (old.passthru or {}) // { + lsp-plugins-is-patched = builtins.elem "58c3f985f009c84347fa91236f164a9e47aafa93.patch" + (builtins.map (p: p.name) (old.patches or [])); + }; + })).lsp-plugins-is-patched; + + # TODO: version check once a patched version comes out + lsp-plugins-is-safe = lsp-plugins-is-patched; + in lib.mkIf config.hardware.asahi.setupAsahiSound { + # set up pipewire with the supported capabilities (instead of pulseaudio) + services.pipewire = { + enable = true; + + alsa.enable = true; + wireplumber.enable = true; + pulse.enable = true; }; + + # enable speakersafetyd to protect speakers + systemd.packages = lib.mkAssert lsp-plugins-is-safe + "lsp-plugins is unpatched/outdated and speakers cannot be safely enabled" + [ pkgs.speakersafetyd ]; + services.udev.packages = [ pkgs.speakersafetyd ]; + + # set up enivronment so that asahi-audio data and UCM conf are used + environment.etc.asahi-audio = { + source = "${pkgs.asahi-audio}/share"; + target = ""; + }; + environment.variables.ALSA_CONFIG_UCM2 = "${pkgs.alsa-ucm-conf-asahi}/share/alsa/ucm2"; + + # set up pipewire and wireplumber to use asahi-audio configs and plugins + systemd.user.services.pipewire.environment.ALSA_CONFIG_UCM2 = config.environment.variables.ALSA_CONFIG_UCM2; + systemd.user.services.wireplumber.environment.ALSA_CONFIG_UCM2 = config.environment.variables.ALSA_CONFIG_UCM2; + systemd.user.services.pipewire.environment.LV2_PATH = let + lv2Plugins = [ lsp-plugins pkgs.bankstown-lv2 ]; + in lib.makeSearchPath "lib/lv2" lv2Plugins; + systemd.user.services.wireplumber.environment.LV2_PATH = let + lv2Plugins = [ lsp-plugins pkgs.bankstown-lv2 ]; + in lib.makeSearchPath "lib/lv2" lv2Plugins; }; } |