nixos-config/users/simon/modules/mpd.nix

94 lines
2.7 KiB
Nix
Raw Permalink Normal View History

{ config, lib, nixosConfig, pkgs, ... }:
2020-11-07 15:27:13 +01:00
2021-01-30 13:27:29 +01:00
# 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 {
2020-11-07 15:27:13 +01:00
services.mpd = {
enable = true;
musicDirectory = "~/Music";
2020-12-05 18:53:35 +01:00
network.listenAddress = "${config.services.mpd.dataDir}/socket";
2020-11-07 15:27:13 +01:00
extraConfig = ''
zeroconf_enabled "no"
restore_paused "yes"
audio_output {
type "pulse"
name "pulse"
}
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 terminfos 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"'
'';
});
2020-11-07 15:27:13 +01:00
mpdMusicDir = null; # does not work (not of type `null or path')
settings = {
2020-12-05 18:53:35 +01:00
# Connection
2021-02-27 17:50:14 +01:00
mpd_host = config.services.mpd.network.listenAddress;
2020-12-05 18:53:35 +01:00
2020-11-07 15:27:13 +01:00
# Visualizer
visualizer_autoscale = true;
visualizer_data_source = "${config.services.mpd.dataDir}/fifo";
2020-11-07 15:27:13 +01:00
visualizer_in_stereo = "yes";
visualizer_look = "";
2020-11-07 15:27:13 +01:00
visualizer_output_name = "fifo";
visualizer_spectrum_dft_size = 1;
2020-11-07 15:27:13 +01:00
# Song list formatting
song_columns_list_format = lib.concatStringsSep " " [
2020-11-07 15:27:13 +01:00
"(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";
2021-07-02 18:02:41 +02:00
# Misc
external_editor = "nvim";
2020-11-07 15:27:13 +01:00
};
};
home.packages = with pkgs; [
mpc_cli
];
home.sessionVariables.MPD_HOST = config.services.mpd.network.listenAddress;
2020-11-07 15:27:13 +01:00
}