nixos/alsa: kill sound.enable and friends with fire

K900 3eeff547 16007071

+1 -2
nixos/doc/manual/configuration/profiles/headless.section.md
···
Common configuration for headless machines (e.g., Amazon EC2 instances).
-
Disables [sound](#opt-sound.enable),
-
[vesa](#opt-boot.vesa), serial consoles,
+
Disables [vesa](#opt-boot.vesa), serial consoles,
[emergency mode](#opt-systemd.enableEmergencyMode),
[grub splash images](#opt-boot.loader.grub.splashImage)
and configures the kernel to reboot automatically on panic.
+1 -2
nixos/doc/manual/configuration/profiles/minimal.section.md
···
[noXlibs](#opt-environment.noXlibs), sets
[](#opt-i18n.supportedLocales) to
only support the user-selected locale,
-
[disables packages' documentation](#opt-documentation.enable),
-
and [disables sound](#opt-sound.enable).
+
and [disables packages' documentation](#opt-documentation.enable).
+45
nixos/doc/manual/release-notes/rl-2411.section.md
···
- `services.roundcube.maxAttachmentSize` will multiply the value set with `1.37` to offset overhead introduced by the base64 encoding applied to attachments.
+
- The `sound` options have been removed or renamed, as they had a lot of unintended side effects. See [below](#sec-release-24.11-migration-sound) for details.
+
- The `services.mxisd` module has been removed as both [mxisd](https://github.com/kamax-matrix/mxisd) and [ma1sd](https://github.com/ma1uta/ma1sd) are not maintained any longer.
Consequently the package `pkgs.ma1sd` has also been removed.
···
should be changed to using *runner authentication tokens* by configuring
{option}`services.gitlab-runner.services.<name>.authenticationTokenConfigFile` instead of the former
{option}`services.gitlab-runner.services.<name>.registrationConfigFile` option.
+
+
## Detailed migration information {#sec-release-24.11-migration}
+
+
### `sound` options removal {#sec-release-24.11-migration-sound}
+
+
The `sound` options have been largely removed, as they are unnecessary for most modern setups, and cause issues when enabled.
+
+
If you set `sound.enable` in your configuration:
+
- If you are using Pulseaudio or PipeWire, simply remove that option
+
- If you are not using an external sound server, and want volumes to be persisted across shutdowns, set `hardware.alsa.enablePersistence = true` instead
+
+
If you set `sound.enableOSSEmulation` in your configuration:
+
- Make sure it is still necessary, as very few applications actually use OSS
+
- If necessary, set `boot.kernelModules = [ "snd_pcm_oss" ]`
+
+
If you set `sound.extraConfig` in your configuration:
+
- If you are using another sound server, like Pulseaudio, JACK or PipeWire, migrate your configuration to that
+
- If you are not using an external sound server, set `environment.etc."asound.conf".text = yourExtraConfig` instead
+
+
If you set `sound.mediaKeys` in your configuration:
+
- Preferably switch to handling media keys in your desktop environment/compositor
+
- If you want to maintain the exact behavior of the option, use the following snippet
+
+
```nix
+
services.actkbd = let
+
volumeStep = "1%";
+
in {
+
enable = true;
+
bindings = [
+
# "Mute" media key
+
{ keys = [ 113 ]; events = [ "key" ]; command = "${alsa-utils}/bin/amixer -q set Master toggle"; }
+
+
# "Lower Volume" media key
+
{ keys = [ 114 ]; events = [ "key" "rep" ]; command = "${alsa-utils}/bin/amixer -q set Master ${volumeStep}- unmute"; }
+
+
# "Raise Volume" media key
+
{ keys = [ 115 ]; events = [ "key" "rep" ]; command = "${alsa-utils}/bin/amixer -q set Master ${volumeStep}+ unmute"; }
+
+
# "Mic Mute" media key
+
{ keys = [ 190 ]; events = [ "key" ]; command = "${alsa-utils}/bin/amixer -q set Capture toggle"; }
+
];
+
};
+
```
+3 -7
nixos/modules/config/pulseaudio.nix
···
let
cfg = config.hardware.pulseaudio;
-
alsaCfg = config.sound;
hasZeroconf = let z = cfg.zeroconf; in z.publish.enable || z.discovery.enable;
···
# Write an /etc/asound.conf that causes all ALSA applications to
# be re-routed to the PulseAudio server through ALSA's Pulse
# plugin.
-
alsaConf = writeText "asound.conf" (''
+
alsaConf = ''
pcm_type.pulse {
libs.native = ${pkgs.alsa-plugins}/lib/alsa-lib/libasound_module_pcm_pulse.so ;
${lib.optionalString enable32BitAlsaPlugins
···
ctl.!default {
type pulse
}
-
${alsaCfg.extraConfig}
-
'');
+
'';
in {
···
environment.systemPackages = [ overriddenPackage ];
-
sound.enable = true;
-
environment.etc = {
-
"asound.conf".source = alsaConf;
+
"alsa/conf.d/99-pulseaudio.conf".text = alsaConf;
"pulse/daemon.conf".source = writeText "daemon.conf"
(lib.generators.toKeyValue {} cfg.daemon.config);
+22 -116
nixos/modules/services/audio/alsa.nix
···
with lib;
-
let
-
-
inherit (pkgs) alsa-utils;
-
-
pulseaudioEnabled = config.hardware.pulseaudio.enable;
-
-
in
-
{
imports = [
-
(mkRenamedOptionModule [ "sound" "enableMediaKeys" ] [ "sound" "mediaKeys" "enable" ])
+
(mkRemovedOptionModule [ "sound" ] "The option was heavily overloaded and can be removed from most configurations.")
];
-
###### interface
-
-
options = {
-
-
sound = {
-
-
enable = mkOption {
-
type = types.bool;
-
default = false;
-
description = ''
-
Whether to enable ALSA sound.
-
'';
-
};
-
-
enableOSSEmulation = mkOption {
-
type = types.bool;
-
default = false;
-
description = ''
-
Whether to enable ALSA OSS emulation (with certain cards sound mixing may not work!).
-
'';
-
};
-
-
extraConfig = mkOption {
-
type = types.lines;
-
default = "";
-
example = ''
-
defaults.pcm.!card 3
-
'';
-
description = ''
-
Set addition configuration for system-wide alsa.
-
'';
-
};
-
-
mediaKeys = {
-
-
enable = mkOption {
-
type = types.bool;
-
default = false;
-
description = ''
-
Whether to enable volume and capture control with keyboard media keys.
-
-
You want to leave this disabled if you run a desktop environment
-
like KDE, Gnome, Xfce, etc, as those handle such things themselves.
-
You might want to enable this if you run a minimalistic desktop
-
environment or work from bare linux ttys/framebuffers.
-
-
Enabling this will turn on {option}`services.actkbd`.
-
'';
-
};
-
-
volumeStep = mkOption {
-
type = types.str;
-
default = "1";
-
example = "1%";
-
description = ''
-
The value by which to increment/decrement volume on media keys.
-
-
See amixer(1) for allowed values.
-
'';
-
};
-
-
};
-
-
};
-
+
options.hardware.alsa.enablePersistence = mkOption {
+
type = types.bool;
+
default = false;
+
description = ''
+
Whether to enable ALSA sound card state saving on shutdown.
+
This is generally not necessary if you're using an external sound server.
+
'';
};
-
-
###### implementation
-
-
config = mkIf config.sound.enable {
-
-
environment.systemPackages = [ alsa-utils ];
-
-
environment.etc = mkIf (!pulseaudioEnabled && config.sound.extraConfig != "")
-
{ "asound.conf".text = config.sound.extraConfig; };
-
+
config = mkIf config.hardware.alsa.enablePersistence {
# ALSA provides a udev rule for restoring volume settings.
services.udev.packages = [ alsa-utils ];
-
boot.kernelModules = optional config.sound.enableOSSEmulation "snd_pcm_oss";
-
-
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;
-
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p /var/lib/alsa";
-
ExecStart = "${alsa-utils}/sbin/alsactl restore --ignore";
-
ExecStop = "${alsa-utils}/sbin/alsactl store --ignore";
-
};
+
systemd.services.alsa-store = {
+
description = "Store Sound Card State";
+
wantedBy = [ "multi-user.target" ];
+
unitConfig = {
+
RequiresMountsFor = "/var/lib/alsa";
+
ConditionVirtualization = "!systemd-nspawn";
+
};
+
serviceConfig = {
+
Type = "oneshot";
+
RemainAfterExit = true;
+
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p /var/lib/alsa";
+
ExecStart = "${alsa-utils}/sbin/alsactl restore --ignore";
+
ExecStop = "${alsa-utils}/sbin/alsactl store --ignore";
};
-
-
services.actkbd = mkIf config.sound.mediaKeys.enable {
-
enable = true;
-
bindings = [
-
# "Mute" media key
-
{ keys = [ 113 ]; events = [ "key" ]; command = "${alsa-utils}/bin/amixer -q set Master toggle"; }
-
-
# "Lower Volume" media key
-
{ keys = [ 114 ]; events = [ "key" "rep" ]; command = "${alsa-utils}/bin/amixer -q set Master ${config.sound.mediaKeys.volumeStep}- unmute"; }
-
-
# "Raise Volume" media key
-
{ keys = [ 115 ]; events = [ "key" "rep" ]; command = "${alsa-utils}/bin/amixer -q set Master ${config.sound.mediaKeys.volumeStep}+ unmute"; }
-
-
# "Mic Mute" media key
-
{ keys = [ 190 ]; events = [ "key" ]; command = "${alsa-utils}/bin/amixer -q set Capture toggle"; }
-
];
};
-
};
-
}
+2 -2
nixos/modules/services/audio/jack.nix
···
config = mkMerge [
(mkIf pcmPlugin {
-
sound.extraConfig = ''
+
environment.etc."alsa/conf.d/98-jack.conf".text = ''
pcm_type.jack {
libs.native = ${pkgs.alsa-plugins}/lib/alsa-lib/libasound_module_pcm_jack.so ;
${lib.optionalString enable32BitAlsaPlugins
···
(mkIf loopback {
boot.kernelModules = [ "snd-aloop" ];
boot.kernelParams = [ "snd-aloop.index=${toString cfg.loopback.index}" ];
-
sound.extraConfig = cfg.loopback.config;
+
environment.etc."alsa/conf.d/99-jack-loopback.conf".text = cfg.loopback.config;
})
(mkIf cfg.jackd.enable {
-1
nixos/modules/virtualisation/vagrant-virtualbox-image.nix
···
usb = "off";
usbehci = "off";
};
-
sound.enable = false;
documentation.man.enable = false;
documentation.nixos.enable = false;
-1
nixos/tests/domination.nix
···
];
services.xserver.enable = true;
-
sound.enable = true;
environment.systemPackages = [ pkgs.domination ];
};
+1 -2
nixos/tests/firefox.nix
···
# Create a virtual sound device, with mixing
# and all, for recording audio.
boot.kernelModules = [ "snd-aloop" ];
-
sound.enable = true;
-
sound.extraConfig = ''
+
environment.etc."asound.conf".text = ''
pcm.!default {
type plug
slave.pcm pcm.dmixer
-2
nixos/tests/ft2-clone.nix
···
imports = [
./common/x11.nix
];
-
-
sound.enable = true;
environment.systemPackages = [ pkgs.ft2-clone ];
};
-1
nixos/tests/login.nix
···
nodes.machine =
{ pkgs, lib, ... }:
{ boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest;
-
sound.enable = true; # needed for the factl test, /dev/snd/* exists without them but udev doesn't care then
};
testScript = ''
-1
nixos/tests/mpd.nix
···
mkServer = { mpd, musicService, }:
{ boot.kernelModules = [ "snd-dummy" ];
-
sound.enable = true;
services.mpd = mpd;
systemd.services.musicService = musicService;
};
-1
nixos/tests/pt2-clone.nix
···
];
services.xserver.enable = true;
-
sound.enable = true;
environment.systemPackages = [ pkgs.pt2-clone ];
};
-1
nixos/tests/sfxr-qt.nix
···
];
services.xserver.enable = true;
-
sound.enable = true;
environment.systemPackages = [ pkgs.sfxr-qt ];
};
-1
nixos/tests/shattered-pixel-dungeon.nix
···
];
services.xserver.enable = true;
-
sound.enable = true;
environment.systemPackages = [ pkgs.shattered-pixel-dungeon ];
};
+1 -2
nixos/tests/slimserver.nix
···
enable = true;
extraArguments = "-s 127.0.0.1 -d slimproto=info";
};
-
sound.enable = true;
-
boot.initrd.kernelModules = ["snd-dummy"];
+
boot.kernelModules = ["snd-dummy"];
};
testScript =
-1
nixos/tests/systemd-analyze.nix
···
nodes.machine =
{ pkgs, lib, ... }:
{ boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest;
-
sound.enable = true; # needed for the factl test, /dev/snd/* exists without them but udev doesn't care then
};
testScript = ''
+1 -1
pkgs/tools/nix/nixos-option/src/nixos-option.cc
···
}
// Calls f on all the config values inside one option.
-
// Simple options have one config value inside, like sound.enable = true.
+
// Simple options have one config value inside, like services.foo.enable = true.
// Compound options have multiple config values. For example, the option
// "users.users" has about 1000 config values inside it:
// users.users.avahi.createHome = false;