Package rescrobbled from an open nixpkgs PR, add home-manager module for it
This commit is contained in:
parent
abfdb8a590
commit
e3e3f34646
9 changed files with 182 additions and 5 deletions
|
@ -17,6 +17,7 @@ This folder contains sub-folders for each of my NixOS hosts, of which there is o
|
||||||
This folder contains all of my personally-made nix packages. This is mainly just packages I can't seem to find on the interwebs, like some themes. Theoretically they could be used by someone else, but I haven't quite made my config modular yet, so don't try.
|
This folder contains all of my personally-made nix packages. This is mainly just packages I can't seem to find on the interwebs, like some themes. Theoretically they could be used by someone else, but I haven't quite made my config modular yet, so don't try.
|
||||||
|
|
||||||
| Package | License | Original Link |
|
| Package | License | Original Link |
|
||||||
| ------------------- | ------- | ---------------------------------------------------------------------- |
|
| ------------------- | ------- | ---------------------------------------------------------------------------------|
|
||||||
| BeautyLine (Garuda) | GPLv3 | https://gitlab.com/garuda-linux/themes-and-settings/artwork/beautyline |
|
| BeautyLine (Garuda) | GPLv3 | https://gitlab.com/garuda-linux/themes-and-settings/artwork/beautyline |
|
||||||
| Magna Splash 6 | GPLv3 | https://www.pling.com/p/2136626/ |
|
| Magna Splash 6 | GPLv3 | https://www.pling.com/p/2136626/ |
|
||||||
|
| Rescrobbled | GPLv3 | https://github.com/NixOS/nixpkgs/pull/274553 (unmerged nixpkgs PR by negatethis) |
|
||||||
|
|
|
@ -83,6 +83,7 @@
|
||||||
# the path to your home.nix.
|
# the path to your home.nix.
|
||||||
modules = [
|
modules = [
|
||||||
plasma-manager.homeManagerModules.plasma-manager
|
plasma-manager.homeManagerModules.plasma-manager
|
||||||
|
./home-manager/custom-modules
|
||||||
./home-manager/home.nix
|
./home-manager/home.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
6
home-manager/custom-modules/default.nix
Normal file
6
home-manager/custom-modules/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./rescrobbled.nix
|
||||||
|
];
|
||||||
|
}
|
85
home-manager/custom-modules/rescrobbled.nix
Normal file
85
home-manager/custom-modules/rescrobbled.nix
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
{ pkgs, lib, config, ... }:
|
||||||
|
let tomlFormat = pkgs.formats.toml { }; in {
|
||||||
|
options = {
|
||||||
|
services.custom.rescrobbled = {
|
||||||
|
enable = lib.mkEnableOption "rescrobbled";
|
||||||
|
|
||||||
|
package = lib.mkOption {
|
||||||
|
type = lib.types.package;
|
||||||
|
default = (pkgs.callPackage ../../packages/rescrobbled {});
|
||||||
|
defaultText = lib.literalExpression "pkgs.rescrobbled";
|
||||||
|
description = "The package to use for rescrobbled";
|
||||||
|
};
|
||||||
|
|
||||||
|
session = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = ''
|
||||||
|
The session token to use for last.fm.
|
||||||
|
This can be found by setting a last.fm API key & secret,
|
||||||
|
and then manually running the daemon. Then, the session token
|
||||||
|
will be located at {file}`$XDG_CONFIG_HOME/rescrobbled/session`.
|
||||||
|
'';
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
settings = lib.mkOption {
|
||||||
|
type = tomlFormat.type;
|
||||||
|
default = {};
|
||||||
|
example = lib.literalExpression ''
|
||||||
|
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"
|
||||||
|
|
||||||
|
[[listenbrainz]]
|
||||||
|
url = "Custom API URL"
|
||||||
|
token = "User token"
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
Configuration written to
|
||||||
|
{file}`$XDG_CONFIG_HOME/rescrobbled/config.toml`.
|
||||||
|
|
||||||
|
See <https://github.com/InputUsername/rescrobbled#configuration> for the full list
|
||||||
|
of options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = let cfg = config.services.custom.rescrobbled; in lib.mkIf cfg.enable {
|
||||||
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
|
xdg.configFile ={
|
||||||
|
"rescrobbled/config.toml" = lib.mkIf (cfg.settings != { }) {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
source = tomlFormat.generate "rescrobbled-config" cfg.settings;
|
||||||
|
};
|
||||||
|
|
||||||
|
"rescrobbled/session" = lib.mkIf (cfg.settings != { }) {
|
||||||
|
enable = true;
|
||||||
|
# Force makes it easy to generate the session file, then add it to nix cfg without issues
|
||||||
|
force = true;
|
||||||
|
|
||||||
|
text = cfg.session;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.user.services.rescrobbled = {
|
||||||
|
Unit = {
|
||||||
|
Description = "An MPRIS scrobbler";
|
||||||
|
Documentation = "https://github.com/InputUsername/rescrobbled";
|
||||||
|
Wants = "network-online.target";
|
||||||
|
After = "network-online.target";
|
||||||
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
ExecStartPre = "${pkgs.coreutils}/bin/sleep 15"; # Avoid listenbrainz errors by adding delay till network is connected
|
||||||
|
ExecStart = "${cfg.package}/bin/rescrobbled";
|
||||||
|
};
|
||||||
|
|
||||||
|
Install.WantedBy = [ "default.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -2,7 +2,10 @@
|
||||||
{
|
{
|
||||||
home-manager.useGlobalPkgs = true;
|
home-manager.useGlobalPkgs = true;
|
||||||
home-manager.useUserPackages = true;
|
home-manager.useUserPackages = true;
|
||||||
home-manager.sharedModules = [ inputs.plasma-manager.homeManagerModules.plasma-manager ];
|
home-manager.sharedModules = [
|
||||||
|
inputs.plasma-manager.homeManagerModules.plasma-manager
|
||||||
|
./custom-modules
|
||||||
|
];
|
||||||
home-manager.extraSpecialArgs = {
|
home-manager.extraSpecialArgs = {
|
||||||
inherit inputs system secrets;
|
inherit inputs system secrets;
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,5 +17,6 @@
|
||||||
./modules/desktop.nix
|
./modules/desktop.nix
|
||||||
./modules/gtk.nix
|
./modules/gtk.nix
|
||||||
./modules/beets.nix
|
./modules/beets.nix
|
||||||
|
./modules/rescrobbled.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
21
home-manager/modules/rescrobbled.nix
Normal file
21
home-manager/modules/rescrobbled.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{ secrets, lib, ... }:
|
||||||
|
{
|
||||||
|
services.custom.rescrobbled = let s = secrets.programs.rescrobbled; in lib.mkIf s.enable {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
session = s.lastfm.session;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
player-whitelist = [ "elisa" ];
|
||||||
|
|
||||||
|
listenbrainz = lib.mkIf (s.listenbrainz.token != null) [
|
||||||
|
{
|
||||||
|
token = s.listenbrainz.token;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
lastfm-key = lib.mkIf (s.lastfm.key != null && s.lastfm.secret != null) s.lastfm.key;
|
||||||
|
lastfm-secret = lib.mkIf (s.lastfm.key != null && s.lastfm.secret != null) s.lastfm.secret;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
44
packages/rescrobbled/default.nix
Normal file
44
packages/rescrobbled/default.nix
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
{ lib
|
||||||
|
, bash
|
||||||
|
, fetchFromGitHub
|
||||||
|
, rustPlatform
|
||||||
|
, pkg-config
|
||||||
|
, openssl
|
||||||
|
, dbus
|
||||||
|
}:
|
||||||
|
|
||||||
|
rustPlatform.buildRustPackage rec {
|
||||||
|
|
||||||
|
pname = "rescrobbled";
|
||||||
|
version = "0.7.1";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "InputUsername";
|
||||||
|
repo = "rescrobbled";
|
||||||
|
rev = "v${version}";
|
||||||
|
hash = "sha256-1E+SeKjHCah+IFn2QLAyyv7jgEcZ1gtkh8iHgiVBuz4=";
|
||||||
|
};
|
||||||
|
|
||||||
|
cargoHash = "sha256-ZJbyYFvGTuXt1aqhGOATcDRrkTk7SorWXkN81sUoDdo=";
|
||||||
|
|
||||||
|
nativeBuildInputs = [ pkg-config ];
|
||||||
|
|
||||||
|
buildInputs = [ openssl dbus ];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
# Required for tests
|
||||||
|
substituteInPlace src/filter.rs --replace '#!/usr/bin/bash' '#!${bash}/bin/bash'
|
||||||
|
'';
|
||||||
|
|
||||||
|
postInstall = ''
|
||||||
|
substituteInPlace rescrobbled.service --replace '%h/.cargo/bin/rescrobbled' "$out/bin/rescrobbled"
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "MPRIS music scrobbler daemon";
|
||||||
|
homepage = "https://github.com/InputUsername/rescrobbled";
|
||||||
|
license = licenses.gpl3Plus;
|
||||||
|
mainProgram = "rescrobbled";
|
||||||
|
platforms = platforms.unix;
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,6 +4,21 @@
|
||||||
# The API key to use for google custom search lyrics backend
|
# The API key to use for google custom search lyrics backend
|
||||||
google_api_key = null;
|
google_api_key = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
rescrobbled = {
|
||||||
|
enable = false;
|
||||||
|
|
||||||
|
# The credentials to use for last.fm and listenbrainz
|
||||||
|
lastfm = {
|
||||||
|
key = null;
|
||||||
|
secret = null;
|
||||||
|
# Generated by manually running the rescrobbled daemon and reading $XDG_CONFIG_HOME/rescrobbled/session
|
||||||
|
session = null;
|
||||||
|
};
|
||||||
|
listenbrainz = {
|
||||||
|
token = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
passwords = {
|
passwords = {
|
||||||
|
|
Loading…
Reference in a new issue