Can't control volume, either 100% or 0%

Hi, I’m kindly looking for help here.
I just installed nixos on a Minisforum V3, all is working fine except for volume controls.

I can see the volume slider going up and down, but as soon as the computer is not muted it goes very loud and the volume output doesn’t change at all. I’ve tried to move the slider manually through the settings but it is the same result.

The only volume configuration that I have is the default pipewire:

  # Enable sound with pipewire.
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

This is my config: https://github.com/ferrumboll/nixos-system/blob/fe7403ae1357e78ebf2e5b569e0203d27b9ce4ff/nixos/configuration.nix

and you can see the other files in the repo, but the only one with sound configuration is that file.

Can I please get some help?

Kind of a shot in the dark, but have you tried jack.enable = true; ?

(as in uncommenting it)

What do you get when you run the following command?

wpctl get-volume @DEFAULT_AUDIO_SINK@

On that note, what Desktop Environment/WM are you using?

Piggy backing on this as my issue is exactly the same.

For me the wpctl command gives a number between 0 and 1 based on where the slider is.

I’m was on KDE and switched to Gnome hoping it would fix it.

Youtube volume and application volume level controls do work for me. Just not the master slider.

EDIT:

wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.005

Tried out this command it seems to set the audio to 50%!
0.01 is acting as 100%

Same as tucker87, gives me a number between 0 and 100.

This command

wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.005

did also work for me actually!, but how could we fix that? It seems anything after 0.01 is irrelevant because it already is 100%.

I’m using GNOME as my desktop environment.

This indicates that the issue is in communication of the audio levels supported by the hardware. What in-built sound card is being used on both of your systems? @tucker87 @pxlf

What does sudo lspci -k show?

Try this too: Can't get alsa + nixos working - #2 by oxij

lspci -k shows the following:

00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14e8
	Subsystem: Device 1f4c:e001
00:00.2 IOMMU: Advanced Micro Devices, Inc. [AMD] Device 14e9
	Subsystem: Device 1f4c:e001
00:01.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14ea
00:02.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14ea
00:02.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14ee
	Subsystem: Device 1f4c:e001
	Kernel driver in use: pcieport
00:02.3 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14ee
	Subsystem: Device 1f4c:e001
	Kernel driver in use: pcieport
00:02.4 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14ee
	Subsystem: Device 1f4c:e001
	Kernel driver in use: pcieport
00:03.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14ea
00:03.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 19h USB4/Thunderbolt PCIe tunnel
	Subsystem: Device 1f4c:e001
	Kernel driver in use: pcieport
00:04.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14ea
00:04.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 19h USB4/Thunderbolt PCIe tunnel
	Subsystem: Device 1f4c:e001
	Kernel driver in use: pcieport
00:08.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14ea
00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14eb
	Subsystem: Device 1f4c:e001
	Kernel driver in use: pcieport
00:08.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14eb
	Subsystem: Device 1f4c:e001
	Kernel driver in use: pcieport
00:08.3 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 14eb
pcilib: Error reading /sys/bus/pci/devices/0000:00:08.3/label: Operation not permitted
	Subsystem: Device 1f4c:e001
	Kernel driver in use: pcieport
00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller (rev 71)
	Subsystem: Device 1f4c:e001
	Kernel driver in use: piix4_smbus
	Kernel modules: i2c_piix4, sp5100_tco
00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge (rev 51)
	Subsystem: Device 1f4c:e001
00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14f0
00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14f1
00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14f2
00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14f3
	Kernel driver in use: k10temp
	Kernel modules: k10temp
00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14f4
00:18.5 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14f5
00:18.6 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14f6
00:18.7 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 14f7
01:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS525A PCI Express Card Reader (rev 01)
	Subsystem: Realtek Semiconductor Co., Ltd. RTS525A PCI Express Card Reader
	Kernel driver in use: rtsx_pci
	Kernel modules: rtsx_pci
02:00.0 Network controller: Intel Corporation Wi-Fi 6E(802.11ax) AX210/AX1675* 2x2 [Typhoon Peak] (rev 1a)
	Subsystem: Intel Corporation Wi-Fi 6 AX210 160MHz
	Kernel driver in use: iwlwifi
	Kernel modules: iwlwifi
03:00.0 Non-Volatile memory controller: Kingston Technology Company, Inc. OM8PGP4 NVMe PCIe SSD (DRAM-less)
	Subsystem: Kingston Technology Company, Inc. OM8PGP4 NVMe PCIe SSD (DRAM-less)
	Kernel driver in use: nvme
	Kernel modules: nvme
c4:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Phoenix3 (rev 01)
	Subsystem: Device 1f4c:e001
	Kernel driver in use: amdgpu
	Kernel modules: amdgpu
c4:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Rembrandt Radeon High Definition Audio Controller
	Subsystem: Device 1f4c:e001
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel
c4:00.2 Encryption controller: Advanced Micro Devices, Inc. [AMD] Family 19h (Model 74h) CCP/PSP 3.0 Device
	Subsystem: Device 1f4c:e001
	Kernel driver in use: ccp
	Kernel modules: ccp
c4:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15b9
	Subsystem: Device 1f4c:e001
	Kernel driver in use: xhci_hcd
	Kernel modules: xhci_pci
c4:00.4 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15ba
	Subsystem: Device 1f4c:e001
	Kernel driver in use: xhci_hcd
	Kernel modules: xhci_pci
c4:00.5 Multimedia controller: Advanced Micro Devices, Inc. [AMD] ACP/ACP3X/ACP6x Audio Coprocessor (rev 63)
	Subsystem: Device 1f4c:e001
	Kernel driver in use: snd_pci_ps
	Kernel modules: snd_pci_acp3x, snd_rn_pci_acp3x, snd_pci_acp5x, snd_pci_acp6x, snd_acp_pci, snd_rpl_pci_acp6x, snd_pci_ps, snd_sof_amd_renoir, snd_sof_amd_rembrandt, snd_sof_amd_vangogh
c4:00.6 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h/19h HD Audio Controller
	DeviceName: Realtek ALC256
	Subsystem: Device 1f4c:e001
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel
c4:00.7 Signal processing controller: Advanced Micro Devices, Inc. [AMD] Device 164a
	Subsystem: Advanced Micro Devices, Inc. [AMD] Device 164a
	Kernel driver in use: pcie_mp2_amd
	Kernel modules: amd_sfh
c5:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device 14ec
	Subsystem: Device 1f4c:e001
c5:00.1 Signal processing controller: Advanced Micro Devices, Inc. [AMD] AMD IPU Device
	Subsystem: Device 1f4c:e001
c6:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Device 14ec
	Subsystem: Device 1f4c:e001
c6:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15c0
	Subsystem: Device 1f4c:e001
	Kernel driver in use: xhci_hcd
	Kernel modules: xhci_pci
c6:00.4 USB controller: Advanced Micro Devices, Inc. [AMD] Device 15c1
	Subsystem: Device 1f4c:e001
	Kernel driver in use: xhci_hcd
	Kernel modules: xhci_pci
c6:00.5 USB controller: Advanced Micro Devices, Inc. [AMD] Pink Sardine USB4/Thunderbolt NHI controller #1
	Subsystem: Device 1f4c:e001
	Kernel driver in use: thunderbolt
	Kernel modules: thunderbolt
c6:00.6 USB controller: Advanced Micro Devices, Inc. [AMD] Pink Sardine USB4/Thunderbolt NHI controller #2
	Subsystem: Device 1f4c:e001
	Kernel driver in use: thunderbolt
	Kernel modules: thunderbolt

I can’t get NixOS to build with alsa only as sound.enable = true seems to be deprecated, I did try to turn the sound off altogether and create the /etc/asound.conf file, but it did not work.

