1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/modules/mpd-fm.nix

97 lines
2.7 KiB
Nix
Raw Normal View History

2021-01-26 23:05:16 +01:00
{ config, lib, pkgs, ... }:
with lib;
let
mpd-fm = pkgs.callPackage <niveum/packages/MPD.FM> {};
cfg = config.services.mpd-fm;
in {
imports = [];
options.services.mpd-fm = {
enable = mkEnableOption "MPD.FM, an MPD web UI for radio streams";
webPort = mkOption {
type = types.port;
default = 4200;
};
stations = mkOption {
default = [];
type = types.listOf (types.submodule {
options = {
id = mkOption {
type = types.int;
description = "A unique identifier of the station";
};
station = mkOption {
type = types.str;
description = "Name of the station that should be displayed";
};
desc = mkOption {
type = types.nullOr types.str;
description = "Short description of the station (optional)";
};
logo = mkOption {
type = types.str;
description = "URL to a logo of the station (any size)";
};
stream = mkOption {
type = types.str;
description = "URL to the stream of the radio station (in a format supported by MPD such as MP3, OGG, ...)";
};
};
});
};
stationsFile = mkOption {
type = types.path;
2021-04-07 09:37:57 +02:00
default = (pkgs.formats.json {}).generate "stations.json" cfg.stations;
2021-01-26 23:05:16 +01:00
};
package = mkOption {
type = types.package;
default = mpd-fm;
};
mpd = {
host = mkOption {
type = types.str;
default = "localhost";
description = "The host where MPD is listening.";
example = "localhost";
};
port = mkOption {
type = types.port;
default = config.services.mpd.network.port;
description = "The port where MPD is listening.";
example = 6600;
};
};
};
config = mkIf cfg.enable {
users.extraUsers.mpd-fm.isSystemUser = true;
# ref https://github.com/florianheinemann/MPD.FM/blob/9d037cf87597b26ae2f10ba9feea48946ad6cc68/service/MPD.FM.service
systemd.services.mpd-fm = {
wantedBy = [ "multi-user.target" ];
after = [ "mpd.service" ];
description = "MPD.FM an MPD web radio player web GUI";
script = "${cfg.package}/libexec/mpd.fm/deps/mpd.fm/bin/www";
environment = {
NODE_ENV = "production";
MPD_HOST = cfg.mpd.host;
MPD_PORT = toString cfg.mpd.port;
PORT = toString cfg.webPort;
STATION_FILE = cfg.stationsFile;
};
serviceConfig = {
Restart = "always";
StandardOutput = "syslog";
StandardError = "syslog";
SyslogIdentifier = "mpd-fm";
User = "mpd-fm";
};
};
};
}