forked from surrealdb/surrealdb
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes surrealdb#97
- Loading branch information
Showing
2 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
description = "SurrealDB - a scalable, distributed, collaborative, document-graph database, for the realtime web"; | ||
|
||
inputs = { | ||
# We have to use an older NixOS release here because `grpcio-sys` is not compatible with GCC 11 | ||
# See https://github.com/tikv/client-rust/issues/365 | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11-small"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
naersk.url = "github:nix-community/naersk"; | ||
rust-overlay.url = "github:oxalica/rust-overlay"; | ||
}; | ||
|
||
outputs = { self, flake-utils, naersk, nixpkgs, rust-overlay }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let | ||
|
||
# Set the desired FoundationDB version here | ||
# Specify only the major and minor parts using `major.minor` format | ||
# You can find the versions available at | ||
# https://search.nixos.org/packages?channel=22.05&from=0&size=50&sort=relevance&type=packages&query=foundationdb | ||
fdbVersion = "6.1"; | ||
|
||
pkgs = (import nixpkgs) { | ||
inherit system; | ||
overlays = [ rust-overlay.overlays.default ]; | ||
}; | ||
|
||
rustLatest = pkgs.rust-bin.stable.latest; | ||
|
||
naersk' = pkgs.callPackage naersk { | ||
cargo = rustLatest.default; | ||
rustc = rustLatest.default; | ||
}; | ||
|
||
fdbPkgVersion = builtins.replaceStrings ["."] [""] fdbVersion; | ||
fdbFeatureVersion = builtins.replaceStrings ["."] ["_"] fdbVersion; | ||
|
||
commonArgs = { | ||
nativeBuildInputs = with pkgs; [ pkg-config ]; | ||
buildInputs = with pkgs; [ cmake perl protobuf openssl clang fdbPackages."foundationdb${fdbPkgVersion}" ]; | ||
LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"; | ||
}; | ||
|
||
in rec { | ||
# For `nix build` & `nix run`: | ||
packages.default = naersk'.buildPackage (commonArgs // { | ||
src = ./.; | ||
cargoBuildOptions = options: options ++ [ ''--features "storage-tikv storage-fdb-${fdbFeatureVersion}"'' ]; | ||
}); | ||
|
||
# For `nix develop` | ||
devShell = pkgs.mkShell (commonArgs // { | ||
hardeningDisable = [ "fortify" ]; | ||
buildInputs = with pkgs; [ | ||
rustLatest.default rustLatest.rustfmt rustLatest.clippy rust-analyzer | ||
]; | ||
}); | ||
} | ||
); | ||
} |