From b2fd6ef461dbf516fe7b3476ab6e5e3f06bed58b Mon Sep 17 00:00:00 2001 From: Slendi Date: Thu, 29 Jan 2026 16:33:02 +0200 Subject: [PATCH] package for nix Signed-off-by: Slendi --- LICENSE | 15 ++++++++++++ flake.nix | 27 ++++++++++++++++++++-- nix/mpd-discord-presence.nix | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 LICENSE create mode 100644 nix/mpd-discord-presence.nix diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..645a9aa --- /dev/null +++ b/LICENSE @@ -0,0 +1,15 @@ +mpd-discord-presence: MPD Discord daemon +Copyright (C) 2025 Slendi + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published +by the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . diff --git a/flake.nix b/flake.nix index 847a371..ca0ab3e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "Rust flake"; + description = "MPD Discord daemon"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -12,6 +12,7 @@ outputs = { + self, nixpkgs, flake-utils, fenix, @@ -21,7 +22,7 @@ overlay = final: prev: let - fenixPkgs = fenix.packages.${final.system}; + fenixPkgs = fenix.packages.${final.stdenv.hostPlatform.system}; in { rustToolchain = @@ -40,6 +41,7 @@ in { overlays.default = overlay; + homeManagerModules.mpd-discord-presence = import ./nix/mpd-discord-presence.nix; } // flake-utils.lib.eachDefaultSystem ( system: @@ -65,6 +67,27 @@ export RUST_SRC_PATH="${pkgs.rustToolchain}/lib/rustlib/src/rust/library" ''; }; + + packages = rec { + mpd-discord-presence = pkgs.rustPlatform.buildRustPackage { + pname = "mpd-discord-presence"; + version = "0.1.0"; + + src = ./.; + + cargoLock.lockFile = ./Cargo.lock; + + enableParallelBuild = true; + + meta = { + description = "MPD Discord daemon"; + homepage = "https://git.slendi.dev/Slendi/mpd-discord-presence"; + license = pkgs.lib.licenses.gpl3; + mainProgrma = "mpd-discord-presence"; + }; + }; + default = mpd-discord-presence; + }; } ); } diff --git a/nix/mpd-discord-presence.nix b/nix/mpd-discord-presence.nix new file mode 100644 index 0000000..88a5d29 --- /dev/null +++ b/nix/mpd-discord-presence.nix @@ -0,0 +1,45 @@ +{ config, lib, pkgs, self, ... }: +let + cfg = config.mpd-discord-presence; + defaultPkg = + self.packages.${pkgs.stdenv.hostPlatform.system}.mpd-discord-presence; +in +{ + options.mpd-discord-presence = { + enable = lib.mkEnableOption "mpd-discord-presence (systemd user service)"; + + package = lib.mkOption { + type = lib.types.package; + default = defaultPkg; + description = "Package providing the mpd-discord-presence binary."; + }; + + extraArgs = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = []; + description = "Extra CLI args passed to mpd-discord-presence."; + }; + }; + + config = lib.mkIf cfg.enable { + home.packages = [ cfg.package ]; + + systemd.user.services.mpd-discord-presence = { + Unit = { + Description = "MPD Discord Presence"; + Wants = [ "mpd.service" ]; + After = [ "mpd.service" "network-online.target" ]; + }; + + Service = { + ExecStart = "${cfg.package}/bin/mpd-discord-presence ${lib.escapeShellArgs cfg.extraArgs}"; + Restart = "on-failure"; + RestartSec = 2; + }; + + Install = { + WantedBy = [ "default.target" ]; + }; + }; + }; +}