From 4aa3243c61e88467aac676ec17fe29d6eec040e0 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sat, 26 Jun 2021 02:00:53 +0200 Subject: dnyarri: Add identifiers for sound cards I already had this in my configuration.nix for quite some time and it's part of my overly complicated[TM] audio setup where I combine multiple speaker systems into one using two sound cards. Since the mapping depends on the individual channels, it's very much important to address the right sound card. So while I'm re-doing my whole audio setup, I decided to get at least the udev part out of my very messy configuration as a first start. Signed-off-by: aszlig --- machines/aszlig/dnyarri.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'machines') diff --git a/machines/aszlig/dnyarri.nix b/machines/aszlig/dnyarri.nix index 2e260507..48cde776 100644 --- a/machines/aszlig/dnyarri.nix +++ b/machines/aszlig/dnyarri.nix @@ -78,6 +78,18 @@ in { services.btrfs.autoScrub.enable = true; + # The machine has two identical sound cards, so let's give them stable + # identifiers because the device names assigned by the kernel are based on + # initialisation order. + services.udev.extraRules = let + mkRule = id: path: '' + ACTION=="add", DEVPATH=="${path}", SUBSYSTEM=="sound", ATTR{id}="${id}" + ''; + in lib.concatStrings (lib.mapAttrsToList mkRule { + lower = "/devices/pci0000:00/0000:00:03.1/0000:02:00.0/*/sound/card?*"; + upper = "/devices/pci0000:40/0000:40:01.1/0000:41:00.0/*/sound/card?*"; + }); + swapDevices = map ({ name, ... }: { device = "/dev/mapper/${name}"; }) cryptDevices.swap; -- cgit 1.4.1