nixos-config/nixos/configs/pepe/mpd.nix

96 lines
2.9 KiB
Nix

{ config, lib, pkgs, ... }:
{
services.mpd = {
enable = true;
network.listenAddress = "any";
musicDirectory = "/media/syncthing/music-library";
playlistDirectory = "/media/syncthing/music-library/playlists";
};
users.groups."syncthing".members = [ "mpd" ];
sound.enable = true;
networking.firewall.allowedTCPPorts = [
6680 # mopidy
6600 # mpd
1234 # zeroconf
];
users.users."spotifyd" = {
isSystemUser = true;
group = "spotifyd";
};
users.groups.spotifyd = { };
sops.secrets.spotify_pass = {
owner = "spotifyd";
};
sops.secrets.spotify_user = {
owner = "spotifyd";
};
services.spotifyd.enable = true;
services.spotifyd.config = ''
[global]
username_cmd = "cat ${config.sops.secrets.spotify_user.path}"
password_cmd = "cat ${config.sops.secrets.spotify_pass.path}"
backend = "alsa" # use portaudio for macOS [homebrew]
# The alsa audio device to stream audio to. To get a
# list of valid devices, run `aplay -L`,
#device = "alsa_audio_device" # omit for macOS
# The alsa mixer used by `spotifyd`.
mixer = "PCM" # omit for macOS
# A script that gets evaluated in the user's shell when the song changes [aliases: onevent]
on-song-change-hook = "${pkgs.mpc_cli}/bin/mpc --host localhost --port 6600 stop"
# The volume controller. Each one behaves different to
# volume increases. For possible values, run
# `spotifyd --help`.
volume_controller = "alsa" # use softvol for macOS
# The name that gets displayed under the connect tab on
# official clients. Spaces are not allowed!
device_name = "DJane"
# The audio bitrate. 96, 160 or 320 kbit/s
bitrate = 320
# The directory used to cache audio data. This setting can save
# a lot of bandwidth when activated, as it will avoid re-downloading
# audio files when replaying them.
#
# Note: The file path does not get expanded. Environment variables and
# shell placeholders like $HOME or ~ don't work!
#cache_path = "cache_directory"
# If set to true, audio data does NOT get cached.
no_audio_cache = true
# Volume on startup between 0 and 100
# NOTE: This variable's type will change in v0.4, to a number (instead of string)
initial_volume = "90"
# If set to true, enables volume normalisation between songs.
volume_normalisation = false
# The normalisation pregain that is applied for each song.
# normalisation_pregain = -10
# The port `spotifyd` uses to announce its service over the network.
zeroconf_port = 1234
# The proxy `spotifyd` will use to connect to spotify.
#proxy = "http://proxy.example.org:8080"
# The displayed device type in Spotify clients.
# Can be unknown, computer, tablet, smartphone, speaker, t_v,
# a_v_r (Audio/Video Receiver), s_t_b (Set-Top Box), and audio_dongle.
device_type = "computer"
'';
}