95 lines
2.7 KiB
Nix
95 lines
2.7 KiB
Nix
{ config, lib, nixosConfig, pkgs, ... }:
|
||
|
||
# I only use mpd on gui systems. If I should ever need it on a headless system,
|
||
# I will add a separate option.
|
||
lib.mkIf nixosConfig.sbruder.gui.enable {
|
||
services.mpd = {
|
||
enable = true;
|
||
package = pkgs.mpd;
|
||
musicDirectory = "~/Music";
|
||
network.listenAddress = "${config.services.mpd.dataDir}/socket";
|
||
extraConfig = ''
|
||
zeroconf_enabled "no"
|
||
|
||
restore_paused "yes"
|
||
|
||
audio_output {
|
||
type "pipewire"
|
||
name "pipewire"
|
||
}
|
||
|
||
audio_output {
|
||
type "fifo"
|
||
name "fifo"
|
||
path "${config.services.mpd.dataDir}/fifo"
|
||
format "44100:16:2"
|
||
}
|
||
'';
|
||
};
|
||
|
||
programs.ncmpcpp = {
|
||
enable = true;
|
||
package = (pkgs.ncmpcpp.override {
|
||
visualizerSupport = true;
|
||
taglibSupport = false;
|
||
}).overrideAttrs (o: o // {
|
||
nativeBuildInputs = o.nativeBuildInputs ++ (with pkgs; [ makeWrapper ]);
|
||
|
||
# !!! HACK: ncurses uses terminfo’s rs1 for alacritty (\033c\033]104\007)
|
||
# to reset the terminal when the window is resized. For achieving the
|
||
# required effect (clearing the terminal), \033c would be enough.
|
||
# \033]104\007 additionally resets colours set by dynamic-colors. This
|
||
# makes text written in those colours almost unreadable. Since xterm only
|
||
# uses \033c to reset the terminal and does not make ncmpcpp misbehave in
|
||
# alacritty, this wrapper tricks ncurses into thinking it is running in
|
||
# xterm.
|
||
postInstall = ''
|
||
wrapProgram $out/bin/ncmpcpp \
|
||
--run '[ "$TERM" = "alacritty" ] && export TERM="xterm"'
|
||
'';
|
||
});
|
||
mpdMusicDir = null; # does not work (not of type `null or path')
|
||
settings = {
|
||
# Connection
|
||
mpd_host = config.services.mpd.network.listenAddress;
|
||
|
||
# Visualizer
|
||
visualizer_autoscale = true;
|
||
visualizer_data_source = "${config.services.mpd.dataDir}/fifo";
|
||
visualizer_in_stereo = "yes";
|
||
visualizer_look = "●█";
|
||
visualizer_output_name = "fifo";
|
||
visualizer_spectrum_dft_size = 1;
|
||
|
||
# Song list formatting
|
||
song_columns_list_format = lib.concatStringsSep " " [
|
||
"(6f)[green]{NE}"
|
||
"(45)[white]{t|f:Title}"
|
||
"(20)[]{a}"
|
||
"(25)[cyan]{b}"
|
||
"(5f)[blue]{P}"
|
||
"(7f)[magenta]{l}"
|
||
];
|
||
|
||
# Display lists in column mode by default
|
||
browser_display_mode = "columns";
|
||
search_engine_display_mode = "columns";
|
||
|
||
# Faster seeking
|
||
seek_time = 5;
|
||
|
||
# More modern UI
|
||
user_interface = "alternative";
|
||
|
||
# Misc
|
||
external_editor = "nvim";
|
||
};
|
||
};
|
||
|
||
home.packages = with pkgs; [
|
||
mpc_cli
|
||
];
|
||
|
||
home.sessionVariables.MPD_HOST = config.services.mpd.network.listenAddress;
|
||
}
|