2022-10-15 23:02:13 +03:00
|
|
|
{
|
2023-04-05 02:56:51 +03:00
|
|
|
inputs = {
|
2023-06-18 03:02:10 +03:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
2023-04-05 02:56:51 +03:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
|
|
|
|
fenix = {
|
|
|
|
url = "github:nix-community/fenix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2023-04-05 03:30:30 +03:00
|
|
|
crane = {
|
|
|
|
url = "github:ipetkov/crane";
|
2023-04-05 02:56:51 +03:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
2023-04-05 03:30:30 +03:00
|
|
|
inputs.flake-utils.follows = "flake-utils";
|
2023-01-28 00:10:21 +03:00
|
|
|
};
|
2023-04-05 02:56:51 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
{ self
|
|
|
|
, nixpkgs
|
|
|
|
, flake-utils
|
|
|
|
|
|
|
|
, fenix
|
2023-04-05 03:30:30 +03:00
|
|
|
, crane
|
2023-04-05 02:56:51 +03:00
|
|
|
}: flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
|
2023-04-05 05:11:34 +03:00
|
|
|
# Use mold on Linux
|
|
|
|
stdenv = if pkgs.stdenv.isLinux then
|
|
|
|
pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv
|
|
|
|
else
|
|
|
|
pkgs.stdenv;
|
|
|
|
|
2023-04-05 02:56:51 +03:00
|
|
|
# Nix-accessible `Cargo.toml`
|
|
|
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
|
|
|
|
|
|
|
# The Rust toolchain to use
|
|
|
|
toolchain = fenix.packages.${system}.toolchainOf {
|
|
|
|
# Use the Rust version defined in `Cargo.toml`
|
|
|
|
channel = cargoToml.package.rust-version;
|
|
|
|
|
|
|
|
# THE rust-version HASH
|
2023-06-18 03:04:11 +03:00
|
|
|
sha256 = "sha256-gdYqng0y9iHYzYPAdkC/ka3DRny3La/S5G8ASj0Ayyc=";
|
2023-04-05 02:56:51 +03:00
|
|
|
};
|
|
|
|
|
2023-04-05 05:15:09 +03:00
|
|
|
# The system's RocksDB
|
2023-04-05 02:47:08 +03:00
|
|
|
ROCKSDB_INCLUDE_DIR = "${pkgs.rocksdb_6_23}/include";
|
|
|
|
ROCKSDB_LIB_DIR = "${pkgs.rocksdb_6_23}/lib";
|
|
|
|
|
2023-04-05 03:52:15 +03:00
|
|
|
# Shared between the package and the devShell
|
|
|
|
nativeBuildInputs = (with pkgs.rustPlatform; [
|
|
|
|
bindgenHook
|
|
|
|
]);
|
|
|
|
|
2023-04-05 03:30:30 +03:00
|
|
|
builder =
|
|
|
|
((crane.mkLib pkgs).overrideToolchain toolchain.toolchain).buildPackage;
|
2023-04-05 02:56:51 +03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
packages.default = builder {
|
|
|
|
src = ./.;
|
|
|
|
|
2023-04-05 05:15:09 +03:00
|
|
|
inherit
|
2023-04-05 05:11:34 +03:00
|
|
|
stdenv
|
2023-04-05 05:15:09 +03:00
|
|
|
nativeBuildInputs
|
|
|
|
ROCKSDB_INCLUDE_DIR
|
|
|
|
ROCKSDB_LIB_DIR;
|
2023-04-05 02:56:51 +03:00
|
|
|
};
|
|
|
|
|
2023-04-05 05:11:34 +03:00
|
|
|
devShells.default = (pkgs.mkShell.override { inherit stdenv; }) {
|
2023-04-05 02:56:51 +03:00
|
|
|
# Rust Analyzer needs to be able to find the path to default crate
|
|
|
|
# sources, and it can read this environment variable to do so
|
|
|
|
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library";
|
|
|
|
|
2023-04-05 05:15:09 +03:00
|
|
|
inherit
|
|
|
|
ROCKSDB_INCLUDE_DIR
|
|
|
|
ROCKSDB_LIB_DIR;
|
2023-04-05 02:47:08 +03:00
|
|
|
|
2023-04-05 02:56:51 +03:00
|
|
|
# Development tools
|
2023-04-05 03:52:15 +03:00
|
|
|
nativeBuildInputs = nativeBuildInputs ++ (with toolchain; [
|
2023-04-05 02:56:51 +03:00
|
|
|
cargo
|
|
|
|
clippy
|
|
|
|
rust-src
|
|
|
|
rustc
|
|
|
|
rustfmt
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
|
|
|
|
checks = {
|
|
|
|
packagesDefault = self.packages.${system}.default;
|
|
|
|
devShellsDefault = self.devShells.${system}.default;
|
|
|
|
};
|
|
|
|
});
|
2022-10-15 23:02:13 +03:00
|
|
|
}
|