mirror of
https://github.com/nix-community/home-manager.git
synced 2026-06-05 21:02:51 +00:00
`literalExpression` is intended just to signify code that needs to stay a string that gets represented exactly as-is for docs. It has been misused heavily and people get confused repeatedly on when or not to use it because of the rampant misuse.
59 lines
1.5 KiB
Nix
59 lines
1.5 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.mpd-discord-rpc;
|
|
tomlFormat = pkgs.formats.toml { };
|
|
configFile = tomlFormat.generate "config.toml" cfg.settings;
|
|
in
|
|
{
|
|
meta.maintainers = [ lib.maintainers.kranzes ];
|
|
|
|
options.services.mpd-discord-rpc = {
|
|
enable = lib.mkEnableOption "the mpd-discord-rpc service";
|
|
|
|
settings = lib.mkOption {
|
|
inherit (tomlFormat) type;
|
|
default = { };
|
|
example = {
|
|
hosts = [ "localhost:6600" ];
|
|
format = {
|
|
details = "$title";
|
|
state = "On $album by $artist";
|
|
};
|
|
};
|
|
description = ''
|
|
Configuration included in `config.toml`.
|
|
For available options see <https://github.com/JakeStanger/mpd-discord-rpc#configuration>
|
|
'';
|
|
};
|
|
|
|
package = lib.mkPackageOption pkgs "mpd-discord-rpc" { };
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "services.mpd-discord-rpc" pkgs lib.platforms.linux)
|
|
];
|
|
|
|
xdg.configFile."discord-rpc/config.toml".source = configFile;
|
|
|
|
systemd.user.services.mpd-discord-rpc = {
|
|
Unit = {
|
|
Description = "Discord Rich Presence for MPD";
|
|
Documentation = "https://github.com/JakeStanger/mpd-discord-rpc";
|
|
After = [ "graphical-session.target" ];
|
|
PartOf = [ "graphical-session.target" ];
|
|
};
|
|
Service = {
|
|
ExecStart = "${cfg.package}/bin/mpd-discord-rpc";
|
|
Restart = "on-failure";
|
|
};
|
|
Install.WantedBy = [ "graphical-session.target" ];
|
|
};
|
|
};
|
|
}
|