2017-01-07 18:16:26 +00:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
cfg = config.programs.beets;
|
|
|
|
|
|
2020-11-30 02:54:55 +00:00
|
|
|
|
yamlFormat = pkgs.formats.yaml { };
|
|
|
|
|
|
2020-02-01 23:39:17 +00:00
|
|
|
|
in {
|
2023-05-11 12:03:54 +00:00
|
|
|
|
meta.maintainers = with maintainers; [ rycee Scrumplex ];
|
2017-09-26 21:40:31 +00:00
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
|
options = {
|
|
|
|
|
programs.beets = {
|
2018-12-04 22:00:11 +00:00
|
|
|
|
enable = mkOption {
|
|
|
|
|
type = types.bool;
|
2020-02-01 23:39:17 +00:00
|
|
|
|
default = if versionAtLeast config.home.stateVersion "19.03" then
|
|
|
|
|
false
|
|
|
|
|
else
|
|
|
|
|
cfg.settings != { };
|
2018-12-04 22:00:11 +00:00
|
|
|
|
defaultText = "false";
|
2023-07-01 23:45:18 +00:00
|
|
|
|
description = ''
|
2018-12-04 22:00:11 +00:00
|
|
|
|
Whether to enable the beets music library manager. This
|
2023-06-30 23:30:13 +00:00
|
|
|
|
defaults to `false` for state
|
2018-12-04 22:00:11 +00:00
|
|
|
|
version ≥ 19.03. For earlier versions beets is enabled if
|
2023-06-30 23:30:13 +00:00
|
|
|
|
{option}`programs.beets.settings` is non-empty.
|
2018-12-04 22:00:11 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2019-12-18 00:25:52 +00:00
|
|
|
|
package = mkOption {
|
|
|
|
|
type = types.package;
|
|
|
|
|
default = pkgs.beets;
|
2021-10-09 09:14:08 +00:00
|
|
|
|
defaultText = literalExpression "pkgs.beets";
|
2020-02-01 23:39:17 +00:00
|
|
|
|
example =
|
2021-10-09 09:14:08 +00:00
|
|
|
|
literalExpression "(pkgs.beets.override { enableCheck = true; })";
|
2023-07-01 23:45:18 +00:00
|
|
|
|
description = ''
|
2023-06-30 23:30:13 +00:00
|
|
|
|
The `beets` package to use.
|
2019-12-18 00:25:52 +00:00
|
|
|
|
Can be used to specify extensions.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-07 18:16:26 +00:00
|
|
|
|
settings = mkOption {
|
2020-11-30 02:54:55 +00:00
|
|
|
|
type = yamlFormat.type;
|
2020-02-01 23:39:17 +00:00
|
|
|
|
default = { };
|
2023-07-01 23:45:18 +00:00
|
|
|
|
description = ''
|
2017-01-15 19:03:55 +00:00
|
|
|
|
Configuration written to
|
2023-06-30 23:30:13 +00:00
|
|
|
|
{file}`$XDG_CONFIG_HOME/beets/config.yaml`
|
2017-01-15 19:03:55 +00:00
|
|
|
|
'';
|
2017-01-07 18:16:26 +00:00
|
|
|
|
};
|
2023-05-11 12:03:54 +00:00
|
|
|
|
|
|
|
|
|
mpdIntegration = {
|
2023-07-01 23:45:18 +00:00
|
|
|
|
enableStats = mkEnableOption "mpdstats plugin and service";
|
2023-05-12 21:25:49 +00:00
|
|
|
|
|
2023-07-01 23:45:18 +00:00
|
|
|
|
enableUpdate = mkEnableOption "mpdupdate plugin";
|
2023-05-12 21:25:49 +00:00
|
|
|
|
|
2023-05-11 12:03:54 +00:00
|
|
|
|
host = mkOption {
|
|
|
|
|
type = types.str;
|
|
|
|
|
default = "localhost";
|
|
|
|
|
example = "10.0.0.42";
|
2023-07-01 23:45:18 +00:00
|
|
|
|
description = "The host that mpdstats will connect to.";
|
2023-05-11 12:03:54 +00:00
|
|
|
|
};
|
2023-05-12 21:25:49 +00:00
|
|
|
|
|
2023-05-11 12:03:54 +00:00
|
|
|
|
port = mkOption {
|
|
|
|
|
type = types.port;
|
|
|
|
|
default = config.services.mpd.network.port;
|
|
|
|
|
defaultText = literalExpression "config.services.mpd.network.port";
|
|
|
|
|
example = 6601;
|
2023-07-01 23:45:18 +00:00
|
|
|
|
description = "The port that mpdstats will connect to.";
|
2023-05-11 12:03:54 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
2017-01-07 18:16:26 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2023-05-11 12:03:54 +00:00
|
|
|
|
config = mkMerge [
|
|
|
|
|
(mkIf cfg.enable {
|
|
|
|
|
home.packages = [ cfg.package ];
|
2017-01-07 18:16:26 +00:00
|
|
|
|
|
2023-05-11 12:03:54 +00:00
|
|
|
|
xdg.configFile."beets/config.yaml".source =
|
|
|
|
|
yamlFormat.generate "beets-config" cfg.settings;
|
|
|
|
|
})
|
2023-05-12 21:25:49 +00:00
|
|
|
|
|
2023-05-11 12:03:54 +00:00
|
|
|
|
(mkIf (cfg.mpdIntegration.enableStats || cfg.mpdIntegration.enableUpdate) {
|
|
|
|
|
programs.beets.settings.mpd = {
|
|
|
|
|
host = cfg.mpdIntegration.host;
|
|
|
|
|
port = cfg.mpdIntegration.port;
|
|
|
|
|
};
|
|
|
|
|
})
|
2023-05-12 21:25:49 +00:00
|
|
|
|
|
2023-05-11 12:03:54 +00:00
|
|
|
|
(mkIf cfg.mpdIntegration.enableStats {
|
|
|
|
|
programs.beets.settings.plugins = [ "mpdstats" ];
|
|
|
|
|
})
|
2023-05-12 21:25:49 +00:00
|
|
|
|
|
2023-05-11 12:03:54 +00:00
|
|
|
|
(mkIf cfg.mpdIntegration.enableUpdate {
|
|
|
|
|
programs.beets.settings.plugins = [ "mpdupdate" ];
|
|
|
|
|
})
|
2023-05-12 21:25:49 +00:00
|
|
|
|
|
2023-05-11 12:03:54 +00:00
|
|
|
|
(mkIf (cfg.enable && cfg.mpdIntegration.enableStats) {
|
|
|
|
|
systemd.user.services."beets-mpdstats" = {
|
|
|
|
|
Unit = {
|
|
|
|
|
Description = "Beets MPDStats daemon";
|
|
|
|
|
After = optional config.services.mpd.enable "mpd.service";
|
|
|
|
|
Requires = optional config.services.mpd.enable "mpd.service";
|
|
|
|
|
};
|
|
|
|
|
Service.ExecStart = "${cfg.package}/bin/beet mpdstats";
|
|
|
|
|
Install.WantedBy = [ "default.target" ];
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
];
|
2017-01-07 18:16:26 +00:00
|
|
|
|
}
|