Skip to content

Commit

Permalink
mpd-discord-rpc: init service (nix-community#2728)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kranzes committed Apr 5, 2022
1 parent 399a3df commit 07b941f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 55 additions & 0 deletions modules/services/mpd-discord-rpc.nix
Original file line number Diff line number Diff line change
@@ -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 <literal>config.toml</literal>.
For available options see <link xlink:href="https://github.com/JakeStanger/mpd-discord-rpc#configuration"/>
'';
};

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" ];
};
};
}

0 comments on commit 07b941f

Please sign in to comment.