2021-11-30 13:51:06 +00:00
|
|
|
let
|
2022-08-17 10:05:13 +00:00
|
|
|
mkTest = { systemWide ? false , fullVersion ? false }:
|
2021-11-30 13:51:06 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
testFile = pkgs.fetchurl {
|
|
|
|
url =
|
2022-08-18 08:20:30 +00:00
|
|
|
"https://file-examples.com/storage/fe5947fd2362fc197a3c2df/2017/11/file_example_MP3_700KB.mp3";
|
2021-11-30 13:51:06 +00:00
|
|
|
hash = "sha256-+iggJW8s0/LfA/okfXsB550/55Q0Sq3OoIzuBrzOPJQ=";
|
|
|
|
};
|
|
|
|
|
|
|
|
makeTestPlay = key:
|
|
|
|
{ sox, alsa-utils }:
|
|
|
|
pkgs.writeScriptBin key ''
|
|
|
|
set -euxo pipefail
|
|
|
|
${sox}/bin/play ${testFile}
|
|
|
|
${sox}/bin/sox ${testFile} -t wav - | ${alsa-utils}/bin/aplay
|
|
|
|
touch /tmp/${key}_success
|
|
|
|
'';
|
|
|
|
|
|
|
|
testers = builtins.mapAttrs makeTestPlay {
|
|
|
|
testPlay = { inherit (pkgs) sox alsa-utils; };
|
|
|
|
testPlay32 = { inherit (pkgs.pkgsi686Linux) sox alsa-utils; };
|
|
|
|
};
|
|
|
|
in {
|
2022-08-17 10:05:13 +00:00
|
|
|
name = "pulseaudio${lib.optionalString fullVersion "Full"}${lib.optionalString systemWide "-systemWide"}";
|
2021-11-30 13:51:06 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
|
|
|
maintainers = [ synthetica ] ++ pkgs.pulseaudio.meta.maintainers;
|
|
|
|
};
|
|
|
|
|
2022-03-20 23:15:30 +00:00
|
|
|
nodes.machine = { ... }:
|
2021-11-30 13:51:06 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
imports = [ ./common/wayland-cage.nix ];
|
|
|
|
hardware.pulseaudio = {
|
|
|
|
enable = true;
|
|
|
|
support32Bit = true;
|
|
|
|
inherit systemWide;
|
2022-08-17 10:05:13 +00:00
|
|
|
} // lib.optionalAttrs fullVersion {
|
|
|
|
package = pkgs.pulseaudioFull;
|
2021-11-30 13:51:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = [ testers.testPlay pkgs.pavucontrol ]
|
2024-09-24 15:50:49 +00:00
|
|
|
++ lib.optional pkgs.stdenv.hostPlatform.isx86_64 testers.testPlay32;
|
2021-11-30 13:51:06 +00:00
|
|
|
} // lib.optionalAttrs systemWide {
|
2022-08-18 09:03:58 +00:00
|
|
|
users.users.alice.extraGroups = [ "pulse-access" ];
|
2021-11-30 13:51:06 +00:00
|
|
|
systemd.services.pulseaudio.wantedBy = [ "multi-user.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
enableOCR = true;
|
|
|
|
|
|
|
|
testScript = { ... }: ''
|
|
|
|
machine.wait_until_succeeds("pgrep xterm")
|
|
|
|
machine.wait_for_text("alice@machine")
|
|
|
|
|
|
|
|
machine.send_chars("testPlay \n")
|
|
|
|
machine.wait_for_file("/tmp/testPlay_success")
|
2024-09-24 15:50:49 +00:00
|
|
|
${lib.optionalString pkgs.stdenv.hostPlatform.isx86_64 ''
|
2021-11-30 13:51:06 +00:00
|
|
|
machine.send_chars("testPlay32 \n")
|
|
|
|
machine.wait_for_file("/tmp/testPlay32_success")
|
|
|
|
''}
|
|
|
|
machine.screenshot("testPlay")
|
|
|
|
|
2022-08-18 06:42:41 +00:00
|
|
|
${lib.optionalString (!systemWide) ''
|
|
|
|
machine.send_chars("pacmd info && touch /tmp/pacmd_success\n")
|
|
|
|
machine.wait_for_file("/tmp/pacmd_success")
|
|
|
|
''}
|
|
|
|
|
2021-11-30 13:51:06 +00:00
|
|
|
# Pavucontrol only loads when Pulseaudio is running. If it isn't, the
|
2022-08-18 08:28:02 +00:00
|
|
|
# text "Dummy Output" (sound device name) will never show.
|
2021-11-30 13:51:06 +00:00
|
|
|
machine.send_chars("pavucontrol\n")
|
2022-08-18 08:28:02 +00:00
|
|
|
machine.wait_for_text("Dummy Output")
|
2021-11-30 13:51:06 +00:00
|
|
|
machine.screenshot("Pavucontrol")
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
in builtins.mapAttrs (key: val: mkTest val) {
|
2022-08-17 10:05:13 +00:00
|
|
|
user = { systemWide = false; fullVersion = false; };
|
|
|
|
system = { systemWide = true; fullVersion = false; };
|
|
|
|
userFull = { systemWide = false; fullVersion = true; };
|
|
|
|
systemFull = { systemWide = true; fullVersion = true; };
|
2021-11-30 13:51:06 +00:00
|
|
|
}
|