diff --git a/_server.nix b/_server.nix index bc11ba6b..2cb2f887 100644 --- a/_server.nix +++ b/_server.nix @@ -1,4 +1,9 @@ -{ mkPoetryApplication, pkg-config, protobuf, openssl }: +{ + mkPoetryApplication, + pkg-config, + protobuf, + openssl, +}: mkPoetryApplication { # name = "text-generation-server"; diff --git a/flake.lock b/flake.lock index ef05c258..dab582a5 100644 --- a/flake.lock +++ b/flake.lock @@ -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" diff --git a/flake.nix b/flake.nix index 8784be37..e1f44212 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; diff --git a/router.nix b/router.nix deleted file mode 100644 index eeeac199..00000000 --- a/router.nix +++ /dev/null @@ -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 ]; - -}