forked from sourmash-bio/sourmash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
127 lines (103 loc) · 3.55 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
{
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";
};
};
};
outputs = { self, nixpkgs, 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;
};
python = pkgs.python311Packages;
in
with pkgs;
{
packages = {
lib = rustPlatform.buildRustPackage {
name = "libsourmash";
src = lib.cleanSource ./.;
copyLibs = true;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = with rustPlatform; [ bindgenHook ];
};
sourmash = python.buildPythonPackage rec {
pname = "sourmash";
version = "4.8.6-dev";
format = "pyproject";
src = ./.;
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = with rustPlatform; [ cargoSetupHook maturinBuildHook bindgenHook ];
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 = with rustPlatform; [ bindgenHook ];
buildInputs = [
rustVersion
openssl
pkg-config
git
stdenv.cc.cc.lib
(python312.withPackages (ps: with ps; [ virtualenv ]))
(python311.withPackages (ps: with ps; [ virtualenv tox cffi ]))
(python310.withPackages (ps: with ps; [ virtualenv ]))
rust-cbindgen
maturin
wasmtime
wasm-pack
nodejs_20
#emscripten
#py-spy
#heaptrack
cargo-all-features
cargo-watch
cargo-limit
cargo-outdated
cargo-udeps
cargo-deny
cargo-semver-checks
nixpkgs-fmt
];
# Needed for matplotlib
LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.stdenv.cc.cc.lib ];
# 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
};
});
}