add mpd and mpd sync

This commit is contained in:
ChaotiCryptidz 2022-01-23 11:48:43 +00:00
parent 5191dee7ad
commit 9dc093e320
4 changed files with 58 additions and 0 deletions

View file

@ -28,6 +28,9 @@
# for sci-hub and whenever websites break
profiles.tor
# Music!
hosts.lappy.profiles.mpd
# For cross compiling and deploying to raspberry
profiles.cross.arm64
];

View file

@ -0,0 +1,21 @@
{ pkgs, ... }: let
passwordFile = "/secrets/mpd-music-sync-password";
in {
systemd.tmpfiles.rules = [ "d /music 0755 mpd users -" ];
systemd.services.mpd-music-sync = {
startAt = "daily";
requires = [ "network.target" ];
after = [ "network.target" ];
path = [ pkgs.rclone ];
script = ''
set -x
export PASSWORD=$(cat ${passwordFile})
rclone sync :ftp:/storage/music /music \
--ftp-host=hetzner-vm.servers.owo.monster \
--ftp-port=4220 \
--ftp-user=ftp-user \
--ftp-pass=$(rclone obscure $PASSWORD)
chown mpd:users -R /music
'';
};
}

View file

@ -0,0 +1,32 @@
{ pkgs, tree, ... }: {
imports = [ ./mpd-music-sync.nix ];
hardware.pulseaudio = {
extraConfig =
"load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1";
};
environment.systemPackages = with pkgs; [ mpc_cli ];
systemd.tmpfiles.rules = [
"d /var/lib/mpd 0755 mpd mpd -"
"d /var/lib/mpd/data 0755 mpd mpd -"
"d /var/lib/mpd/playlists 0755 mpd mpd -" ];
services.mpd = {
enable = true;
dataDir = "/var/lib/mpd/data";
playlistDirectory = "/var/lib/mpd/playlists";
musicDirectory = "/music";
extraConfig = ''
host_permissions "127.0.0.1 read,add,control,admin"
audio_output {
type "pulse"
name "Pulseaudio"
server "127.0.0.1"
}
'';
};
systemd.services.mpd.serviceConfig.StateDirectory = [ "/music" "/var/lib/mpd" ];
}

View file

@ -6,6 +6,8 @@ let
folder = ./.;
config = {
"hosts/*/services".functor.enable = true;
"hosts/*/home".functor.enable = true;
"hosts/*/profiles".functor.enable = true;
"profiles/*".functor.enable = true;
"profiles/sound/*".functor.enable = true;
"profiles/connectivity/*".functor.enable = true;