feat: add mpd for beets' play plugin
This commit is contained in:
parent
54d13d037e
commit
6bd0a92f95
3 changed files with 69 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
description = "Nydragon's NixOS configuration";
|
||||
description = "Nydragon's system configuration";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
|
@ -56,6 +56,7 @@
|
|||
{ pkgs, inputs', ... }:
|
||||
{
|
||||
formatter = pkgs.nixfmt-rfc-style;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
pre-commit
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
{ pkgs, lib, ... }:
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
osConfig,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib) concatStringsSep listToAttrs;
|
||||
inherit (lib.my) getExe;
|
||||
plugins = [
|
||||
"convert"
|
||||
"chroma"
|
||||
|
@ -14,10 +21,46 @@ let
|
|||
"missing"
|
||||
"unimported"
|
||||
"badfiles"
|
||||
"embedart"
|
||||
"play"
|
||||
];
|
||||
|
||||
mkConf =
|
||||
a:
|
||||
let
|
||||
mkGroup = name: values: ''
|
||||
${name} {
|
||||
${lib.concatStringsSep "\n\t" values}
|
||||
}'';
|
||||
stringify = lib.mapAttrsToList (
|
||||
name: value:
|
||||
if lib.isAttrs value then
|
||||
mkGroup name (stringify value)
|
||||
else if (lib.isInt value || lib.isFloat value) then
|
||||
''${name} "${toString value}"''
|
||||
else
|
||||
''${name} "${value}"''
|
||||
);
|
||||
in
|
||||
concatStringsSep "\n" (stringify a);
|
||||
|
||||
mpdSocket = "/run/user/${toString osConfig.users.users.${config.home.username}.uid}/mpd/socket";
|
||||
in
|
||||
{
|
||||
config = {
|
||||
services.mpd = {
|
||||
enable = true;
|
||||
extraConfig = mkConf {
|
||||
auto_update = "yes";
|
||||
log_file = "syslog";
|
||||
bind_to_address = mpdSocket;
|
||||
audio_output = {
|
||||
type = "pipewire";
|
||||
name = "PipeWire Sound Server";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
programs.beets = {
|
||||
package = pkgs.beets.override {
|
||||
pluginOverrides = listToAttrs (
|
||||
|
@ -36,6 +79,26 @@ in
|
|||
format = "flac";
|
||||
never_convert_lossy_files = "yes";
|
||||
};
|
||||
play = {
|
||||
command =
|
||||
let
|
||||
mpc = "${getExe pkgs.mpc} --host=\"${mpdSocket}\"";
|
||||
ncmpcpp = getExe pkgs.ncmpcpp;
|
||||
|
||||
command = pkgs.writers.writeFishBin "play-command" ''
|
||||
set playlist "$argv[1]";
|
||||
${mpc} clear;
|
||||
${mpc} load "$playlist";
|
||||
rm "$playlist";
|
||||
${mpc} play;
|
||||
${ncmpcpp} $args;
|
||||
'';
|
||||
in
|
||||
"${command}/bin/play-command";
|
||||
};
|
||||
embedart = {
|
||||
maxwidth = 500;
|
||||
};
|
||||
fetchart = {
|
||||
auto = true;
|
||||
cover_format = "jpg";
|
||||
|
@ -67,7 +130,8 @@ in
|
|||
languages = "en";
|
||||
};
|
||||
item_fields = {
|
||||
disc_and_track = "u'%02i.%02i' % (disc, track) if disctotal > 1 else u'%02i' % (track)";
|
||||
disc_and_track = # python
|
||||
"u'%02i.%02i' % (disc, track) if disctotal > 1 else u'%02i' % (track)";
|
||||
primary_albumartist = # python
|
||||
''
|
||||
if albumartist.lower().strip().startswith(albumartists[0].lower().strip()):
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
"wheel"
|
||||
];
|
||||
shell = pkgs.fish;
|
||||
uid = 1000;
|
||||
};
|
||||
programs.fish.enable = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue