-
-
Notifications
You must be signed in to change notification settings - Fork 16.5k
llama-swap: init at v129 & llama-swap: init module #417516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
513fd0b
to
2079d16
Compare
Thank you for doing this. Feel free to incorporate the changes from here for supporting building the new react UI with version 126. {
lib,
buildGoModule,
buildNpmPackage,
fetchFromGitHub,
versionCheckHook,
}:
let
version = "126";
src = fetchFromGitHub {
owner = "mostlygeek";
repo = "llama-swap";
rev = "v${version}";
hash = "sha256-ZYGH7eAkasZ79V4DD3fuRcUUjHrvd4DPnAxcWVtkJY8=";
};
ui = buildNpmPackage (finalAttrs: {
pname = "llama-swap-ui";
inherit version src;
postPatch = ''
substituteInPlace vite.config.ts \
--replace '../proxy/ui_dist' '${placeholder "out"}/ui_dist'
'';
sourceRoot = "source/ui";
npmDepsHash = "sha256-smdqD1X9tVr0XMhQYpLBZ57/3iP8tYVoVJ2wR/gAC3w=";
postInstall = ''
rm -rf $out/lib
'';
meta = {
description = "llama-swap - UI";
license = lib.licenses.mit;
platform = lib.platforms.linux;
};
});
in
buildGoModule rec {
pname = "llama-swap";
inherit version src;
vendorHash = "sha256-5mmciFAGe8ZEIQvXejhYN+ocJL3wOVwevIieDuokhGU=";
preBuild = ''
cp -r ${ui}/ui_dist proxy/
'';
subPackages =
[
"."
"proxy"
]
++ lib.optionals doCheck [
"misc/process-cmd-test"
"misc/simple-responder"
];
nativeBuildInputs = [ versionCheckHook ];
ldflags = [
"-X main.version=${version}"
"-X main.date=unknown"
"-X main.commit=v${version}"
];
postInstall = ''
install -Dm444 -t $out/share/doc/${pname} *.md *.yaml
cp -r examples $out/share/doc/${pname}/
'';
# need to adjust proxy/helpers_test.go for it to find the binaries
doCheck = false;
# if we run the tests in installCheckPhase instead, adjust this
postCheck = ''
rm -f $out/bin/{process-cmd-test,simple-responder}
'';
doInstallCheck = true;
versionCheckProgramArg = "-version";
meta = {
description = "Model swapping for llama.cpp (or any local OpenAPI compatible server)";
license = lib.licenses.mit;
platform = lib.platforms.linux;
mainProgram = "llama-swap";
};
} |
As for the module, I would expect it to run as a user service either here or via home-manager. Having multiple users hitting the same |
b8f1abf
to
b257bb5
Compare
Hi, thanks for the addition of the UI to the package, I was not aware of it when i created this PR 😅. services.llama-swap = {
package = pkgs.llama-swap;
instances = {
john = {
enable = true;
...
},
doe = {
enable = true;
...
}
} |
I've been using llama-swap just fine on Darwin, so can we make this a |
In all fairness it was only added in the next version after your initial PR so it's rather difficult to blame you for not being able to see into the future! ;-)
Yes, exactly this and this is why I said that it really belongs in The problem with user services in nixos is that it's a little ugly to activate for individual users and why I wouldn't personally use the nixos module but rather my home-made hm module (which I really should upstream too....)
{
lib,
buildGoModule,
buildNpmPackage,
fetchFromGitHub,
versionCheckHook,
}:
let
version = "137";
src = fetchFromGitHub {
owner = "mostlygeek";
repo = "llama-swap";
rev = "v${version}";
hash = "sha256-DyAbZMTy4gvmF8HnUJ5B4ypIqhL9MDS7zBzeQfapFD8=";
};
ui = buildNpmPackage (finalAttrs: {
pname = "llama-swap-ui";
inherit version src;
postPatch = ''
substituteInPlace vite.config.ts \
--replace-fail '../proxy/ui_dist' '${placeholder "out"}/ui_dist'
'';
sourceRoot = "source/ui";
npmDepsHash = "sha256-smdqD1X9tVr0XMhQYpLBZ57/3iP8tYVoVJ2wR/gAC3w=";
postInstall = ''
rm -rf $out/lib
'';
meta = {
description = "llama-swap - UI";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ peterhoeg ];
platform = lib.platforms.linux;
};
});
in
buildGoModule rec {
pname = "llama-swap";
inherit version src;
vendorHash = "sha256-nSdvqYVBBVIdoa991bLVwfHPGAO4OHzW8lEQPQ6cuMs=";
preBuild = ''
cp -r ${ui}/ui_dist proxy/
'';
subPackages =
[
"."
"proxy"
]
++ lib.optionals doCheck [
"misc/process-cmd-test"
"misc/simple-responder"
];
nativeBuildInputs = [ versionCheckHook ];
ldflags = [
"-X main.version=${version}"
"-X main.date=unknown"
"-X main.commit=v${version}"
];
postInstall = ''
install -Dm444 -t $out/share/doc/${pname} *.md *.yaml
cp -r examples $out/share/doc/${pname}/
'';
# need to adjust proxy/helpers_test.go for it to find the binaries
doCheck = false;
# if we run the tests in installCheckPhase instead, adjust this
postCheck = ''
rm -f $out/bin/{process-cmd-test,simple-responder}
'';
doInstallCheck = true;
versionCheckProgramArg = "-version";
meta = {
description = "Model swapping for llama.cpp (or any local OpenAPI compatible server)";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ peterhoeg ];
platform = lib.platforms.linux;
mainProgram = "llama-swap";
};
} An alternative approach is just to do the package first (which is rather uncontroversial) while we hammer out the details of the nixos module. That's your call of course. I don't have any macs to test on, but if @jwiegley says it works then it does! |
I also didn't take the time to thank for contributing your time to the project - I just noticed this is your first nixos PR so thank you! |
I copied the definitions from this PR into my configuration in order to update to v137 — by changing |
9eb63af
to
9575973
Compare
9575973
to
9cd7f0a
Compare
Hi, i've changed
Would it be possible for the module to be on both home-manager and on nixos at the same time? (system service on nixos here and user service via home-manager) I think that a common use case for llama-swap are home servers where there usually isn't a need for it to be a user service. This would allow more convenience and flexibility for users to choose which type they want 😃 |
--replace-fail '../proxy/ui_dist' '${placeholder "out"}/ui_dist' | ||
''; | ||
|
||
sourceRoot = "source/ui"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sourceRoot = "source/ui"; | |
sourceRoot = "${src.name}/ui"; |
adds llama-swap package at v125 & added module
https://github.com/mostlygeek/llama-swap
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.