I use unstable NixOS and when upgrading the channel I had the following error:
The option definition sound in /etc/nixos/configuration.nix no longer has any effect; please remove it
Casued by
sound.enable = true;
I removed this option and then upgraded my system, but now every time I turn on my PC the speakers give off a popping sound. Is there some other option I could use to fix this?
Interesting. I’m by no means a sound expert, but that sounds like you’re actually somehow using alsa for sound instead of pipewire. Maybe you have some outdated config elsewhere, or some kind of legacy service that uses/enables alsa instead of using the pipewire emulation?
By the way, I moved to NixOS a couple of months ago and when I made my config from scratch I had the same problem until I added the sound.enable = true; option.
I was also having an issue with my audio after the removal of the option, though it wasn’t anything popping.
My mute-state light on my laptop keyboard was showing that sound was muted, however the system settings said otherwise. However I wasn’t able to actually hear any sound. Once I actually muted and unmuted the audio, the sound started working again. (I use playerctl for the media keys on the keyboard).
After adding this option, sound worked without needing to toggle the mute-state.
However I later realized that hardware.alsa.enablePersistence = true; does most of the things you included in the config snippet.
It may make sense to open an issue on the nixpkgs repo for this, it may have been overlooked. If you enable pipewire alsa support, the config options that would allow it to actually work properly should be enabled as well, or at least point the user in the right direction on how to enable them.
I didn’t have this issue (yet) but I’m anticipating something breaking. I’m glad you found a solution!
Cross posting for visibility (from the nixpkg repo issue):
I’m haven’t tried PipeWire yet, still using ALSA and PulseAudio, however after sound.enable was deprecated, I was having to go into alsamixer every time I rebooted my PC to unmute and turn volume up. hardware.alsa.enablePersistence = true; fixes this but every time I do a rebuild of NixOS I get this error:
warning: the following units failed: alsa-store.service
× alsa-store.service - Store Sound Card State
Loaded: loaded (/etc/systemd/system/alsa-store.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Sun 2024-08-11 11:37:38 EDT; 160ms ago
Invocation: 7abcdd93411644cebc0d394b82d35c08
Process: 48275 ExecStartPre=/nix/store/cnknp3yxfibxjhila0sjd1v3yglqssng-coreutils-9.5/bin/mkdir -p /var/lib/alsa (code=exited, status=0/SUCCESS)
Process: 48276 ExecStart=/nix/store/ci53xg2rsd2c73rhz9rf2nrdh7i73xdp-alsa-utils-1.2.10/sbin/alsactl restore --ignore (code=exited, status=99)
Main PID: 48276 (code=exited, status=99)
IP: 0B in, 0B out
Mem peak: 1.5M
CPU: 8ms
Aug 11 11:37:38 nixos alsactl[48276]: Hardware is initialized using a generic method
Aug 11 11:37:38 nixos alsactl[48276]: alsa-lib main.c:1554:(snd_use_case_mgr_open) error: failed to import hw:3 use case configuration -2
Aug 11 11:37:38 nixos alsactl[48276]: Found hardware: "VirMIDI" "" "" "" ""
Aug 11 11:37:38 nixos alsactl[48276]: Hardware is initialized using a generic method
Aug 11 11:37:38 nixos alsactl[48276]: alsa-lib main.c:1554:(snd_use_case_mgr_open) error: failed to import hw:10 use case configuration -2
Aug 11 11:37:38 nixos alsactl[48276]: Found hardware: "Loopback" "Loopback Mixer" "" "" ""
Aug 11 11:37:38 nixos alsactl[48276]: Hardware is initialized using a generic method
Aug 11 11:37:38 nixos systemd[1]: alsa-store.service: Main process exited, code=exited, status=99/n/a
Aug 11 11:37:38 nixos systemd[1]: alsa-store.service: Failed with result 'exit-code'.
Aug 11 11:37:38 nixos systemd[1]: Failed to start Store Sound Card State.
EDIT: Well, I’ve switched over to PipeWire and so far so good. Audio levels persist after reboot.