-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
48 lines (41 loc) · 1.64 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
description = "Application packaged using poetry2nix";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication defaultPoetryOverrides;
customOverrides = defaultPoetryOverrides.extend (self: super: {
# Add overrides only if the package exists in super
maturin = if super ? maturin then super.maturin.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ pkgs.rustc pkgs.cargo ];
}) else null;
tiktoken = if super ? tiktoken then super.tiktoken.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ self.setuptools-rust pkgs.rustc pkgs.cargo ];
}) else null;
pydantic-core = if super ? pydantic-core then super.pydantic-core.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or []) ++ [ pkgs.rustc pkgs.cargo ];
}) else null;
});
chatsh = mkPoetryApplication {
projectDir = ./.;
overrides = [ customOverrides ];
preferWheels = true;
};
in {
packages.default = chatsh;
devShells.default = pkgs.mkShell {
inputsFrom = [ chatsh ];
packages = [ pkgs.poetry ];
};
}
);
}