1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-04 18:29:45 +01:00
home-manager/modules/services/mpdris2.nix
Emily 36a53d9f26 treewide: convert all option docs to Markdown
This process was automated by [my fork of `nix-doc-munge`]. All
conversions were automatically checked to produce the same DocBook
result when converted back, modulo minor typographical/formatting
differences on the acceptable-to-desirable spectrum.

To reproduce this commit, run:

  $ NIX_PATH=nixpkgs=flake:nixpkgs/e7e69199f0372364a6106a1e735f68604f4c5a25 \
    nix shell nixpkgs#coreutils \
    -c find . -name '*.nix' \
    -exec nix run -- github:emilazy/nix-doc-munge/98dadf1f77351c2ba5dcb709a2a171d655f15099 \
    {} +
  $ ./format

[my fork of `nix-doc-munge`]: https://github.com/emilazy/nix-doc-munge/tree/home-manager
2023-07-17 18:40:56 +01:00

112 lines
2.9 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.mpdris2;
toIni = generators.toINI {
mkKeyValue = key: value:
let
value' = if isBool value then
(if value then "True" else "False")
else
toString value;
in "${key} = ${value'}";
};
mpdris2Conf = {
Connection = {
host = cfg.mpd.host;
port = cfg.mpd.port;
music_dir = cfg.mpd.musicDirectory;
} // optionalAttrs (cfg.mpd.password != null) {
password = cfg.mpd.password;
};
Bling = {
notify = cfg.notifications;
mmkeys = cfg.multimediaKeys;
};
};
in {
meta.maintainers = [ maintainers.pjones ];
options.services.mpdris2 = {
enable = mkEnableOption (lib.mdDoc "mpDris2 the MPD to MPRIS2 bridge");
notifications = mkEnableOption (lib.mdDoc "song change notifications");
multimediaKeys = mkEnableOption (lib.mdDoc "multimedia key support");
package = mkOption {
type = types.package;
default = pkgs.mpdris2;
defaultText = literalExpression "pkgs.mpdris2";
description = lib.mdDoc "The mpDris2 package to use.";
};
mpd = {
host = mkOption {
type = types.str;
default = config.services.mpd.network.listenAddress;
defaultText = "config.services.mpd.network.listenAddress";
example = "192.168.1.1";
description =
lib.mdDoc "The address where MPD is listening for connections.";
};
port = mkOption {
type = types.port;
default = config.services.mpd.network.port;
defaultText = "config.services.mpd.network.port";
description = lib.mdDoc ''
The port number where MPD is listening for connections.
'';
};
musicDirectory = mkOption {
type = types.nullOr types.path;
default = config.services.mpd.musicDirectory;
defaultText = "config.services.mpd.musicDirectory";
description = lib.mdDoc ''
If set, mpDris2 will use this directory to access music artwork.
'';
};
password = mkOption {
type = types.nullOr types.str;
default = null;
description = lib.mdDoc ''
The password to connect to MPD.
'';
};
};
};
config = mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.mpdris2" pkgs
lib.platforms.linux)
];
xdg.configFile."mpDris2/mpDris2.conf".text = toIni mpdris2Conf;
systemd.user.services.mpdris2 = {
Install = { WantedBy = [ "default.target" ]; };
Unit = {
Description = "MPRIS 2 support for MPD";
After = [ "mpd.service" ];
};
Service = {
Type = "simple";
Restart = "on-failure";
RestartSec = "5s";
ExecStart = "${cfg.package}/bin/mpDris2";
BusName = "org.mpris.MediaPlayer2.mpd";
};
};
};
}