/
flake.nix
139 lines (113 loc) · 3.88 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "utils";
};
};
naersk = {
url = "github:nix-community/naersk";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, nixpkgs, naersk, rust-overlay, utils }:
utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rustVersion = pkgs.rust-bin.stable.latest.default.override {
#extensions = [ "rust-src" ];
#targets = [ "x86_64-unknown-linux-musl" ];
targets = [ "wasm32-wasi" "wasm32-unknown-unknown" "wasm32-unknown-emscripten" ];
};
rustPlatform = pkgs.makeRustPlatform {
cargo = rustVersion;
rustc = rustVersion;
};
naersk-lib = naersk.lib."${system}".override {
cargo = rustPlatform.rust.cargo;
rustc = rustPlatform.rust.rustc;
};
python = pkgs.python310Packages;
in
with pkgs;
{
packages = {
lib = naersk-lib.buildPackage {
pname = "libsourmash";
root = ./.;
copyLibs = true;
};
sourmash = python.buildPythonPackage rec {
pname = "sourmash";
version = "4.7.0";
format = "pyproject";
src = ./.;
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = with rustPlatform; [ cargoSetupHook maturinBuildHook ];
buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
propagatedBuildInputs = with python; [ cffi deprecation cachetools bitstring numpy scipy matplotlib screed ];
DYLD_LIBRARY_PATH = "${self.packages.${system}.lib}/lib";
};
docker =
let
bin = self.defaultPackage.${system};
in
pkgs.dockerTools.buildLayeredImage {
name = bin.pname;
tag = bin.version;
contents = [ bin ];
config = {
Cmd = [ "/bin/sourmash" ];
WorkingDir = "/";
};
};
};
defaultPackage = self.packages.${system}.sourmash;
devShell = mkShell {
nativeBuildInputs = [
clang_13
];
buildInputs = [
rustPlatform.rust.cargo
openssl
pkgconfig
git
stdenv.cc.cc.lib
(python310.withPackages (ps: with ps; [ virtualenv tox cffi ]))
(python311.withPackages (ps: with ps; [ virtualenv ]))
(python39.withPackages (ps: with ps; [ virtualenv ]))
(python38.withPackages (ps: with ps; [ virtualenv ]))
rust-cbindgen
maturin
wasmtime
wasm-pack
nodejs-16_x
#py-spy
heaptrack
cargo-watch
cargo-limit
cargo-outdated
cargo-udeps
nixpkgs-fmt
llvmPackages_13.libclang
llvmPackages_13.libcxxClang
];
BINDGEN_EXTRA_CLANG_ARGS = "-isystem ${llvmPackages_13.libclang.lib}/lib/clang/${lib.getVersion clang}/include";
LIBCLANG_PATH = "${llvmPackages_13.libclang.lib}/lib";
LD_LIBRARY_PATH = "${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH";
# workaround for https://github.com/NixOS/nixpkgs/blob/48dfc9fa97d762bce28cc8372a2dd3805d14c633/doc/languages-frameworks/python.section.md#python-setuppy-bdist_wheel-cannot-create-whl
SOURCE_DATE_EPOCH = 315532800; # 1980
};
});
}