From d94aa36f1e49ed38a48c7270d4b5a198744a7dcb Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 22 Sep 2013 21:31:38 +0200 Subject: [PATCH] Fix saving the ALSA sound card state This didn't work reliably because it raced with the remounting of /. So if you were unlucky, then / was read-only by the time we ran "alsactl store". Now the sound card state is saved before anything is unmounted/remounted. --- modules/services/audio/alsa.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/services/audio/alsa.nix b/modules/services/audio/alsa.nix index ed08c653f3a..6c53ef46ab9 100644 --- a/modules/services/audio/alsa.nix +++ b/modules/services/audio/alsa.nix @@ -52,12 +52,14 @@ in 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"; - serviceConfig.ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p /var/lib/alsa"; + wantedBy = [ "multi-user.target" ]; + unitConfig.RequiresMountsFor = "/var/lib/alsa"; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = "${pkgs.coreutils}/bin/mkdir -p /var/lib/alsa"; + ExecStop = "${alsaUtils}/sbin/alsactl store --ignore"; + }; }; };