-
Notifications
You must be signed in to change notification settings - Fork 80
/
flake.nix
145 lines (116 loc) · 4.14 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
140
141
142
143
144
145
{
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";
};
};
};
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;
};
inherit (pkgs) lib;
python = pkgs.python311Packages;
stdenv = if pkgs.stdenv.isDarwin then pkgs.overrideSDK pkgs.stdenv "11.0" else pkgs.stdenv;
commonArgs = {
src = ./.;
stdenv = stdenv;
preConfigure = lib.optionalString stdenv.isDarwin ''
export MACOSX_DEPLOYMENT_TARGET=10.14
'';
buildInputs = lib.optionals stdenv.isDarwin [ pkgs.libiconv pkgs.darwin.apple_sdk.frameworks.Security ];
nativeBuildInputs = with rustPlatform; [ cargoSetupHook maturinBuildHook bindgenHook ];
};
in
with pkgs;
{
packages = {
lib = rustPlatform.buildRustPackage ( commonArgs // {
name = "libsourmash";
copyLibs = true;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = with rustPlatform; [ bindgenHook ];
});
sourmash = python.buildPythonPackage ( commonArgs // rec {
pname = "sourmash";
version = "4.8.11";
format = "pyproject";
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
};
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;
devShells.default = pkgs.mkShell.override { stdenv = stdenv; } (commonArgs // {
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-wasi
cargo-codspeed
cargo-semver-checks
nixpkgs-fmt
];
shellHook = ''
export MACOSX_DEPLOYMENT_TARGET=10.14
'';
# 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
# exporting to fix doc building errors in sphinx
LC_ALL="C.utf8";
});
});
}