Trying to get sound working on NixOS

When following this guide Linux distro-specific Configuration | Chrultrabook Docs everything seems to work until i get to

Audio setup (Does the same as the audio script)

  • I change the generation to cml since i have a Dragonair hp x360 chromebook 14c and it takes hours to compile and then errors out at the end. All that to get sound working and it never works.

Is there something easier ? when i don’t go this route I can get pipewire working but the microphone dosen’t work via headphones and regular speakers. Anything i can do to get this working. I really like NixOS

I’m currently working on it. I’ve successfully add ucm configs into the system but found it didn’t work, then I checked the audio script on Github. It looks there’s something more to do. Basicly, just adding some firmware files and config files into nixpkgs. I’ll post an HOWTO guide if I get things work.

If you wonder why there’s so much compiling work to do: add overlays to nixpkgs would turn out change the hash of the package, then hashes of those packages depends on it would change as follows. If hash changes, caches couldn’t be matched (cause hash is the only way cache could be hit). As a result, you’ll get a system that EVERYTHING HAS TO BE COMPILED by yourself… XD

If NixOS supports systemd-sysext then you can add audio configs to a systemd-sysext externsion. This way works on Fedora Silverblue.

Would be nice. I took nixos off the Chromebook till i get or find replies like you guys are doing till there is a solution. I really like nixos but sound is a must. I’m always watching YouTube videos with the kids.

Thanks all for helping out

I was afraid of that. I was really let down when it compiled for 4 hours and errored out at the end. I kept telling my wife almost almost lol

NixOS seems interesting. I feel like distro-hopping to NixOS now. Maybe I’ll create a proper NixOS package for Chromebook audio.

Actually NixOS seems too confusing to use compared to Fedora Silverblue.

1 Like

Looks like systemd-sysext is installed on NixOS, but the service to enable it automatically isn’t.

lol

ok, here’s the problem:
i’ve managed to translate what this script does into nix configuration, i do it for my own model (pixelbook go with model name atlas).

it supposed to work, actually it did. but nixos kernel seems lack of something that allows the firmware loaded correctly.

i try to set modprobe like this:

boot.extraModprobeConfig = ''
  options snd-intel-dspcfg dsp_driver=3
'';

it just couldn’t load the firmware, i don’t know why…

any idea plz? @WeirdTreeThing

pixelbook go does not use sof (3) but instead uses avs (4)

same, doesn’t work

edit: i just found another attempt to add custom firmware into nixos, surprisingly, this guy also trying to get a chromebook audio to work. i checked his nix files, didn’t see much difference.

this is my dmesg | grep avs:

there’s something more I clipped from dmesg:

it’s quite confusing to see the line of BUG: unable to handle page fault for address: ffff9f14c02c1d70 , btw the kernel version I am currently using is 6.7.6

I got a somewhat similar problem on BANSHEE (kernel 6.7.7). I used a modified version of your NixOS config for adl and the microphone seems to be detected, but it always seems to have 50% volume output on pavucontrol and doesn’t detect my voice.

I tried to debug it by installing another OS (Manjaro) to my laptop and running @WeirdTreeThing upstream script and unfortunately it doesn’t solve the problem. My guess is perhaps the hardware itself isn’t supported at the moment.

