1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

rescrobbled: add module

This commit is contained in:
awwpotato 2025-08-05 21:24:21 -07:00 committed by Austin Horstman
parent f6cc29aab0
commit ad5d2b4aa7
5 changed files with 131 additions and 0 deletions

1
.github/labeler.yml vendored
View file

@ -24,6 +24,7 @@
- modules/services/pasystray.nix
- modules/services/playerctld.nix
- modules/services/pulseeffects.nix
- modules/services/rescrobbled.nix
- modules/services/spotifyd.nix
- tests/modules/services/mpd/**/*
"automation":

View file

@ -0,0 +1,12 @@
{ pkgs, ... }:
{
time = "2025-08-06T04:18:50+00:00";
condition = pkgs.stdenv.hostPlatform.isLinux;
message = ''
A new service is available: 'services.rescrobbled'.
Rescrobbled is a music scrobbler daemon. It detects active media players
running on D-Bus using MPRIS automatically updates "now playing" status, and
scrobbles songs to Last.fm or ListenBrainz-compatible services as they play.
'';
}

View file

@ -0,0 +1,68 @@
{
lib,
pkgs,
config,
...
}:
let
tomlFormat = pkgs.formats.toml { };
cfg = config.services.rescrobbled;
in
{
meta.maintainers = [ lib.maintainers.awwpotato ];
options.services.rescrobbled = {
enable = lib.mkEnableOption "rescrobbled, a MPRIS music scrobbler daemon";
package = lib.mkPackageOption pkgs "rescrobbled" { };
settings = lib.mkOption {
inherit (tomlFormat) type;
default = { };
description = ''
Configuration written to {file}`$XDG_CONFIG_HOME/rescrobbled/config.toml`
See <https://github.com/InputUsername/rescrobbled#configuration> for
the full list of options.
'';
example = {
lastfm-key = "Last.fm API key";
lastfm-secret = "Last.fm API secret";
min-play-time = 0;
player-whitelist = [ "Player MPRIS identity or bus name" ];
filter-script = "path/to/script";
use-track-start-timestamp = false;
listenbrainz = [
{
url = "Custom API URL";
token = "User token";
}
];
};
};
};
config = lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.rescrobbled" pkgs lib.platforms.linux)
];
home.packages = [ cfg.package ];
xdg.configFile."rescrobbled/config.toml" = lib.mkIf (cfg.settings != { }) {
source = tomlFormat.generate "rescrobbled-config" cfg.settings;
};
systemd.user.services.rescrobbled = {
Unit = {
Description = "An MPRIS scrobbler";
Documentation = "https://github.com/InputUsername/rescrobbled";
Wants = [ "network-online.target" ];
After = [ "network-online.target" ];
};
Service.ExecStart = lib.getExe cfg.package;
Install.WantedBy = [ "default.target" ];
};
};
}

View file

@ -0,0 +1,46 @@
{ pkgs, ... }:
{
services.rescrobbled = {
enable = true;
settings = {
lastfm-key = "Last.fm API key";
lastfm-secret = "Last.fm API secret";
min-play-time = 0;
player-whitelist = [ "Player MPRIS identity or bus name" ];
filter-script = "path/to/script";
use-track-start-timestamp = false;
listenbrainz = [
{
url = "Custom API URL";
token = "User token";
}
];
};
};
nmt.script = ''
assertFileExists home-files/.config/rescrobbled/config.toml
assertFileContent home-files/.config/rescrobbled/config.toml \
${pkgs.writeText "settings-expected" ''
filter-script = "path/to/script"
lastfm-key = "Last.fm API key"
lastfm-secret = "Last.fm API secret"
min-play-time = 0
player-whitelist = ["Player MPRIS identity or bus name"]
use-track-start-timestamp = false
[[listenbrainz]]
token = "User token"
url = "Custom API URL"
''}
service=home-files/.config/systemd/user/rescrobbled.service
assertFileExists $service
assertFileRegex $service 'Description=An MPRIS scrobbler'
assertFileRegex $service 'Wants=network-online.target'
assertFileRegex $service 'After=network-online.target'
assertFileRegex $service 'WantedBy=default.target'
'';
}

View file

@ -0,0 +1,4 @@
{ lib, pkgs, ... }:
lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
rescrobbled-basic-config = ./basic-config.nix;
}