Files
millerson-overlay.nix/packages/kyojin/package.nix
T
2026-11-18 18:31:54 +03:00

55 lines
1.6 KiB
Nix

{
pkgs,
kyojin,
exllamav3,
jitCheck,
cpuCheck,
}:
let
admissionPatch = ./prefix-disk-admission.patch;
engine = exllamav3.overrideAttrs (old: {
patches = (old.patches or [ ]) ++ [ admissionPatch ];
});
# Both the upstream serve wrappers and the CPU check prepend the wheel to PYTHONPATH.
withEngine =
script:
let
updated = builtins.replaceStrings [ "${exllamav3}/" ] [ "${engine}/" ] script;
in
assert updated != script;
updated;
in
kyojin.overrideAttrs (old: {
installPhase = withEngine old.installPhase;
# Upstream installs tools directly from $src, bypassing the unpacked tree.
src = pkgs.applyPatches {
src = old.src;
patches = [ ./short-reply-prefill-grace.patch ];
};
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.makeWrapper ];
meta = (old.meta or { }) // {
homepage = "https://github.com/Yamz-Labs/kyojin";
license = pkgs.lib.licenses.mit;
};
passthru = (old.passthru or { }) // {
category = "AI Inference";
tests = (old.passthru.tests or { }) // {
jit = jitCheck;
cpu = cpuCheck.overrideAttrs (check: {
patches = (check.patches or [ ]) ++ [ admissionPatch ];
checkPhase = withEngine check.checkPhase;
});
};
};
postFixup = ''
# Fail the build, not the first request, if upstream renames the wrappers.
ls "$out"/bin/kyojin-serve-* > /dev/null 2>&1 || {
echo "kyojin-cc: no kyojin-serve-* in $out/bin; upstream moved them" >&2
exit 1
}
for b in $out/bin/kyojin-serve-*; do
wrapProgram "$b" --set CC ${pkgs.stdenv.cc}/bin/gcc
done
'';
})