forked from robustmq/robustmq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
111 lines (91 loc) · 2.66 KB
/
flake.nix
File metadata and controls
111 lines (91 loc) · 2.66 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
103
104
105
106
107
108
109
110
{
description = "A reproducible development environment for RobustMQ";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{ self
, nixpkgs
, crane
, flake-utils
, rust-overlay
}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
craneLib = crane.mkLib pkgs;
rustToolchain = pkgs.rust-bin.stable."1.89.0".default.override {
extensions = [ "rust-src" "rust-analyzer" "rustfmt" ];
};
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
inherit (cargoToml.workspace.package) version;
nativeBuildInputs = with pkgs; [
pkg-config
openssl
protobuf
clang
cmake
rdkafka
zstd
gfortran
snappy
];
devTools = with pkgs; [
buf
python3
cargo-deny
cargo-nextest
typos
(hawkeye.overrideAttrs (_: {
__intentionallyOverridingVersion = true;
version = "5.8.1";
}))
];
commonArgs = {
pname = "robustmq";
inherit version;
src = craneLib.cleanCargoSource ./.;
strictDeps = true;
inherit nativeBuildInputs;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
robustmq-pkg = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
});
in
{
packages.default = robustmq-pkg;
devShells.default = pkgs.mkShell {
name = "robustmq-dev-shell";
inputsFrom = [ cargoArtifacts ];
inherit nativeBuildInputs;
packages = [ rustToolchain ] ++ devTools;
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
LD_LIBRARY_PATH =
with pkgs;
lib.concatStringsSep ":" [
(lib.makeLibraryPath [ openssl ])
"${pkgs.stdenv.cc.cc.lib}/lib"
];
shellHook = ''
echo "Entered RobustMQ development shell. 🚀"
if [ ! -d "precommit_venv" ]; then
echo "Creating Python virtual environment for pre-commit..."
python3 -m venv precommit_venv
fi
if [ -z "$VIRTUAL_ENV" ]; then
echo "Activating Python venv and installing pre-commit dependencies..."
source ./precommit_venv/bin/activate
pip3 install -r ./.requirements-precommit.txt
fi
'';
};
}
);
}