Merge pull request #117847 from SuperSandro2000/jmusicbot

This commit is contained in:
Sandro 2021-04-05 06:20:56 +02:00 committed by GitHub
commit e039d12c85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 0 deletions

View File

@ -233,6 +233,7 @@
./services/audio/alsa.nix
./services/audio/jack.nix
./services/audio/icecast.nix
./services/audio/jmusicbot.nix
./services/audio/liquidsoap.nix
./services/audio/mpd.nix
./services/audio/mpdscribble.nix

View File

@ -0,0 +1,41 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.jmusicbot;
in
{
options = {
services.jmusicbot = {
enable = mkEnableOption "jmusicbot, a Discord music bot that's easy to set up and run yourself";
stateDir = mkOption {
type = types.path;
description = ''
The directory where config.txt and serversettings.json is saved.
If left as the default value this directory will automatically be created before JMusicBot starts, otherwise the sysadmin is responsible for ensuring the directory exists with appropriate ownership and permissions.
Untouched by the value of this option config.txt needs to be placed manually into this directory.
'';
default = "/var/lib/jmusicbot/";
};
};
};
config = mkIf cfg.enable {
systemd.services.jmusicbot = {
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ];
description = "Discord music bot that's easy to set up and run yourself!";
serviceConfig = mkMerge [{
ExecStart = "${pkgs.jmusicbot}/bin/JMusicBot";
WorkingDirectory = cfg.stateDir;
Restart = "always";
RestartSec = 20;
DynamicUser = true;
}
(mkIf (cfg.stateDir == "/var/lib/jmusicbot") { StateDirectory = "jmusicbot"; })];
};
};
meta.maintainers = with maintainers; [ SuperSandro2000 ];
}

View File

@ -0,0 +1,31 @@
{ stdenv, lib, fetchurl, makeWrapper, jre }:
stdenv.mkDerivation rec {
pname = "JMusicBot";
version = "0.3.4";
src = fetchurl {
url = "https://github.com/jagrosh/MusicBot/releases/download/${version}/JMusicBot-${version}.jar";
sha256 = "sha256-++/ot9k74pkN9Wl7IEjiMIv/q5zklIEdU6uFjam0tmU=";
};
dontUnpack = true;
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
mkdir -p $out/lib
cp $src $out/lib/JMusicBot
makeWrapper ${jre}/bin/java $out/bin/JMusicBot \
--add-flags "-Xmx1G -Dnogui=true -jar $out/lib/JMusicBot"
'';
meta = with lib; {
description = "Discord music bot that's easy to set up and run yourself";
homepage = "https://github.com/jagrosh/MusicBot";
license = licenses.asl20;
maintainers = with maintainers; [ SuperSandro2000 ];
platforms = platforms.all;
};
}

View File

@ -23078,6 +23078,8 @@ in
jdk = callPackage ../development/compilers/jetbrains-jdk { };
});
jmusicbot = callPackage ../applications/audio/jmusicbot { };
libquvi = callPackage ../applications/video/quvi/library.nix { };
librespot = callPackage ../applications/audio/librespot {