fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

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