-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add common Ghaf audio configuration for app-vms
Signed-off-by: Jon Sahlberg <[email protected]>
- Loading branch information
1 parent
3f3766d
commit 1733e08
Showing
6 changed files
with
55 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
modules/microvm/virtualization/microvm/common/ghaf-audio.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2022-2024 TII (SSRC) and the Ghaf contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
{ | ||
config, | ||
lib, | ||
pkgs, | ||
... | ||
}: | ||
let | ||
cfg = config.ghaf.ghaf-audio; | ||
audiovmHost = "audio-vm"; | ||
audiovmPort = config.ghaf.services.audio.pulseaudioTcpPort; | ||
address = "tcp:${audiovmHost}:${toString audiovmPort}"; | ||
reconnectMs = 1000; | ||
in | ||
{ | ||
options.ghaf.ghaf-audio = with lib; { | ||
enable = mkEnableOption "Ghaf audio support for application virtual machine."; | ||
|
||
name = mkOption { | ||
description = '' | ||
Basename of corresponding virtual machine audio channel. | ||
''; | ||
type = types.str; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
security.rtkit.enable = true; | ||
users.extraUsers.ghaf.extraGroups = [ | ||
"audio" | ||
"video" | ||
]; | ||
|
||
hardware.pulseaudio = { | ||
enable = true; | ||
extraConfig = '' | ||
load-module module-tunnel-sink-new sink_name=${cfg.name}.speaker server=${address} reconnect_interval_ms=${toString reconnectMs} | ||
load-module module-tunnel-source-new source_name=${cfg.name}.mic server=${address} reconnect_interval_ms=${toString reconnectMs} | ||
''; | ||
package = pkgs.pulseaudio-ghaf; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters