Skip to content

Commit 7ee0b82

Browse files
committed
audio: rework modules, forward pipewire socket to gui-vm
- introduced 'server' and 'client' configs - audio-vm is now the 'server', in charge of all audio hw - all other systems are now 'clients' - 'clients' can optionally enable pw socket forwarding - removed all audio-related configs from gui-vm/cosmic - removed ghaf-audio namespace - removed ghaf audio control tool, replaced by pavucontrol - re-enabled all sound-related settings in cosmic DE Signed-off-by: Kajus Naujokaitis <kajus.naujokaitis@unikie.com>
1 parent f2175ed commit 7ee0b82

File tree

26 files changed

+423
-368
lines changed

26 files changed

+423
-368
lines changed

modules/common/services/audio.nix

Lines changed: 0 additions & 131 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# SPDX-FileCopyrightText: 2026 TII (SSRC) and the Ghaf contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
{
4+
pkgs,
5+
config,
6+
lib,
7+
...
8+
}:
9+
let
10+
cfg = config.ghaf.services.audio;
11+
host = "audio-vm";
12+
address = "tcp:${host}:${toString cfg.server.pulseaudioTcpPort}";
13+
14+
in
15+
{
16+
options.ghaf.services.audio = {
17+
client = {
18+
remotePulseServerAddress = lib.mkOption {
19+
type = lib.types.str;
20+
default = address;
21+
defaultText = "tcp:audio-vm:4714";
22+
description = ''
23+
Address of the remote PulseAudio server to connect to.
24+
25+
This should point to the main Ghaf audio server.
26+
'';
27+
};
28+
enablePipewireControl = lib.mkEnableOption ''
29+
PipeWire control via a forwarded pipewire socket from the server to this machine.
30+
31+
The PipeWire socket will be available at `/tmp/pipewire-0`.
32+
To use it, set the `PIPEWIRE_RUNTIME_DIR` environment variable to /tmp.
33+
`PIPEWIRE_RUNTIME_DIR` can be set for the entire session but is not recommended,
34+
as it may interfere with local PipeWire instances.
35+
36+
Should only be used on gui-vm where users need to control audio settings.
37+
38+
Requires givc to be enabled on both client and server.
39+
PipeWire socket forwarding must be enabled on the server as well.
40+
'';
41+
};
42+
};
43+
config = lib.mkMerge [
44+
{
45+
environment = {
46+
systemPackages = [ pkgs.pulseaudio ];
47+
sessionVariables = {
48+
PULSE_SERVER = "${cfg.client.remotePulseServerAddress}";
49+
};
50+
variables = {
51+
PULSE_SERVER = "${cfg.client.remotePulseServerAddress}";
52+
};
53+
};
54+
}
55+
(lib.mkIf cfg.client.enablePipewireControl {
56+
assertions = [
57+
{
58+
assertion = config.system.name == "gui-vm";
59+
message = "PipeWire control forwarding can only be enabled on gui-vm.";
60+
}
61+
{
62+
assertion = config.ghaf.givc.enable;
63+
message = "GIVC must be enabled on audio clients when enabling Ghaf audio server control forwarding.";
64+
}
65+
];
66+
67+
environment = {
68+
systemPackages = with pkgs; [
69+
pipewire
70+
pwvucontrol-gui
71+
];
72+
};
73+
74+
givc.sysvm.socketProxy = [
75+
{
76+
transport = {
77+
name = "audio-vm";
78+
addr = config.ghaf.networking.hosts."audio-vm".ipv4;
79+
port = "9013";
80+
protocol = "tcp";
81+
};
82+
socket = "/tmp/pipewire-0";
83+
}
84+
];
85+
})
86+
];
87+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-FileCopyrightText: 2022-2026 TII (SSRC) and the Ghaf contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
{
4+
lib,
5+
...
6+
}:
7+
{
8+
imports = [
9+
./server.nix
10+
./client.nix
11+
];
12+
13+
options.ghaf.services.audio = {
14+
enable = lib.mkEnableOption "Enable Ghaf audio services";
15+
role = lib.mkOption {
16+
type = lib.types.enum [
17+
"server"
18+
"client"
19+
];
20+
default = "client";
21+
description = ''
22+
The role of this VM in the Ghaf audio topology.
23+
- "server" controls audio hardware and runs the main audio server
24+
- "client" connects to the audio server to play/record (and optionally control) audio
25+
'';
26+
};
27+
};
28+
}

0 commit comments

Comments
 (0)