From 17be85d4155628b7a6a8c3e76641f20a91af4da4 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 25 Jan 2026 00:46:33 +0100 Subject: modules/{mpdpopm,legacy/beets}: Move the mpd stat tracking to mpdpopm It is just easier to use the hand-written rust version, than to try to do this via the beets plugin. --- modules/by-name/mp/mpdpopm/module.nix | 65 ++++++++++++++++++++++ modules/home.legacy/conf/beets/default.nix | 1 - modules/home.legacy/conf/beets/plugins.nix | 7 --- modules/home.legacy/conf/beets/plugins/default.nix | 1 - .../conf/beets/plugins/smartplaylist/default.nix | 42 -------------- 5 files changed, 65 insertions(+), 51 deletions(-) create mode 100644 modules/by-name/mp/mpdpopm/module.nix delete mode 100644 modules/home.legacy/conf/beets/plugins/smartplaylist/default.nix (limited to 'modules') diff --git a/modules/by-name/mp/mpdpopm/module.nix b/modules/by-name/mp/mpdpopm/module.nix new file mode 100644 index 00000000..3524554c --- /dev/null +++ b/modules/by-name/mp/mpdpopm/module.nix @@ -0,0 +1,65 @@ +# nixos-config - My current NixOS configuration +# +# Copyright (C) 2025 Benedikt Peetz +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of my nixos-config. +# +# You should have received a copy of the License along with this program. +# If not, see . +{ + config, + pkgs, + libraries, + lib, + ... +}: let + cfg = config.soispha.services.mpdpopm; + + settingsFormat = pkgs.formats.json {}; +in { + options.soispha.services.mpdpopm = { + enable = libraries.base.options.mkEnable "mpdpopm"; + + settings = lib.mkOption { + # Setting this type allows for correct merging behavior + inherit (settingsFormat) type; + default = {}; + description = '' + Configuration for foo, see + + for supported settings. + ''; + }; + }; + + config = lib.mkIf cfg.enable { + soispha.services.mpdpopm.settings = { + version = "1"; + log = "${config.home-manager.users.soispha.xdg.dataHome}/mpdpopm/log"; + + conn.Local = { + path = config.home-manager.users.soispha.home.sessionVariables.MPD_HOST; + }; + + local_music_dir = config.soispha.services.mpd.directories.music; + }; + + home-manager.users.soispha = { + systemd.user.services.mpdpopm = { + Unit = { + Description = "mpdpopm ratings and playcounts for MPD"; + Requires = ["mpd.service"]; + After = ["mpd.service"]; + }; + + Service = { + Restart = "on-failure"; + ExecStart = "${lib.getExe' pkgs.mpdpopm "mpdpopmd"} --config ${settingsFormat.generate "config.json" cfg.settings}"; + }; + + Install = {WantedBy = ["default.target"];}; + }; + }; + }; +} diff --git a/modules/home.legacy/conf/beets/default.nix b/modules/home.legacy/conf/beets/default.nix index 2fec6881..0132a859 100644 --- a/modules/home.legacy/conf/beets/default.nix +++ b/modules/home.legacy/conf/beets/default.nix @@ -105,7 +105,6 @@ in { }; mpdIntegration = { - enableStats = true; enableUpdate = true; host = config.home.sessionVariables.MPD_HOST; }; diff --git a/modules/home.legacy/conf/beets/plugins.nix b/modules/home.legacy/conf/beets/plugins.nix index ed78b49e..01d022c4 100644 --- a/modules/home.legacy/conf/beets/plugins.nix +++ b/modules/home.legacy/conf/beets/plugins.nix @@ -29,12 +29,6 @@ # Show tags on files/queries "info" - # Create playlist from `play_count`/`skip_count` (gathered by the `mpdstats` - # plugin) - # Note that this should come _before_ the `mpdupdate` plugin, to ensure that - # `mpdupgate` can propagate changed playlist to `mpd`. - "smartplaylist" - "inline" # Warn, when importing a matching item @@ -58,6 +52,5 @@ # Allow beets to understand deezer id's # "deezer" - "mpdstats" # Transfer MPD stats to beets "mpdupdate" # Update MPD database on import ] diff --git a/modules/home.legacy/conf/beets/plugins/default.nix b/modules/home.legacy/conf/beets/plugins/default.nix index d22369be..2b2bd607 100644 --- a/modules/home.legacy/conf/beets/plugins/default.nix +++ b/modules/home.legacy/conf/beets/plugins/default.nix @@ -15,7 +15,6 @@ ./inline ./lyrics ./replaygain - ./smartplaylist # ./xtractor ]; } diff --git a/modules/home.legacy/conf/beets/plugins/smartplaylist/default.nix b/modules/home.legacy/conf/beets/plugins/smartplaylist/default.nix deleted file mode 100644 index 9b52c1ad..00000000 --- a/modules/home.legacy/conf/beets/plugins/smartplaylist/default.nix +++ /dev/null @@ -1,42 +0,0 @@ -# nixos-config - My current NixOS configuration -# -# Copyright (C) 2025 Benedikt Peetz -# SPDX-License-Identifier: GPL-3.0-or-later -# -# This file is part of my nixos-config. -# -# You should have received a copy of the License along with this program. -# If not, see . -{config, ...}: { - programs.beets.settings.smartplaylist = { - relative_to = config.services.mpd.musicDirectory; - playlist_dir = config.services.mpd.playlistDirectory; - forward_slash = false; - - # Show the real m3u file paths, when running `--pretend` - pretend_paths = true; - - playlists = [ - { - name = "artists-$first_artist.m3u"; - query = ""; - } - { - name = "ratings-good.m3u"; - query = "rating:0.7..1.0"; - } - { - name = "ratings-mediocre.m3u"; - query = "rating:0.4..0.7"; - } - { - name = "ratings-bad.m3u"; - query = "rating:0.0..0.4"; - } - { - name = "not_played.m3u"; - query = "-play_count: artist:"; - } - ]; - }; -} -- cgit 1.4.1