Sound not working in newly installed NixOS

Hello, I am a beginner at NixOs, I installed the os a few hours ago but I noticed the sound is not working, after playing around typing some commands I found out my sound card isn’t being recognized by NixOS.

[santiago@nixos:~]$ nix-shell -p alsa-utils

[nix-shell:~]$ aplay -l
aplay: device_list:277: no soundcards found...

I would like some help to get this fixed please, my laptop is an Acer Aspire Lite 16.

Here is my configuration.nix file:

# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).

{ config, lib, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Bootloader
  boot.loader = {
    grub = {
      enable = true;
      useOSProber = false;
      device = "nodev";
      efiSupport = true;
    };
    efi.canTouchEfiVariables = true;
  };

  boot.loader.grub.extraEntries = ''

  menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-A0BB-A207' {
        insmod part_gpt
        insmod fat
        search --no-floppy --fs-uuid --set=root A0BB-A207
        chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
menuentry 'Arch Linux (on /dev/nvme0n1p5)' --class arch --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460' {
        insmod part_gpt
        insmod ext2
        search --no-floppy --fs-uuid --set=root 47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460
        linux /boot/vmlinuz-linux root=UUID=47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460 rw loglevel=3 quiet
        initrd /boot/initramfs-linux.img
}
submenu 'Advanced options for Arch Linux (on /dev/nvme0n1p5)' $menuentry_id_option 'osprober-gnulinux-advanced-47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460' {
        menuentry 'Arch Linux (on /dev/nvme0n1p5)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-linux--47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460' {
                insmod part_gpt
                insmod ext2
                search --no-floppy --fs-uuid --set=root 47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460
                linux /boot/vmlinuz-linux root=UUID=47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460 rw loglevel=3 quiet
                initrd /boot/initramfs-linux.img
        }
        menuentry 'Arch Linux, with Linux linux (on /dev/nvme0n1p5)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-linux--47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460' {
                insmod part_gpt
                insmod ext2
                search --no-floppy --fs-uuid --set=root 47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460
                linux /boot/vmlinuz-linux root=UUID=47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460 rw loglevel=3 quiet
                initrd /boot/initramfs-linux.img
        }
        menuentry 'Arch Linux, with Linux linux (fallback initramfs) (on /dev/nvme0n1p5)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-linux--47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460' {
                insmod part_gpt
                insmod ext2
                search --no-floppy --fs-uuid --set=root 47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460
                linux /boot/vmlinuz-linux root=UUID=47f6a5fd-9a2d-400b-a7ad-b0ea2ab7e460 rw loglevel=3 quiet
                initrd /boot/initramfs-linux-fallback.img
        }
}


  '';  

  networking.hostName = "nixos"; # Define your hostname.
  # Pick only one of the below networking options.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
  networking.networkmanager.enable = true;  # Easiest to use and most distros use this by default.

  # Set your time zone.
  time.timeZone = "America/Bogota";

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";
  # console = {
  #   font = "Lat2-Terminus16";
  #   keyMap = "us";
  #   useXkbConfig = true; # use xkb.options in tty.
  # };

  # Enable the X11 windowing system.
  services.xserver.enable = true;


  # Enable the GNOME Desktop Environment.
  services.displayManager.sddm.enable = true;
  services.desktopManager.plasma6.enable = true;
  

  # Configure keymap in X11
  services.xserver.xkb.layout = "us";
  # services.xserver.xkb.options = "eurosign:e,caps:escape";

  # Enable CUPS to print documents.
  # services.printing.enable = true;

  # Enable sound.
  # hardware.pulseaudio.enable = true;
  # OR

  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    pulse.enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    jack.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  services.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.santiago = {
    isNormalUser = true;
    extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
    packages = with pkgs; [

    ];
  };

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  nixpkgs.config.allowUnfree = true;
  environment.systemPackages = with pkgs; [
    vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
    wget
    firefox
    google-chrome
    tree
    vscode
    python3
    nodejs_22
  ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # Copy the NixOS configuration file and link it from the resulting system
  # (/run/current-system/configuration.nix). This is useful in case you
  # accidentally delete configuration.nix.
  # system.copySystemConfiguration = true;

  # This option defines the first version of NixOS you have installed on this particular machine,
  # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
  #
  # Most users should NEVER change this value after the initial install, for any reason,
  # even if you've upgraded your system to a new NixOS release.
  #
  # This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
  # so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
  # to actually do that.
  #
  # This value being lower than the current NixOS release does NOT mean your system is
  # out of date, out of support, or vulnerable.
  #
  # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
  # and migrated your data accordingly.
  #
  # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
  system.stateVersion = "24.05"; # Did you read the comment?

}

Thanks (:

Sadly no nixos-hardware entry for this laptop yet: nixos-hardware/acer at master · NixOS/nixos-hardware · GitHub

So we’ll have to play this the traditional way. Most likely your kernel is just too old for this device, and doesn’t have a driver for the soundcard yet. You can try to set boot.kernelPackages = pkgs.linuxKernel.packages.linux_latest, that might just solve it.

For more detailed debugging, we’ll need the output of dmesg -Tx, and potentially journalctl -x --boot, both will be easier to read after a fresh reboot.

1 Like

Okay, configuring Nixos to use the latest kernel definitely helped, the line you told me to add to configuration.nix didn’t work, instead I added this line that fixed my issue:

boot.kernelPackages = pkgs.linuxPackages_latest;

Thank you very much (:

The other option that’d work would be pkgs.linuxKernel.packageAliases.linux_latest (i.e. what pkgs.linuxPackages_latest points at)

Derp, well, in my defense, that name used to work for me, guess it changed recently.