forked from commune-ai/subspace
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
59 lines (53 loc) · 1.81 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
{
description = "Commune's Subspace Node";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/23.11";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
naersk.url = "github:nix-community/naersk";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils, naersk, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
generalBuildInputs = with pkgs; [
pkg-config
rocksdb
zstd.dev
bashInteractive
openssl.dev
];
buildInputs = with pkgs;
if pkgs.stdenv.isLinux
then generalBuildInputs ++ [ jemalloc ]
else generalBuildInputs;
nativeBuildInputs = with pkgs; [ git rust clang protobuf ];
naersk' = pkgs.callPackage naersk {
cargo = rust;
rustc = rust;
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = buildInputs;
nativeBuildInputs = nativeBuildInputs;
env = {
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
ROCKSDB_LIB_DIR = "${pkgs.rocksdb}/lib";
ZSTD_SYS_USE_PKG_CONFIG = "true";
OPENSSL_DIR = "${pkgs.openssl.dev}";
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include";
} // nixpkgs.lib.optionalAttrs pkgs.stdenv.isLinux { JEMALLOC_OVERRIDE = "${pkgs.jemalloc}/lib/libjemalloc.so"; };
};
packages.default = naersk'.buildPackage {
inherit buildInputs nativeBuildInputs;
src = ./.;
};
}
);
}