feat(jbot): move package to packages

This commit is contained in:
matt1432 2025-01-25 11:41:14 -05:00
parent ef74bd3c41
commit 8f1a3f6f21
4 changed files with 61 additions and 44 deletions

View file

@ -1,11 +1,14 @@
{
config,
pkgs,
self,
...
}: let
inherit (self.packages.${pkgs.system}) jmusicbot;
inherit (config.khepri) rwDataDir;
rwPath = rwDataDir + "/music/jbots";
image = import ./images/jmusicbot.nix {inherit pkgs jmusicbot;};
in {
khepri.compositions."jbots" = {
networks.proxy_net = {external = true;};
@ -13,8 +16,8 @@ in {
services = {
"musicbot_be" = {
containerName = "be";
image = import ./images/jmusicbot.nix pkgs;
restart = "always";
inherit image;
volumes = [
"${rwPath}/be:/jmb/config:rw"
@ -24,8 +27,8 @@ in {
"musicbot_br" = {
containerName = "br";
image = import ./images/jmusicbot.nix pkgs;
restart = "always";
inherit image;
volumes = [
"${rwPath}/br:/jmb/config:rw"

View file

@ -1,43 +1,15 @@
# 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.2";
src = pkgs.fetchurl {
url = "https://github.com/xPrinny/MusicBot/releases/download/${version}/JMusicBot-${version}.jar";
sha256 = "sha256-MEOWppkw74s81D1EJEqZMjOzDlLdH6uyanDZD5d+Xa4=";
};
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" = {};
};
}
{
pkgs,
jmusicbot,
}:
pkgs.dockerTools.buildLayeredImage {
name = "jmusicbot-docker";
tag = jmusicbot.version;
config = {
created = "now";
Cmd = ["${jmusicbot}/bin/JMusicBot"];
WorkingDir = "/jmb/config";
Volumes."/jmb/config" = {};
};
}

View file

@ -13,6 +13,8 @@
homepage = pkgs.callPackage ./homepage {};
jmusicbot = pkgs.callPackage ./jmusicbot {};
libratbag = pkgs.callPackage ./libratbag {
inherit (inputs) libratbag-src;
};

View file

@ -0,0 +1,40 @@
{
lib,
fetchurl,
jmusicbot,
jdk11_headless,
jre_minimal,
...
}: let
inherit (lib) concatStringsSep;
jre_modules = [
"java.se"
"jdk.crypto.cryptoki"
];
jre = (jre_minimal.override {jdk = jdk11_headless;}).overrideAttrs (o: {
buildPhase = ''
runHook preBuild
# further optimizations for image size https://github.com/NixOS/nixpkgs/issues/169775
jlink \
--module-path ${jdk11_headless}/lib/openjdk/jmods \
--add-modules ${concatStringsSep "," jre_modules} \
--no-header-files \
--no-man-pages \
--compress=2 \
--output $out
runHook postBuild
'';
});
in
(jmusicbot.override {jre_headless = jre;}).overrideAttrs (o: rec {
version = "0.4.3.2";
src = fetchurl {
url = "https://github.com/xPrinny/MusicBot/releases/download/${version}/JMusicBot-${version}.jar";
sha256 = "sha256-MEOWppkw74s81D1EJEqZMjOzDlLdH6uyanDZD5d+Xa4=";
};
meta.platforms = ["x86_64-linux"];
})