mirror of
https://github.com/nix-community/home-manager
synced 2024-11-22 12:43:14 +00:00
9f9e277b60
These (and the `*MD` functions apart from `literalMD`) are now no-ops in nixpkgs and serve no purpose other than to add additional noise and potentially mislead people into thinking unmarked DocBook documentation will still be accepted. Note that if backporting changes including documentation to 23.05, the `mdDoc` calls will need to be re-added. 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 \ --strip {} + $ ./format
110 lines
3 KiB
Nix
110 lines
3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
let
|
|
cfg = config.services.mpd-mpris;
|
|
|
|
ignoreIfLocalMpd = value: if cfg.mpd.useLocal then null else value;
|
|
|
|
renderArg = name: value:
|
|
if lib.isBool value && value then
|
|
"-${name}"
|
|
else if lib.isInt value then
|
|
"-${name} ${toString value}"
|
|
else if lib.isString value then
|
|
"-${name} ${lib.escapeShellArg value}"
|
|
else
|
|
"";
|
|
|
|
concatArgs = strings:
|
|
lib.concatStringsSep " " (lib.filter (s: s != "") strings);
|
|
|
|
renderArgs = args: concatArgs (lib.mapAttrsToList renderArg args);
|
|
|
|
renderCmd = pkg: args: "${pkg}/bin/mpd-mpris ${renderArgs args}";
|
|
in {
|
|
meta.maintainers = [ lib.hm.maintainers.olmokramer ];
|
|
|
|
options.services.mpd-mpris = {
|
|
enable = lib.mkEnableOption
|
|
"mpd-mpris: An implementation of the MPRIS protocol for MPD";
|
|
|
|
package = lib.mkPackageOption pkgs "mpd-mpris" { };
|
|
|
|
mpd = {
|
|
useLocal = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = config.services.mpd.enable;
|
|
defaultText = lib.literalExpression "config.services.mpd.enable";
|
|
description = ''
|
|
Whether to configure for the local MPD daemon. If
|
|
`true` the `network`,
|
|
`host`, and `port`
|
|
settings are ignored.
|
|
'';
|
|
};
|
|
|
|
network = lib.mkOption {
|
|
type = with lib.types; nullOr str;
|
|
default = null;
|
|
description = ''
|
|
The network used to dial to the MPD server. Check
|
|
<https://golang.org/pkg/net/#Dial>
|
|
for available values (most common are "tcp" and "unix")
|
|
'';
|
|
};
|
|
|
|
host = lib.mkOption {
|
|
type = with lib.types; nullOr str;
|
|
default = null;
|
|
example = "192.168.1.1";
|
|
description = "The address where MPD is listening for connections.";
|
|
};
|
|
|
|
port = lib.mkOption {
|
|
type = with lib.types; nullOr port;
|
|
default = null;
|
|
description = ''
|
|
The port number where MPD is listening for connections.
|
|
'';
|
|
};
|
|
|
|
password = lib.mkOption {
|
|
type = with lib.types; nullOr str;
|
|
default = null;
|
|
description = ''
|
|
The password to connect to MPD.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "services.mpd-mpris" pkgs
|
|
lib.platforms.linux)
|
|
];
|
|
|
|
systemd.user.services.mpd-mpris = {
|
|
Install = { WantedBy = [ "default.target" ]; };
|
|
|
|
Unit = {
|
|
Description =
|
|
"mpd-mpris: An implementation of the MPRIS protocol for MPD";
|
|
After = [ "mpd.service" ];
|
|
Requires = lib.mkIf cfg.mpd.useLocal [ "mpd.service" ];
|
|
};
|
|
|
|
Service = {
|
|
Type = "simple";
|
|
Restart = "on-failure";
|
|
RestartSec = "5s";
|
|
ExecStart = renderCmd cfg.package {
|
|
no-instance = true;
|
|
network = ignoreIfLocalMpd cfg.mpd.network;
|
|
host = ignoreIfLocalMpd cfg.mpd.host;
|
|
port = ignoreIfLocalMpd cfg.mpd.port;
|
|
pwd = cfg.mpd.password;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|