forked from rivet-gg/rivet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.nix
112 lines (91 loc) · 3.23 KB
/
shell.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Cross-platform Rust Setup: https://zeroes.dev/p/nix-recipe-for-rust/
let
pkgs = import ./infra/nix/common/pkgs.nix;
unstablePkgs = import ./infra/nix/common/unstable_pkgs.nix;
custom_clickhouse = import ./infra/nix/pkgs/clickhouse.nix { inherit (pkgs) stdenv fetchurl lib; };
custom_bolt = import ./infra/nix/bolt/default.nix;
useSccache = builtins.getEnv "USE_SCCACHE" == "1";
extraInputs = if useSccache then [ unstablePkgs.sccache ] else [];
sccacheShellHook = if useSccache then ''
export RUSTC_WRAPPER=sccache
export SCCACHE_BUCKET=${builtins.getEnv "SCCACHE_BUCKET"}
export SCCACHE_ENDPOINT=${builtins.getEnv "SCCACHE_ENDPOINT"}
export SCCACHE_REGION=${builtins.getEnv "SCCACHE_REGION"}
export AWS_ACCESS_KEY_ID=${builtins.getEnv "AWS_ACCESS_KEY_ID"}
export AWS_SECRET_ACCESS_KEY=${builtins.getEnv "AWS_SECRET_ACCESS_KEY"}
'' else "";
in
pkgs.mkShell {
name = "rivet";
buildInputs = with pkgs; [
# Kubernetes tools
k3d
kubectl
kubernetes-helm
# Clouds
awscli2
# Infrastructure
terraform
# Tools
custom_bolt
cloc
curl
docker-client # Standardize client CLI since older clients have breaking changes
git # Bolt relies functionality only available in newer versions of Bolt
git-lfs
go-migrate
jq
openssh # ssh-keygen
# Runtimes
nodejs # Required for Fern
# Compilers
clang
llvm
lld
pkg-config
pkgs.latest.rustChannels.stable.rust
# Libraries
openssl
protobuf
# Autocomplete
bashInteractive
bash-completion
# Fixes "cannot change locale" warning
glibcLocales
] ++ extraInputs ++ (
pkgs.lib.optionals stdenv.isDarwin [
libiconv # See https://stackoverflow.com/a/69732679
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.CoreServices
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.Foundation
]
);
shellHook = ''
# Setup Git LFS
git lfs install > /dev/null
# Add binaries to path so we can use a locally built copy of Bolt.
export PATH="${toString ./target/debug/.}:${toString ./target/release/.}:$PATH"
# See https://docs.rs/prost-build/0.8.0/prost_build/#sourcing-protoc
export PROTOC="${pkgs.protobuf}/bin/protoc"
export PROTOC_INCLUDE="${pkgs.protobuf}/include"
# Install autocomplete
source ${pkgs.bash-completion}/share/bash-completion/bash_completion
# terraform -install-autocomplete
complete -C ${pkgs.terraform}/bin/terraform terraform
# awscli
complete -C aws_completer aws
# kubectl completion bash
source <(kubectl completion bash)
# Automatically connect to correct cluster
alias kubectl='KUBECONFIG=$(bolt output project-root)/gen/k8s/kubeconfig/$(bolt output namespace).yml kubectl'
alias helm='KUBECONFIG=$(bolt output project-root)/gen/k8s/kubeconfig/$(bolt output namespace).yml helm'
# Fix dynamic library path to fix issue with Python
export LD_LIBRARY_PATH="${pkgs.clang}/resource-root/lib:${pkgs.lib.strings.makeLibraryPath [ pkgs.openssl ]}"
# Set default Rust flags to match the Rust flags used inside of Bolt.
#
# If these don't match, then the build cache is purged any time Rust is ran from Bolt.
export RUSTFLAGS="--cfg tokio_unstable"
${sccacheShellHook}
'';
}