I did have audio working on NixOS on my dragonair at some point with just this, but it stopped working when alsa-ucm-conf updated from 1.2.9. I’m trying to get it running without having to recompile by doing:

  environment = {
    systemPackages = with pkgs; [ maliit-keyboard ];
    sessionVariables.ALSA_CONFIG_UCM2 = let
      cml-ucm-conf = pkgs.alsa-ucm-conf.overrideAttrs {
        wttsrc = pkgs.fetchurl {
          url =
            "https://github.com/WeirdTreeThing/chromebook-ucm-conf/archive/2b2f3a7c993fd38a24aa81394e29ee530b890658.tar.gz";
          hash = "sha256-WeLkxWB174Hwb11xnIxsvRm5NpM528IVEYH4K32pLwg=";
        };
        unpackPhase = ''
          runHook preUnpack
          tar xf "$src"
          tar xf "$wttsrc"
          runHook postUnpack
        '';
        installPhase = ''
          runHook preInstall
          mkdir -p $out/share/alsa
          cp -r alsa-ucm*/{ucm,ucm2} $out/share/alsa
          cp -r chromebook-ucm*/common $out/share/alsa/ucm2/common
          cp -r chromebook-ucm*/codecs $out/share/alsa/ucm2/codecs
          cp -r chromebook-ucm*/platforms $out/share/alsa/ucm2/platforms
          cp -r chromebook-ucm*/sof-rt5682 $out/share/alsa/ucm2/conf.d/sof-rt5682
          cp -r chromebook-ucm*/sof-cs42l42 $out/share/alsa/ucm2/conf.d/sof-cs42l42
          cp -r chromebook-ucm*/cml/* $out/share/alsa/ucm2/conf.d
          runHook postInstall
        '';
      };
    in "${cml-ucm-conf}/share/alsa/ucm2";
  };

But it’s not working.

See relevant thread on NixOS discourse.

I could make it work Only by choosing LATEST Linux Mint/Ubuntu/Linux Lite [Surprisingly, Not even gallium OS worked in my case] as the distro fixed my problem
all that was left was Mic and Aux Which has following workaround

I had similar problem with my linux mint and was solved by :

THEY ARE INSTRUCTIONS AND THIS IS NOT A SCRIPT FILE AND DONOT RUN THIS

to fix trackpad (restart after doing this)

sudo apt-get purge xserver-xorg-input-synaptics
sudo apt install gedit
sudo gedit /etc/pulse/default.pa

search for line “.ifexists module-udev-detect.so”

type arecord -l

dmic something must be mic it will look like this

**** List of CAPTURE Hardware Devices ****
card 0: sofglkrt5682max [sof-glkrt5682max], device 1: Headset () []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: sofglkrt5682max [sof-glkrt5682max], device 99: DMIC (
)
Subdevices: 1/1
Subdevice #0: subdevice #0

note the card no. and device no. (0 and 99 in this case)
add the line “load-module module-alsa-source device=hw:x,y” BEFORE “.ifexists module-udev-detect.so”
run this
pulseaudio -k ; pulseaudio -D

This is to fix AUX

(make a script of following text and run it as root) :

#!/bin/bash

echo Adding microphone to Pulseaudio

grep -qxF ‘load-module module-alsa-source device=hw:0,99’ /etc/pulse/default.pa || echo ‘load-module module-alsa-source device=hw:0,99’ >> /etc/pulse/default.pa

echo Adding headphone to Pulseaudio

grep -qxF ‘load-module module-alsa-sink device=hw:0,1’ /etc/pulse/default.pa || echo ‘load-module module-alsa-sink device=hw:0,1’ >> /etc/pulse/default.pa

echo Adding headset microphone to Pulseaudio

grep -qxF ‘load-module module-alsa-source device=hw:0,1’ /etc/pulse/default.pa || echo ‘load-module module-alsa-source device=hw:0,1’ >> /etc/pulse/default.pa

echo Restarting Pulseaudio

killall pulseaudio

echo Configuring headphone/headset mixer

amixer cset name=‘Playback Digital Volume’ 111
amixer cset name=‘Playback Digital Switch’ 1
amixer cset name=‘Out DACL Mux’ DAIL
amixer cset name=‘Out DACR Mux’ DAIR
amixer cset name=‘Mixer Out FilterL DACL Switch’ 1
amixer cset name=‘Mixer Out FilterR DACR Switch’ 1
amixer cset name=‘ST Mixer Out FilterL Out FilterL Switch’ 1
amixer cset name=‘ST Mixer Out FilterR Out FilterR Switch’ 1
amixer cset name=‘Headphone Jack Switch’ on
amixer cset name=‘Headset Mic Switch’ on
amixer cset name=‘Mic Volume’ 5
amixer cset name=‘Capture Digital Volume’ 111
amixer cset name=‘Capture Digital Switch’ 1
amixer cset name=‘Mixin Volume’ 10
amixer cset name=‘Mixin Switch’ 1
amixer cset name=‘Mixer In Mic Switch’ 1
amixer cset name=‘Out DAIL Mux’ ADC
amixer cset name=‘Out DAIR Mux’ ADC
amixer cset name=‘Pin5-Port0 Mux’ 1
amixer cset name=‘Pin5-Port1 Mux’ 1
amixer cset name=‘Pin5-Port2 Mux’ 1
amixer cset name=‘Pin6-Port0 Mux’ 2
amixer cset name=‘Pin6-Port1 Mux’ 2
amixer cset name=‘Pin6-Port2 Mux’ 2
amixer cset name=‘Gain Ramp Rate’ 1

now if it did not fix aux run these without root privileges :
amixer cset name=‘Headphone Jack Switch’ on
amixer cset name=‘Headset Mic Switch’ on

Can we PLEASE stop with the hacky pulseaudio config modifications.

Also this is not even related to NixOS.