-
Notifications
You must be signed in to change notification settings - Fork 28
/
flake.nix
87 lines (83 loc) · 2.49 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
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
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk = {
url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self
, nixpkgs
, flake-utils
, naersk
, fenix
}:
flake-utils.lib.eachDefaultSystem (system:
let
lib = nixpkgs.lib;
pkgs = nixpkgs.legacyPackages.${system};
rust = fenix.packages.${system}.default;
inherit (rust) cargo rustc;
# Get a naersk with the input rust version
naerskWithRust = rust: naersk.lib."${system}".override {
inherit (rust) cargo rustc;
};
env = with pkgs; {
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
PROTOC = "${protobuf}/bin/protoc";
ROCKSDB_LIB_DIR = "${rocksdb}/lib";
OPENSSL_LIB_DIR = "${openssl.out}/lib";
OPENSSL_ROOT_DIR = "${openssl.out}";
OPENSSL_INCLUDE_DIR = "${openssl.dev}/include";
};
# Naersk using the default rust version
buildRustProject = pkgs.makeOverridable ({ naersk ? naerskWithRust rust, ... } @ args: naersk.buildPackage ({
buildInputs = with pkgs; [ sqlite postgresql ];
targets = [ ];
copyLibs = true;
copyBins = true;
copySources = [ "src" ];
cargoBuildOptions = d: d ++ [ ];
remapPathPrefix =
true; # remove nix store references for a smaller output package
} // env // args));
# Load a nightly rust. The hash takes precedence over the date so remember to set it to
# something like `lib.fakeSha256` when changing the date.
crateName = "arangors";
root = ./.;
# This is a wrapper around naersk build
# Remember to add Cargo.lock to git for naersk to work
project = buildRustProject {
inherit root;
};
# Running tests
testProject = project.override {
doCheck = true;
};
in
{
packages = {
${crateName} = project;
"${crateName}-test" = testProject;
};
defaultPackage = self.packages.${system}.${crateName};
# `nix develop`
devShell = pkgs.mkShell (env // {
nativeBuildInputs = [ rustc cargo ];
buildInputs = with pkgs; [
rust-analyzer
clippy
rustfmt
];
});
});
}