diff --git a/nixos/msi/configuration.nix b/nixos/msi/configuration.nix index b2bc79b..4ede3d5 100644 --- a/nixos/msi/configuration.nix +++ b/nixos/msi/configuration.nix @@ -23,8 +23,9 @@ in [ ./hardware-configuration.nix - ./nvidia.nix ./boot.nix + ./sound.nix + ./nvidia.nix ]; # Nix package installer settings @@ -83,19 +84,6 @@ in # Enable CUPS to print documents. # services.printing.enable = true; - # Enable sound. - security.rtkit.enable = true; - services.pipewire = { - enable = true; - audio.enable = true; - jack.enable = true; - pulse.enable = true; - alsa = { - enable = true; - support32Bit = true; - }; - }; - # Enable touchpad support (enabled default in most desktopManager). services.libinput.enable = true; diff --git a/nixos/msi/sound.nix b/nixos/msi/sound.nix new file mode 100644 index 0000000..52d210f --- /dev/null +++ b/nixos/msi/sound.nix @@ -0,0 +1,34 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = [ pkgs.alsa-utils ]; + + # ALSA provides a udev rule for restoring volume settings. + services.udev.packages = [ pkgs.alsa-utils ]; + + systemd.services.alsa-store = + { description = "Store Sound Card State"; + wantedBy = [ "multi-user.target" ]; + unitConfig.RequiresMountsFor = "/var/lib/alsa"; + unitConfig.ConditionVirtualization = "!systemd-nspawn"; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = "${pkgs.coreutils}/bin/mkdir -p /var/lib/alsa"; + ExecStop = "${pkgs.alsa-utils}/sbin/alsactl store --ignore"; + }; + }; + + security.rtkit.enable = true; + + services.pipewire = { + enable = true; + audio.enable = true; + jack.enable = true; + pulse.enable = true; + alsa = { + enable = true; + support32Bit = true; + }; + }; +}