my aplay -l looks like this: I tried with both options.

**** List of PLAYBACK Hardware Devices ****
card 0: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 0: ALC245 Analog [ALC245 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I have looked at the output of lspci -k. Other than the AMD sound card using snd_hda_intel kernel module, I don’t know what else is “weird” about it. I don’t have an AMD system so can’t speak to it if it’s normal or not.

In which case, can you try out the steps mentioned in the post that I’ve linked in the message I’m replying to?

[nix-shell:~]$ lspci -k | grep Audio -A3
00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21)
	Subsystem: ASUSTeK Computer Inc. Device 1b00
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel, snd_soc_skl, snd_soc_avs, snd_sof_pci_intel_skl

I’m a little unclear on what to try from that post. As one of the last comments even mentions that I “Should be using pipewire” which I am.

[nix-shell:~]$ nix-env -p alsa-utils
[nix-shell:~]$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC295 Analog [ALC295 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

[nix-shell:~]$ cat /etc/asound.conf
cat: /etc/asound.conf: No such file or directory

[nix-shell:~]$ arecord -f cd - | aplay -f cd -
Recording WAVE '-' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Playing WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
^CAborted by signal Interrupt...
Aborted by signal Interrupt...
aplay: pcm_write:2178: write error: Interrupted system call

[nix-shell:~]$ alsamixer

I got no sounds from the arecord|aplay. But alsamixer does update as I change my UI.

Well, I’m out of ideas!

I just went on a giant goose chase when I saw that channelmix.max-volume defaults to 10. So I thought maybe setting it to 1 should compress the volume down to 10%.

I ended up with this config but the only effect is that anything over 0.01 is now 50%. So at least I can’t blow my ears out anymore…

    wireplumber.extraConfig = {
      "wh-1000xm3-ldac-hq" = {
        "monitor.alsa.rules" = [{
          matches =
            [{ "node.name" = "alsa_output.pci-0000_00_1f.3.analog-stereo"; }];
          actions = {
            update-props = {
              "node.description" = "Laptop Speakers";
              "node.nick" = "Laptop Speakers";
              "channelmix.max-volume" = 0.5;
            };
          };
        }];
      };

@thefossguy I tried what I could, it seems that post is a little old so things like sound.enable = true is now deprecated. but I tried to follow the steps as closely as I could and nothing unfortunately.

@tucker87 I did find something that might help you: nixos-hardware/minisforum/v3 at master · NixOS/nixos-hardware · GitHub

I tried adding the module to my configuration, but in my case the volume stops working altogether. Maybe it works for you. For now I think I’ll do the same and limit it to 50%.

I also got no audio with that package.

After poking around a bit I found a fix from 2012

This is 100% my problem. The PCM controls my audio.

I found where someone tried to fix this with a post build script but he hadn’t had any luck.

I made an audio.nix based on this but I’m not able to figure it out.

The pipewire-patch-with-pcm-control package is there and it has the Element Master section added to it.

services.pipewire.package = pipewire_hacked; was the last thing I tried. The old one had hardware.pulseaudio.package but there’s no hardware.pipewire

EDIT: I really thought I had it when I saw someone else feeding the modified pipewire into wireplumber!

{ pkgs, lib, ... }:

let
  pipewire' = pkgs.pipewire.overrideAttrs (old: {
    # name = "pulseaudio-patched";
    pname = "${old.pname}-patched-with-pcm-control";
    # Instead of overriding some post-build action, which would require a
    # pulseaudio rebuild, we override the entire `buildCommand` to produce
    # its outputs by copying the original package's files (much faster).
    buildCommand = ''
      set -euo pipefail

      ${ # Copy original files, for each split-output (`out`, `dev` etc.).
      lib.concatStringsSep "\n" (map (outputName: ''
        echo "Copying output ${outputName}"
        set -x
        cp -a ${pkgs.pipewire.${outputName}} ''$${outputName}
        set +x
      '') old.outputs)}
        
      # Find this file: /nix/store/vr4mv8jppbvr96ml2chlgikmy6f9crb7-pipewire-0.3.80-lib/share/alsa-card-profile/mixer/paths/analog-output.conf.common 
      #   and add these three lines:
      # 
      #   [Element Master]
      #   switch = mute
      #   volume = ignore
      # 
      # Directly above of this part of code:
      # 
      #   [Element PCM]
      #   switch = mute
      #   volume = merge
      #   override-map.1 = all
      #   override-map.2 = all-left,all-right
      set -x
      INFILE=$out/share/alsa-card-profile/mixer/paths/analog-output.conf.common
      sed 's/\[Element PCM\]/\[Element Master\]\nswitch = mute\nvolume = ignore\n\n[Element PCM]/' $INFILE > tmp.conf
      # Ensure file changed (something was replaced)
      ! cmp tmp.conf $INFILE
      chmod +w $out/share/alsa-card-profile/mixer/paths/analog-output.conf.common
      cp tmp.conf $INFILE
      set +x
    '';
  });
  wireplumber' = (pkgs.wireplumber.override { pipewire = pipewire'; });
