From bfe6c7c05c6cdfb18a0648ff74bd6d99ac0e60e1 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Fri, 27 Sep 2024 12:23:04 -0400 Subject: [PATCH] fix(servers): switch to working fork of jmusicbots --- .../docker/music/jbots/images/jmusicbot.nix | 51 ++++++++++++++++--- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/devices/nos/modules/docker/music/jbots/images/jmusicbot.nix b/devices/nos/modules/docker/music/jbots/images/jmusicbot.nix index 807cdb90..569aeb81 100644 --- a/devices/nos/modules/docker/music/jbots/images/jmusicbot.nix +++ b/devices/nos/modules/docker/music/jbots/images/jmusicbot.nix @@ -1,8 +1,43 @@ -pkgs: -pkgs.dockerTools.pullImage { - imageName = "craumix/jmusicbot"; - imageDigest = "sha256:ba0d7e7e4b1dba86981687e3c8ada6b7a7170c6b4884c12a16c6ee046e2df763"; - sha256 = "1h7fwbr4wlyxjdynfs7fb6yb0j7ng16v10q646mdblvlflngpf9s"; - finalImageName = "craumix/jmusicbot"; - finalImageTag = "latest"; -} +# Locked +pkgs: let + dname = "jmusicbot-docker"; + dtag = pkgs.jmusicbot.version; + + jre_modules = [ + "java.se" + "jdk.crypto.cryptoki" + ]; + jre = + (pkgs.jre_minimal.overrideAttrs { + buildPhase = '' + runHook preBuild + + # further optimizations for image size https://github.com/NixOS/nixpkgs/issues/169775 + jlink --module-path ${pkgs.jdk11_headless}/lib/openjdk/jmods --add-modules ${pkgs.lib.concatStringsSep "," jre_modules} --no-header-files --no-man-pages --compress=2 --output $out + + runHook postBuild + ''; + }) + .override {jdk = pkgs.jdk11_headless;}; + + jmusicbot = + (pkgs.jmusicbot.overrideAttrs rec { + version = "0.4.3.1"; + src = pkgs.fetchurl { + url = "https://github.com/xPrinny/MusicBot/releases/download/${version}/JMusicBot-${version}.jar"; + sha256 = "sha256-35JdmLArl9ssYDpdKDsBx3lu6TCN1JiCBI34W+uyVJ0="; + }; + meta.platforms = ["x86_64-linux"]; + }) + .override {jre_headless = jre;}; +in + pkgs.dockerTools.buildLayeredImage { + name = dname; + tag = dtag; + config = { + created = "now"; + Cmd = ["${jmusicbot}/bin/JMusicBot"]; + WorkingDir = "/jmb/config"; + Volumes."/jmb/config" = {}; + }; + }