Add snapsync and mopidy
This commit is contained in:
parent
2ec800234d
commit
c4fb41f93a
4 changed files with 151 additions and 0 deletions
|
|
@ -8,12 +8,15 @@
|
|||
./jellyfin.nix
|
||||
./mail.nix
|
||||
./matrix.nix
|
||||
./mopidy.nix
|
||||
./navidrome.nix
|
||||
./nginx.nix
|
||||
./ntp.nix
|
||||
./public-ip-tunnel.nix
|
||||
./radicale.nix
|
||||
./remarkable.nix
|
||||
./snapclient.nix
|
||||
./snapserver.nix
|
||||
./sturzbach.nix
|
||||
./unifi-controller.nix
|
||||
./whatsapp.nix
|
||||
|
|
|
|||
65
hosts/iron/services/mopidy.nix
Normal file
65
hosts/iron/services/mopidy.nix
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
args@{ lib, pkgs, config, custom-utils, ... }:
|
||||
let
|
||||
interfaces = import ../interfaces.nix;
|
||||
mopidyConfig = {
|
||||
audio.output = "audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! wavenc ! filesink location=/run/snapserver/mopidy.fifo";
|
||||
file.enabled = false;
|
||||
local = {
|
||||
library = "sqlite";
|
||||
scan_flush_threshold = 100;
|
||||
media_dir = "/var/lib/music";
|
||||
included_file_extensions = lib.strings.concatStringsSep "," [
|
||||
".aac"
|
||||
".flac"
|
||||
".m4a"
|
||||
".mp3"
|
||||
".opus"
|
||||
];
|
||||
};
|
||||
m3u = {
|
||||
playlists_dir = "$XDG_CONFIG_DIR/mopidy/playlists";
|
||||
};
|
||||
http = {
|
||||
enabled = true;
|
||||
hostname = "::";
|
||||
port = 6680;
|
||||
};
|
||||
mpd = {
|
||||
enabled = true;
|
||||
hostname = "::";
|
||||
port = 6600;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
services.mopidy = {
|
||||
enable = true;
|
||||
extensionPackages = with pkgs; [
|
||||
mopidy-iris
|
||||
mopidy-local
|
||||
mopidy-moped
|
||||
mopidy-mpd
|
||||
mopidy-muse
|
||||
mopidy-somafm
|
||||
mopidy-ytmusic
|
||||
];
|
||||
configuration = lib.generators.toINI { } mopidyConfig;
|
||||
};
|
||||
|
||||
networking.firewall.interfaces."${interfaces.lan}".allowedTCPPorts = [
|
||||
mopidyConfig.http.port
|
||||
mopidyConfig.mpd.port
|
||||
];
|
||||
|
||||
environment.systemPackages = [
|
||||
(with config.systemd.services.mopidy.serviceConfig;
|
||||
pkgs.writeShellScriptBin "mopidyctl" ''
|
||||
cmd='sudo -u ${User} -- ${ExecStart}'
|
||||
if [ $# -eq 0 ]; then
|
||||
exec $cmd --help
|
||||
fi
|
||||
exec $cmd "$@"
|
||||
''
|
||||
)
|
||||
];
|
||||
}
|
||||
36
hosts/iron/services/snapclient.nix
Normal file
36
hosts/iron/services/snapclient.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{ lib, pkgs, ... }:
|
||||
|
||||
let hostId = "Wohnzimmer";
|
||||
in
|
||||
{
|
||||
#services.pipewire = {
|
||||
# enable = true;
|
||||
# pulse.enable = true;
|
||||
# alsa.enable = true;
|
||||
#};
|
||||
|
||||
#environment.systemPackages = with pkgs; [
|
||||
# pulseaudio # pacmd and pactl
|
||||
# pulsemixer
|
||||
#];
|
||||
|
||||
systemd.services.snapclient = {
|
||||
enable = true;
|
||||
description = "Snapcast client";
|
||||
wants = [ "network.target" "sound.target" ];
|
||||
after = [ "network.target" "sound.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
DynamicUser = "yes";
|
||||
ExecStart = "${pkgs.snapcast}/bin/snapclient --host 127.0.0.1 -s DAC";
|
||||
Group = "audio";
|
||||
NoNewPrivileges = true;
|
||||
ProtectControlGroups = true;
|
||||
ProtectHome = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectKernelTunables = true;
|
||||
RestrictAddressFamilies = "AF_INET AF_INET6 AF_UNIX";
|
||||
RestrictNamespaces = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
47
hosts/iron/services/snapserver.nix
Normal file
47
hosts/iron/services/snapserver.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
args@{ lib, pkgs, config, custom-utils, ... }:
|
||||
let
|
||||
ports = import ../ports.nix args;
|
||||
interfaces = import ../interfaces.nix;
|
||||
in
|
||||
{
|
||||
services.snapserver = {
|
||||
enable = true;
|
||||
streams = {
|
||||
mopidy = {
|
||||
type = "pipe";
|
||||
location = "/run/snapserver/mopidy.fifo";
|
||||
};
|
||||
airplay = {
|
||||
type = "airplay";
|
||||
location = lib.getExe' pkgs.shairport-sync "shairport-sync";
|
||||
query = {
|
||||
devicename = "Snapcast";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#systemd.services.snapserver = {
|
||||
#requires = [config.systemd.services.mopidy.name];
|
||||
#after = [config.systemd.services.mopidy.name];
|
||||
#};
|
||||
|
||||
services.home-assistant.config.media_player = [
|
||||
{
|
||||
platform = "snapcast";
|
||||
host = "127.0.0.1";
|
||||
}
|
||||
];
|
||||
|
||||
networking.firewall.interfaces."${interfaces.lan}" = {
|
||||
allowedTCPPorts = [
|
||||
config.services.snapserver.http.port
|
||||
config.services.snapserver.port
|
||||
config.services.snapserver.tcp.port
|
||||
5000 # airplay
|
||||
];
|
||||
allowedUDPPortRanges = [
|
||||
{ from = 6001; to = 6011; } # airplay
|
||||
];
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue