-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathflake.nix
More file actions
102 lines (86 loc) · 2.54 KB
/
Copy pathflake.nix
File metadata and controls
102 lines (86 loc) · 2.54 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{
description = "patent — prior-art search for your code ideas";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
rust-overlay,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustToolchain = pkgs.rust-bin.stable.latest.default;
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
src = pkgs.lib.cleanSource ./.;
cargoToml = pkgs.lib.importTOML ./Cargo.toml;
patent = rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = cargoToml.package.version;
inherit src;
cargoLock.lockFile = "${src}/Cargo.lock";
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [
openssl
onnxruntime
];
env.OPENSSL_NO_VENDOR = 1;
env.ORT_PREFER_DYNAMIC_LINK = 1;
env.ORT_LIB_LOCATION = "${pkgs.onnxruntime}/lib";
# rank() integration tests download the embedding model (network).
doCheck = false;
};
dockerImage = pkgs.dockerTools.buildImage {
name = patent.pname;
tag = patent.version;
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [
patent
pkgs.cacert
];
pathsToLink = [
"/bin"
"/etc"
];
};
config = {
Entrypoint = [ "/bin/patent" ];
Env = [ "SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt" ];
};
};
in
{
packages.default = patent;
packages.patent = patent;
packages.dockerImage = dockerImage;
apps.default = flake-utils.lib.mkApp { drv = patent; };
devShells.default = pkgs.mkShell {
inputsFrom = [ patent ];
packages = with pkgs; [
rustToolchain
pkg-config
openssl
];
OPENSSL_NO_VENDOR = 1;
ORT_PREFER_DYNAMIC_LINK = 1;
ORT_LIB_LOCATION = "${pkgs.onnxruntime}/lib";
};
formatter = pkgs.nixfmt;
}
);
}