Skip to content

Commit

Permalink
Add Nix flake files (surrealdb#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
rushmorem committed Sep 3, 2022
1 parent 1c0b6e7 commit 96f61c5
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 0 deletions.
127 changes: 127 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions flake.nix
@@ -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
];
});
}
);
}

0 comments on commit 96f61c5

Please sign in to comment.