in {

  # Enable sound with pipewire.
  security.rtkit.enable = true;
  hardware.pulseaudio.enable = false;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    #jack.enabule = true;
    package = pipewire';
    wireplumber.package = wireplumber';

  };

  environment.systemPackages = [ pkgs.alsa-utils ];
}

I can’t help with your current approach with pipewire, as you’ve seen that my efforts didn’t lead anywhere unfortunately. However, I can say that the fix for pulseaudio just worked, so that would be my 2 cents, if that’s no problem for you.
For me, the problem was eventually resolved with a new kernel version that fixed the hardware/driver issue.

No luck getting the pulseaudio version to work :frowning:

audio.nix

{ pkgs, lib, ... }:
let
  pulseaudio' = pkgs.pulseaudio.overrideAttrs (old: {
    pname = "${old.pname}-patched-with-pcm-control";
    # Instead of overriding some post-build action, which would require a
    # pulseaudio rebuild, we override the entire `buildCommand` to produce
    # its outputs by copying the original package's files (much faster).
    buildCommand = ''
      set -euo pipefail

      ${ # Copy original files, for each split-output (`out`, `dev` etc.).
      lib.concatStringsSep "\n" (map (outputName: ''
        echo "Copying output ${outputName}"
        set -x
        cp -a ${pkgs.pulseaudio.${outputName}} ''$${outputName}
        set +x
      '') old.outputs)}

      # Find this file: share/pulseaudio/alsa-mixer/paths/analog-output.conf.common
      #   and add these three lines:
      # 
      #   [Element Master]
      #   switch = mute
      #   volume = ignore
      # 
      # Directly above of this part of code:
      # 
      #   [Element PCM]
      #   switch = mute
      #   volume = merge
      #   override-map.1 = all
      #   override-map.2 = all-left,all-right

      set -x
      INFILE=$out/share/pulseaudio/alsa-mixer/paths/analog-output.conf.common
      sed 's/\[Element PCM\]/\[Element Master\]\nswitch = mute\nvolume = ignore\n\n[Element PCM]/' $INFILE > tmp.conf
      # Ensure file changed (something was replaced)
      ! cmp tmp.conf $INFILE
      chmod +w $out/share/pulseaudio/alsa-mixer/paths/analog-output.conf.common
      cp tmp.conf $INFILE
      set +x
    '';
  });
in {
  hardware.pulseaudio.enable = true;
  hardware.pulseaudio.support32Bit = true;
  hardware.pulseaudio.package = pulseaudio';
  services.pipewire.enable = lib.mkForce false;

  environment.systemPackages = [ pkgs.alsa-utils ];

}