|
9 | 9 | yamlFormat = pkgs.formats.yaml { };
|
10 | 10 |
|
11 | 11 | in {
|
12 |
| - meta.maintainers = [ maintainers.rycee ]; |
| 12 | + meta.maintainers = with maintainers; [ rycee Scrumplex ]; |
13 | 13 |
|
14 | 14 | options = {
|
15 | 15 | programs.beets = {
|
|
48 | 48 | <filename>$XDG_CONFIG_HOME/beets/config.yaml</filename>
|
49 | 49 | '';
|
50 | 50 | };
|
| 51 | + |
| 52 | + mpdIntegration = { |
| 53 | + enableStats = mkEnableOption "mpdstats plugin and service"; |
| 54 | + enableUpdate = mkEnableOption "mpdupdate plugin"; |
| 55 | + host = mkOption { |
| 56 | + type = types.str; |
| 57 | + default = "localhost"; |
| 58 | + description = "Host mpdstats will connect to"; |
| 59 | + example = "10.0.0.42"; |
| 60 | + }; |
| 61 | + port = mkOption { |
| 62 | + type = types.port; |
| 63 | + default = config.services.mpd.network.port; |
| 64 | + defaultText = "6600"; |
| 65 | + description = "Port mpdstats will connect to"; |
| 66 | + example = "6601"; |
| 67 | + }; |
| 68 | + }; |
51 | 69 | };
|
52 | 70 | };
|
53 | 71 |
|
54 |
| - config = mkIf cfg.enable { |
55 |
| - home.packages = [ cfg.package ]; |
| 72 | + config = mkIf cfg.enable (mkMerge [ |
| 73 | + { |
| 74 | + home.packages = [ cfg.package ]; |
56 | 75 |
|
57 |
| - xdg.configFile."beets/config.yaml".source = |
58 |
| - yamlFormat.generate "beets-config" cfg.settings; |
59 |
| - }; |
| 76 | + xdg.configFile."beets/config.yaml".source = |
| 77 | + yamlFormat.generate "beets-config" cfg.settings; |
| 78 | + } |
| 79 | + (mkIf (cfg.mpdIntegration.enableStats || cfg.mpdIntegration.enableUpdate) { |
| 80 | + programs.beets.settings.mpd = { |
| 81 | + host = cfg.mpdIntegration.host; |
| 82 | + port = cfg.mpdIntegration.port; |
| 83 | + }; |
| 84 | + }) |
| 85 | + (mkIf cfg.mpdIntegration.enableStats { |
| 86 | + programs.beets.settings.plugins = [ "mpdstats" ]; |
| 87 | + |
| 88 | + systemd.user.services."beets-mpdstats" = { |
| 89 | + Unit = { |
| 90 | + Description = "Beets MPDStats daemon"; |
| 91 | + After = [ "mpd.service" ]; |
| 92 | + Requires = [ "mpd.service" ]; |
| 93 | + }; |
| 94 | + Service.ExecStart = "${cfg.package}/bin/beet mpdstats"; |
| 95 | + }; |
| 96 | + }) |
| 97 | + (mkIf cfg.mpdIntegration.enableUpdate { |
| 98 | + programs.beets.settings.plugins = [ "mpdupdate" ]; |
| 99 | + }) |
| 100 | + ]); |
60 | 101 | }
|
0 commit comments