about summary refs log tree commit diff
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2021-06-26 02:00:53 +0200
committeraszlig <aszlig@nix.build>2021-06-26 02:09:28 +0200
commit4aa3243c61e88467aac676ec17fe29d6eec040e0 (patch)
tree6e65b75c2dd8abfbd5a6da15d444ccf09a9a38f2
parente8f2190048e98b98c7d47479a44448ee6297dd10 (diff)
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 <aszlig@nix.build>
-rw-r--r--machines/aszlig/dnyarri.nix12
1 files changed, 12 insertions, 0 deletions
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;