-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathshell.nix
More file actions
52 lines (49 loc) · 1.36 KB
/
shell.nix
File metadata and controls
52 lines (49 loc) · 1.36 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
{ profile ? "stable", version ? "1.88.0" }:
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {
overlays = [ (_: _: { inherit sources; }) (import ./nix/overlay.nix { }) ];
};
rust = import sources.nixpkgs { overlays = [ (import sources.rust-overlay) ]; };
usePreCommit = builtins.getEnv "IN_NIX_SHELL" == "impure" && builtins.getEnv "CI" != "1";
pre-commit = pkgs.runCommand "pre-commit" { } ''
mkdir -p $out/bin
cp ${pkgs.pre-commit}/bin/pre-commit $out/bin/pre-commit
'';
in
let
rust-bin =
(rust.rust-bin.${profile}.${version}.default.override {
extensions = [ "rust-src" ];
});
in
with pkgs;
pkgs.mkShell {
buildInputs = [
rust-bin
cacert
cargo-udeps
clang
openssl
pkg-config
protobuf
udev
util-linux
commitlint
git
] ++ pkgs.lib.optional (usePreCommit) pre-commit;
LIBCLANG_PATH = "${llvmPackages.libclang.lib}/lib";
PROTOC = "${protobuf}/bin/protoc";
PROTOC_INCLUDE = "${protobuf}/include";
shellHook = ''
if [ "${toString usePreCommit}" = "1" ]; then
pre-commit install
pre-commit install --hook commit-msg
fi
if [ -d ~/.cargo/bin ]; then
# Adding ~/.cargo/bin to the path let's us carry on using rustup but it lowers its
# priority: https://github.com/rust-lang/cargo/pull/11023
export PATH=$PATH:~/.cargo/bin
fi
'';
}