From f8e3e1267441bca037c0f2cb6ad376fdbdd2c072 Mon Sep 17 00:00:00 2001 From: "Reid \"reidlab" Date: Wed, 11 Sep 2024 15:29:00 -0700 Subject: [PATCH] untested hm module --- README.md | 2 -- flake.nix | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a123a85..5d96da9 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ a rust application to scrobble your currently playing song on last.fm with mpris -upd 2024-08-27: i'm adding a home-manager module, eventually! - ## limitations unfortunately, because of how most mpris players work, the [Track_Id](https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Simple-Type:Track_Id) (unique identifier for every song in the tracklist) object is very rarely supported, or, if supported, implemented incorrectly (looking at you, [Cider](https://cider.sh/)) meaning it is impossible to tell if the track has been played twice in a row. this means you cannot have succssive scrobbles of the same song, sorry! besides this, i'd say the program is feature complete. diff --git a/flake.nix b/flake.nix index 3f14fd1..626eb2d 100644 --- a/flake.nix +++ b/flake.nix @@ -22,7 +22,8 @@ toolchain = pkgs.rust-bin.fromRustupToolchainFile ./toolchain.toml; in rec { - packages = flake-utils.lib.flattenTree { + packages = flake-utils.lib.flattenTree rec { + default = lastfmpris; lastfmpris = rustPlatform.buildRustPackage { pname = package.name; inherit (package) version; @@ -31,21 +32,19 @@ # very scuffed but endorsed! #cargoSha256 = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; cargoSha256 = "sha256-KOMEvg3iGjmMEFxsrIqD4SaDw63ojiNNNqCfzRlbYLw="; + + nativeBuildInputs = with pkgs; [ pkg-config ]; - buildInputs = with pkgs; [ pkg-config ]; - - nativeBuildInputs = with pkgs; [ openssl dbus ]; + buildInputs = with pkgs; [ openssl dbus ]; src = ./.; }; }; - defaultPackage = packages.lastfmpris; - devShells.default = pkgs.mkShell { - buildInputs = with pkgs; [ pkg-config ]; + nativeBuildInputs = with pkgs; [ pkg-config ]; - nativeBuildInputs = with pkgs; [ openssl dbus ]; + buildInputs = with pkgs; [ openssl dbus ]; packages = with pkgs; [ toolchain @@ -54,5 +53,39 @@ RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; }; - }); + }) // { + homeManagerModules = rec { + default = lastfmpris; + lastfmpris = { config, lib, pkgs, ... }: + with lib; + let + cfg = config.services.lastfmpris; + in { + options.services.lastfmpris = { + enable = mkEnableOption "Enables the lastfmpris mpris scrobbling daemon"; + package = mkOption { + type = types.package; + default = self.packages.${pkgs.stdenv.hostPlatform.system}.default; + }; + }; + + config = mkIf cfg.enable { + systemd.user.services.lastfmpris = { + Unit = { + Description = "a rust application to scrobble your currently playing song on last.fm with mpris"; + Requires = ["graphical-session.target"]; + }; + Service = { + Type = "simple"; + ExecStart = "${lib.getExe cfg.package}"; + }; + }; + + home.packages = [ + cfg.package + ]; + }; + }; + }; + }; }