mirror of
https://github.com/kmein/niveum
synced 2026-03-16 10:11:08 +01:00
feat(mpd-fm): rebrand
This commit is contained in:
101
modules/tuna.nix
Normal file
101
modules/tuna.nix
Normal file
@@ -0,0 +1,101 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
tuna-src = pkgs.fetchFromGitHub {
|
||||
owner = "kmein";
|
||||
repo = "tuna";
|
||||
rev = "7652b18a6da85723641492e9a499c6c2c1b370e4";
|
||||
sha256 = "06b2isba29vlxzgyinnqjchsz39ja60nwrx64v5kddkjqniwqjbr";
|
||||
};
|
||||
tuna = pkgs.callPackage tuna-src {};
|
||||
cfg = config.services.tuna;
|
||||
in {
|
||||
imports = [];
|
||||
|
||||
options.services.tuna = {
|
||||
enable = mkEnableOption "Tuna, 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;
|
||||
default = (pkgs.formats.json {}).generate "stations.json" cfg.stations;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = tuna;
|
||||
};
|
||||
|
||||
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.tuna.isSystemUser = true;
|
||||
# ref https://github.com/florianheinemann/MPD.FM/blob/9d037cf87597b26ae2f10ba9feea48946ad6cc68/service/MPD.FM.service
|
||||
systemd.services.tuna = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "mpd.service" ];
|
||||
script = "${cfg.package}/bin/tuna";
|
||||
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 = "tuna";
|
||||
User = "tuna";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user