127 lines
3.5 KiB
Nix
127 lines
3.5 KiB
Nix
{
|
|
description = "MPD Discord daemon";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
fenix = {
|
|
url = "github:nix-community/fenix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils, fenix, ... }:
|
|
let
|
|
overlay = final: prev:
|
|
let
|
|
fenixPkgs = fenix.packages.${final.stdenv.hostPlatform.system};
|
|
rustToolchain =
|
|
with fenixPkgs;
|
|
combine (with stable; [
|
|
clippy
|
|
rustc
|
|
cargo
|
|
rustfmt
|
|
rust-src
|
|
]);
|
|
in
|
|
{
|
|
inherit rustToolchain;
|
|
|
|
mpd-discord-presence = final.rustPlatform.buildRustPackage {
|
|
pname = "mpd-discord-presence";
|
|
version = "0.1.0";
|
|
|
|
src = self;
|
|
|
|
cargoLock.lockFile = ./Cargo.lock;
|
|
|
|
enableParallelBuild = true;
|
|
|
|
meta = {
|
|
description = "MPD Discord daemon";
|
|
homepage = "https://git.slendi.dev/Slendi/mpd-discord-presence";
|
|
license = final.lib.licenses.gpl3;
|
|
mainProgram = "mpd-discord-presence";
|
|
};
|
|
};
|
|
};
|
|
in
|
|
{
|
|
overlays.default = overlay;
|
|
|
|
homeManagerModules.mpd-discord-presence = { config, lib, pkgs, ... }:
|
|
let
|
|
cfg = config.services.mpd-discord-presence;
|
|
in
|
|
{
|
|
options.services.mpd-discord-presence = {
|
|
enable = lib.mkEnableOption "mpd-discord-presence (systemd user service)";
|
|
|
|
package = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = self.packages.${pkgs.system}.mpd-discord-presence;
|
|
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" ];
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|
|
// flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [ overlay ];
|
|
};
|
|
in
|
|
{
|
|
packages = {
|
|
mpd-discord-presence = pkgs.mpd-discord-presence;
|
|
default = pkgs.mpd-discord-presence;
|
|
};
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
packages = with pkgs; [
|
|
rustToolchain
|
|
openssl
|
|
pkg-config
|
|
cargo-deny
|
|
cargo-edit
|
|
cargo-watch
|
|
rust-analyzer
|
|
];
|
|
|
|
shellHook = ''
|
|
export RUST_SRC_PATH="${pkgs.rustToolchain}/lib/rustlib/src/rust/library"
|
|
'';
|
|
};
|
|
});
|
|
}
|