From 0d015ac41801c70ace24856876d4a515c5a980ba Mon Sep 17 00:00:00 2001 From: Jordan Holt Date: Sun, 10 Dec 2023 19:45:31 +0000 Subject: [PATCH] Refactor sound card config --- hosts/odyssey/audio.nix | 45 ++++++++++++++++++++++++ hosts/odyssey/default.nix | 25 +------------ hosts/odyssey/hardware-configuration.nix | 11 +----- 3 files changed, 47 insertions(+), 34 deletions(-) create mode 100644 hosts/odyssey/audio.nix diff --git a/hosts/odyssey/audio.nix b/hosts/odyssey/audio.nix new file mode 100644 index 0000000..3b4c3ee --- /dev/null +++ b/hosts/odyssey/audio.nix @@ -0,0 +1,45 @@ +{ config, pkgs, ... }: +let + snd-usb-audio-module = pkgs.callPackage ./snd-usb-audio.nix { + kernel = config.boot.kernelPackages.kernel; + }; + upmixConfig = '' + stream.properties = { + channelmix.upmix = true + channelmix.upmix-method = psd + } + ''; +in { + boot.extraModulePackages = [ + (snd-usb-audio-module.overrideAttrs (_: { + patches = [ ./0001-Update-device-ID-for-PreSonus-1824c.patch ]; + })) + ]; + + environment.etc = { + "pipewire/pipewire.conf.d/surround.conf".text = '' + context.modules = [ + { + name = libpipewire-module-loopback + args = { + node.description = "Genelec 4.1 Surround" + capture.props = { + node.name = "Genelec_Speakers" + media.class = "Audio/Sink" + audio.position = [ FL FR SL SR LFE ] + } + playback.props = { + node.name = "playback.Genelec_Speakers" + audio.position = [ AUX0 AUX1 AUX3 AUX4 AUX5 ] + target.object = "alsa_output.usb-PreSonus_Studio_1824c_SC4E21110775-00.multichannel-output" + stream.dont-remix = true + node.passive = true + } + } + } + ] + ''; + "pipewire/pipewire-pulse.conf.d/40-upmix.conf".text = upmixConfig; + "pipewire/client-rt.conf.d/40-upmix.conf".text = upmixConfig; + }; + } diff --git a/hosts/odyssey/default.nix b/hosts/odyssey/default.nix index 2c99e59..775bd96 100644 --- a/hosts/odyssey/default.nix +++ b/hosts/odyssey/default.nix @@ -4,6 +4,7 @@ with lib.my; { imports = [ ./hardware-configuration.nix + ./audio.nix ../desktop.nix ]; @@ -16,32 +17,8 @@ with lib.my; networking.hostName = "odyssey"; networking.hostId = "c5e68d78"; - networking.networkmanager.enable = true; - environment.etc."pipewire/pipewire.conf.d/surround.conf".text = '' - context.modules = [ - { - name = libpipewire-module-loopback - args = { - node.description = "1824c Surround" - capture.props = { - node.name = "1824c_Speakers" - media.class = "Audio/Sink" - audio.position = [ FL FR SL SR LFE ] - } - playback.props = { - node.name = "playback.1824c_Speakers" - audio.position = [ AUX0 AUX1 AUX3 AUX4 AUX5 ] - target.object = "alsa_output.usb-PreSonus_Studio_1824c_SC4E21110775-00.multichannel-output" - stream.dont-remix = true - node.passive = true - } - } - } - ] - ''; - nix.package = pkgs.nixFlakes; nix.extraOptions = '' experimental-features = nix-command flakes diff --git a/hosts/odyssey/hardware-configuration.nix b/hosts/odyssey/hardware-configuration.nix index a2deb1e..d30c646 100644 --- a/hosts/odyssey/hardware-configuration.nix +++ b/hosts/odyssey/hardware-configuration.nix @@ -1,10 +1,6 @@ { config, lib, pkgs, modulesPath, ... }: -let - snd-usb-audio-module = pkgs.callPackage ./snd-usb-audio.nix { - kernel = config.boot.kernelPackages.kernel; - }; -in { +{ imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; @@ -13,11 +9,6 @@ in { boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-intel" ]; boot.kernelPackages = pkgs.linuxPackages; - boot.extraModulePackages = [ - (snd-usb-audio-module.overrideAttrs (_: { - patches = [ ./0001-Update-device-ID-for-PreSonus-1824c.patch ]; - })) - ]; boot.supportedFilesystems = [ "ntfs" ]; boot.binfmt.emulatedSystems = [ "aarch64-linux" ];