diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 4fb015f32..d298d034c 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -340,6 +340,8 @@
/modules/services/mpdris2.nix @pjones
+/modules/services/mpd-discord-rpc.nix @Kranzes
+
/modules/services/mpris-proxy.nix @ThibautMarty
/modules/services/muchsync.nix @pacien
diff --git a/modules/modules.nix b/modules/modules.nix
index 81b75db4e..5bd77c929 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -209,6 +209,7 @@ let
./services/mbsync.nix
./services/mpd.nix
./services/mpdris2.nix
+ ./services/mpd-discord-rpc.nix
./services/mpris-proxy.nix
./services/muchsync.nix
./services/network-manager-applet.nix
diff --git a/modules/services/mpd-discord-rpc.nix b/modules/services/mpd-discord-rpc.nix
new file mode 100644
index 000000000..23cf1b5ec
--- /dev/null
+++ b/modules/services/mpd-discord-rpc.nix
@@ -0,0 +1,55 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.services.mpd-discord-rpc;
+ tomlFormat = pkgs.formats.toml { };
+ configFile = tomlFormat.generate "config.toml" cfg.settings;
+in {
+ meta.maintainers = [ maintainers.kranzes ];
+
+ options.services.mpd-discord-rpc = {
+ enable = mkEnableOption "the mpd-discord-rpc service";
+
+ settings = mkOption {
+ type = tomlFormat.type;
+ default = { };
+ example = literalExpression ''
+ {
+ hosts = [ "localhost:6600" ];
+ format = {
+ details = "$title";
+ state = "On $album by $artist";
+ };
+ }
+ '';
+ description = ''
+ Configuration included in config.toml.
+ For available options see
+ '';
+ };
+
+ package = mkOption {
+ type = types.package;
+ default = pkgs.mpd-discord-rpc;
+ defaultText = literalExpression "pkgs.mpd-discord-rpc";
+ description = "mpd-discord-rpc package to use.";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ 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-pre.target" ];
+ PartOf = [ "graphical-session.desktop" ];
+ };
+ Service.ExecStart = "${cfg.package}/bin/mpd-discord-rpc";
+ Install.WantedBy = [ "graphical-session.target" ];
+ };
+ };
+}