mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
nixos/alsa: kill sound.enable and friends with fire
This commit is contained in:
parent
16007071b4
commit
3eeff54780
@ -2,8 +2,7 @@
|
||||
|
||||
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.
|
||||
|
@ -5,5 +5,4 @@ graphical stuff. It's a very short file that enables
|
||||
[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).
|
||||
|
@ -197,6 +197,8 @@
|
||||
|
||||
- `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.
|
||||
|
||||
@ -233,3 +235,46 @@
|
||||
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"; }
|
||||
];
|
||||
};
|
||||
```
|
||||
|
@ -6,7 +6,6 @@ with lib;
|
||||
let
|
||||
|
||||
cfg = config.hardware.pulseaudio;
|
||||
alsaCfg = config.sound;
|
||||
|
||||
hasZeroconf = let z = cfg.zeroconf; in z.publish.enable || z.discovery.enable;
|
||||
|
||||
@ -58,7 +57,7 @@ let
|
||||
# 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
|
||||
@ -76,8 +75,7 @@ let
|
||||
ctl.!default {
|
||||
type pulse
|
||||
}
|
||||
${alsaCfg.extraConfig}
|
||||
'');
|
||||
'';
|
||||
|
||||
in {
|
||||
|
||||
@ -221,10 +219,8 @@ 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);
|
||||
|
@ -3,106 +3,31 @@
|
||||
|
||||
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 {
|
||||
options.hardware.alsa.enablePersistence = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to enable ALSA sound.
|
||||
Whether to enable ALSA sound card state saving on shutdown.
|
||||
This is generally not necessary if you're using an external sound server.
|
||||
'';
|
||||
};
|
||||
|
||||
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.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
###### 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";
|
||||
systemd.services.alsa-store = {
|
||||
description = "Store Sound Card State";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
unitConfig.RequiresMountsFor = "/var/lib/alsa";
|
||||
unitConfig.ConditionVirtualization = "!systemd-nspawn";
|
||||
unitConfig = {
|
||||
RequiresMountsFor = "/var/lib/alsa";
|
||||
ConditionVirtualization = "!systemd-nspawn";
|
||||
};
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
@ -111,24 +36,5 @@ in
|
||||
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"; }
|
||||
];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ in {
|
||||
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
|
||||
@ -139,7 +139,7 @@ in {
|
||||
(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 {
|
||||
|
@ -15,7 +15,6 @@
|
||||
usb = "off";
|
||||
usbehci = "off";
|
||||
};
|
||||
sound.enable = false;
|
||||
documentation.man.enable = false;
|
||||
documentation.nixos.enable = false;
|
||||
|
||||
|
@ -10,7 +10,6 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
];
|
||||
|
||||
services.xserver.enable = true;
|
||||
sound.enable = true;
|
||||
environment.systemPackages = [ pkgs.domination ];
|
||||
};
|
||||
|
||||
|
@ -21,8 +21,7 @@ import ./make-test-python.nix ({ lib, pkgs, firefoxPackage, ... }:
|
||||
# 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
|
||||
|
@ -8,8 +8,6 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
imports = [
|
||||
./common/x11.nix
|
||||
];
|
||||
|
||||
sound.enable = true;
|
||||
environment.systemPackages = [ pkgs.ft2-clone ];
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,6 @@ import ./make-test-python.nix ({ pkgs, latestKernel ? false, ... }:
|
||||
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 = ''
|
||||
|
@ -37,7 +37,6 @@ import ./make-test-python.nix ({ pkgs, lib, ... }:
|
||||
|
||||
mkServer = { mpd, musicService, }:
|
||||
{ boot.kernelModules = [ "snd-dummy" ];
|
||||
sound.enable = true;
|
||||
services.mpd = mpd;
|
||||
systemd.services.musicService = musicService;
|
||||
};
|
||||
|
@ -10,7 +10,6 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
];
|
||||
|
||||
services.xserver.enable = true;
|
||||
sound.enable = true;
|
||||
environment.systemPackages = [ pkgs.pt2-clone ];
|
||||
};
|
||||
|
||||
|
@ -10,7 +10,6 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
];
|
||||
|
||||
services.xserver.enable = true;
|
||||
sound.enable = true;
|
||||
environment.systemPackages = [ pkgs.sfxr-qt ];
|
||||
};
|
||||
|
||||
|
@ -10,7 +10,6 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
||||
];
|
||||
|
||||
services.xserver.enable = true;
|
||||
sound.enable = true;
|
||||
environment.systemPackages = [ pkgs.shattered-pixel-dungeon ];
|
||||
};
|
||||
|
||||
|
@ -8,8 +8,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
enable = true;
|
||||
extraArguments = "-s 127.0.0.1 -d slimproto=info";
|
||||
};
|
||||
sound.enable = true;
|
||||
boot.initrd.kernelModules = ["snd-dummy"];
|
||||
boot.kernelModules = ["snd-dummy"];
|
||||
};
|
||||
|
||||
testScript =
|
||||
|
@ -9,7 +9,6 @@ import ./make-test-python.nix ({ pkgs, latestKernel ? false, ... }:
|
||||
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 = ''
|
||||
|
@ -319,7 +319,7 @@ void mapOptions(const std::function<void(const std::string & path)> & f, Context
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
Loading…
Reference in New Issue
Block a user