fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . services . fluidsynth ; 8 9in { 10meta . maintainers = [ maintainers . valodim ]; 11 12options = { 13services . fluidsynth = { 14enable = mkEnableOption "fluidsynth midi synthesizer" ; 15 16soundFont = mkOption { 17type = types . path ; 18default = " ${ pkgs . soundfont-fluid } /share/soundfonts/FluidR3_GM2-2.sf2" ; 19description = '' 20The soundfont file to use, in SoundFont 2 format. 21'' ; 22}; 23 24soundService = mkOption { 25type = types . enum [ "jack" "pipewire-pulse" "pulseaudio" ]; 26default = "pulseaudio" ; 27example = "pipewire-pulse" ; 28description = '' 29The systemd sound service to depend on. 30'' ; 31}; 32 33extraOptions = mkOption { 34type = types . listOf types . str ; 35default = [ ]; 36example = [ "--sample-rate 96000" ]; 37description = '' 38Extra arguments, added verbatim to the fluidsynth command. See 39{manpage}`fluidsynth.conf(1)`. 40'' ; 41}; 42}; 43}; 44 45config = mkIf cfg . enable { 46assertions = [ 47( lib . hm . assertions . assertPlatform "services.fluidsynth" pkgs 48lib . platforms . linux ) 49]; 50 51systemd . user . services . fluidsynth = { 52Unit = { 53Description = "FluidSynth Daemon" ; 54Documentation = "man:fluidsynth(1)" ; 55BindsTo = [ ( cfg . soundService + ".service" ) ]; 56After = [ ( cfg . soundService + ".service" ) ]; 57}; 58 59Install = { WantedBy = [ "default.target" ]; }; 60 61Service = { 62ExecStart = " ${ pkgs . fluidsynth } /bin/fluidsynth -a pulseaudio -si ${ 63lib . concatStringsSep " " cfg . extraOptions 64} ${ cfg . soundFont } " ; 65}; 66}; 67}; 68}