diff --git a/modules/services/audio/alsa.nix b/modules/services/audio/alsa.nix index fa63bc74cfc5..ff08f21a4857 100644 --- a/modules/services/audio/alsa.nix +++ b/modules/services/audio/alsa.nix @@ -45,29 +45,19 @@ in environment.systemPackages = [ alsaUtils ]; + # ALSA provides a udev rule for restoring volume settings. + services.udev.packages = [ alsaUtils ]; + boot.kernelModules = optional config.sound.enableOSSEmulation "snd_pcm_oss"; - jobs.alsa = - { description = "ALSA Volume Settings"; - - startOn = "stopped udevtrigger"; - - preStart = - '' - mkdir -m 0755 -p $(dirname ${soundState}) - - # Try to restore the sound state. - ${alsaUtils}/sbin/alsactl --ignore init || true - ${alsaUtils}/sbin/alsactl --ignore -f ${soundState} restore || true - ''; - - postStop = - '' - # Save the sound state. - ${alsaUtils}/sbin/alsactl --ignore -f ${soundState} store - ''; + boot.systemd.services."alsa-store" = + { description = "Store Sound Card State"; + wantedBy = [ "shutdown.target" ]; + before = [ "shutdown.target" ]; + unitConfig.DefaultDependencies = "no"; + serviceConfig.Type = "oneshot"; + serviceConfig.ExecStart = "${alsaUtils}/sbin/alsactl store --ignore"; }; - }; }