diff --git a/modules/services/fluidsynth.nix b/modules/services/fluidsynth.nix index 1b5a0c5f..bf1b76a0 100644 --- a/modules/services/fluidsynth.nix +++ b/modules/services/fluidsynth.nix @@ -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" ]; }; diff --git a/tests/modules/services/fluidsynth/service.nix b/tests/modules/services/fluidsynth/service.nix index 8d53e75c..9115eb0d 100644 --- a/tests/modules/services/fluidsynth/service.nix +++ b/tests/modules/services/fluidsynth/service.nix @@ -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' ''; }; }