mpd: Manage with home-manager

This commit is contained in:
Simon Bruder 2020-11-07 15:27:13 +01:00
parent fa231a7196
commit 546060a7b8
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
4 changed files with 66 additions and 53 deletions

View file

@ -1,52 +0,0 @@
{ pkgs, ... }:
let
mpdConf = pkgs.writeText "mpd.conf" ''
music_directory "~/Music"
playlist_directory "~/.mpd/playlists"
db_file "~/.mpd/tag_cache"
state_file "~/.mpd/state"
sticker_file "~/.mpd/sticker.sql"
bind_to_address "127.0.0.1"
zeroconf_enabled "no"
restore_paused "yes"
replaygain "track"
audio_output {
type "pulse"
name "pulse"
}
audio_output {
type "fifo"
name "fifo"
path "~/.mpd/fifo"
format "44100:16:2"
}
'';
in
{
imports = [
./pulseaudio.nix
];
systemd.user.services.mpd = {
after = [ "network.target" "sound.target" ];
description = "Music Player Daemon";
wantedBy = [ "default.target" ];
partOf = [ "default.target" ];
serviceConfig = {
ExecStart = "${pkgs.mpd}/bin/mpd --no-daemon ${mpdConf}";
Type = "notify";
ExecStartPre = ''${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p ~/Music ~/.mpd/playlists"'';
};
};
environment.systemPackages = with pkgs; [
mpc_cli
(pkgs.ncmpcpp.override { visualizerSupport = true; taglibSupport = false; })
];
}

View file

@ -9,7 +9,6 @@
../modules/fonts.nix ../modules/fonts.nix
../modules/gui-tools.nix ../modules/gui-tools.nix
(import ../modules/media.nix { inherit pkgs; gui = true; }) (import ../modules/media.nix { inherit pkgs; gui = true; })
../modules/mpd.nix
../modules/network-manager.nix ../modules/network-manager.nix
../modules/office.nix ../modules/office.nix
../modules/pulseaudio.nix ../modules/pulseaudio.nix

View file

@ -34,6 +34,7 @@ in
./modules/ankisyncd.nix ./modules/ankisyncd.nix
./modules/gtk.nix ./modules/gtk.nix
./modules/htop.nix ./modules/htop.nix
./modules/mpd.nix
./modules/sway.nix ./modules/sway.nix
./modules/xdg.nix ./modules/xdg.nix
./modules/zathura.nix ./modules/zathura.nix

View file

@ -0,0 +1,65 @@
{ config, pkgs, ... }:
{
services.mpd = {
enable = true;
musicDirectory = "~/Music";
extraConfig = ''
zeroconf_enabled "no"
restore_paused "yes"
replaygain "track"
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; };
mpdMusicDir = null; # does not work (not of type `null or path')
settings = {
# Visualizer
visualizer_fifo_path = "${config.services.mpd.dataDir}/fifo";
visualizer_in_stereo = "yes";
visualizer_look = "+|";
visualizer_output_name = "fifo";
visualizer_sync_interval = "15";
visualizer_type = "spectrum";
# Song list formatting
song_columns_list_format = builtins.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";
};
};
home.packages = with pkgs; [
mpc_cli
];
}