fluidsynth: add sound service option

Fluidsynth's systemd unit currently has a hard dependency on the
pulseaudio systemd service. Since fluidsynth can use other sound
services (e.g., pipewire-pulse), this should be configurable. This
commit adds the relevant option.

PR #2238
This commit is contained in:
Nicholas Coltharp 2021-07-31 06:05:27 -05:00 committed by Robert Helgesson
parent d11afee973
commit 72394f6d6b
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 18 additions and 2 deletions

View file

@ -21,6 +21,15 @@ in {
'';
};
soundService = mkOption {
type = types.enum [ "jack" "pipewire-pulse" "pulseaudio" ];
default = "pulseaudio";
example = "pipewire-pulse";
description = ''
The systemd sound service to depend on.
'';
};
extraOptions = mkOption {
type = types.listOf types.str;
default = [ ];
@ -46,8 +55,8 @@ in {
Unit = {
Description = "FluidSynth Daemon";
Documentation = "man:fluidsynth(1)";
BindsTo = [ "pulseaudio.service" ];
After = [ "pulseaudio.service" ];
BindsTo = [ (cfg.soundService + ".service") ];
After = [ (cfg.soundService + ".service") ];
};
Install = { WantedBy = [ "default.target" ]; };

View file

@ -1,6 +1,7 @@
{ config, pkgs, ... }: {
config = {
services.fluidsynth.enable = true;
services.fluidsynth.soundService = "pipewire-pulse";
services.fluidsynth.soundFont = "/path/to/soundFont";
services.fluidsynth.extraOptions = [ "--sample-rate 96000" ];
@ -19,6 +20,12 @@
assertFileContains $serviceFile \
'ExecStart=@fluidsynth@/bin/fluidsynth -a pulseaudio -si --sample-rate 96000 /path/to/soundFont'
assertFileContains $serviceFile \
'After=pipewire-pulse.service'
assertFileContains $serviceFile \
'BindsTo=pipewire-pulse.service'
'';
};
}