nix: partial incremental build of the router (#2416)

This is less incremental than crate2nix, but does build all dependencies
separately, so avoids full rebuilds.
This commit is contained in:
Daniël de Kok 2024-08-14 11:06:28 +02:00 committed by GitHub
parent 1cebccc72b
commit c5fff92b48
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 57 additions and 27 deletions

View File

@ -1,4 +1,9 @@
{ mkPoetryApplication, pkg-config, protobuf, openssl }:
{
mkPoetryApplication,
pkg-config,
protobuf,
openssl,
}:
mkPoetryApplication {
# name = "text-generation-server";

View File

@ -579,6 +579,27 @@
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": [
"tgi-nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1721727458,
"narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=",
"owner": "nix-community",
"repo": "naersk",
"rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nix-github-actions": {
"inputs": {
"nixpkgs": [
@ -880,6 +901,7 @@
"inputs": {
"crate2nix": "crate2nix",
"flake-utils": "flake-utils_6",
"naersk": "naersk",
"nixpkgs": [
"tgi-nix",
"nixpkgs"

View File

@ -7,6 +7,10 @@
tgi-nix.url = "github:danieldk/tgi-nix";
nixpkgs.follows = "tgi-nix/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "tgi-nix/nixpkgs";
};
poetry2nix.url = "github:nix-community/poetry2nix";
rust-overlay = {
url = "github:oxalica/rust-overlay";
@ -17,6 +21,7 @@
{
self,
crate2nix,
naersk,
nixpkgs,
flake-utils,
rust-overlay,
@ -41,13 +46,32 @@
tgi-nix.overlay
];
};
naersk' = pkgs.callPackage naersk { };
router =
with pkgs;
naersk'.buildPackage {
name = "router";
src = ./.;
cargoBuildOptions =
x:
x
++ [
"-p"
"text-generation-router-v3"
];
nativeBuildInputs = [ pkg-config ];
buildInputs = [
openssl.dev
protobuf
];
doCheck = false;
};
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryEditablePackage;
text-generation-server = mkPoetryEditablePackage {
editablePackageSources = ./server;
};
text-generation-server = mkPoetryEditablePackage { editablePackageSources = ./server; };
in
{
defaultPackage = router;
devShells.default =
with pkgs;
mkShell {
@ -92,11 +116,8 @@
transformers
vllm
cargoNix.workspaceMembers.text-generation-launcher.build
(callPackage ./router.nix {
inherit (rustPlatform) buildRustPackage importCargoLock;
})
cargoNix.workspaceMembers.text-generation-launcher.build
router
]);
venvDir = "./.venv";

View File

@ -1,18 +0,0 @@
{ buildRustPackage, importCargoLock, pkg-config, protobuf, openssl }:
buildRustPackage {
name = "text-generation-router";
src = ./.;
sourceDir = ./backends/v3;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl.dev protobuf ];
}