add mpd and mpd sync
This commit is contained in:
parent
5191dee7ad
commit
9dc093e320
|
@ -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
|
||||
];
|
||||
|
|
21
hosts/lappy/profiles/mpd-music-sync.nix
Normal file
21
hosts/lappy/profiles/mpd-music-sync.nix
Normal 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
|
||||
'';
|
||||
};
|
||||
}
|
32
hosts/lappy/profiles/mpd.nix
Normal file
32
hosts/lappy/profiles/mpd.nix
Normal 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" ];
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue