-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflake.nix
More file actions
131 lines (113 loc) · 3.75 KB
/
Copy pathflake.nix
File metadata and controls
131 lines (113 loc) · 3.75 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/a7abebc31a8f60011277437e000eebcc01702b9f";
rust-overlay.url = "github:oxalica/rust-overlay/75b2271c5c087d830684cd5462d4410219acc367";
flake-utils.url = "github:numtide/flake-utils";
foundry.url = "github:shazow/foundry.nix/72db7ea069f055d5c7856aca091179a070201931";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { nixpkgs, rust-overlay, flake-utils, foundry, crane, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) foundry.overlay ];
};
toolchain = p: (p.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override {
extensions = [ "rustfmt" "clippy" ];
};
craneLib = (crane.mkLib pkgs).overrideToolchain(toolchain);
frameworks = pkgs.darwin.apple_sdk.frameworks;
# An LLVM build environment
buildDependencies = with pkgs; [
perl
llvmPackages.bintools
openssl
openssl.dev
libiconv
pkg-config
libclang.lib
libz
clang
pkg-config
protobuf
rustPlatform.bindgenHook
lld
coreutils
gcc
rust
zlib
pandoc
] ++ lib.optionals stdenv.isDarwin [
fixDarwinDylibNames
];
sysDependencies = with pkgs; []
++ lib.optionals stdenv.isDarwin [
frameworks.Security
frameworks.CoreServices
frameworks.SystemConfiguration
frameworks.AppKit
libelf
] ++ lib.optionals stdenv.isLinux [
udev
systemd
bzip2
elfutils
];
testDependencies = with pkgs; [
python311
just
foundry-bin
process-compose
jq
docker
solc
grpcurl
grpcui
];
# Specific version of toolchain
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
rustPlatform = pkgs.makeRustPlatform {
cargo = rust;
rustc = rust;
};
in {
devShells = rec {
default = docker-build;
docker-build = pkgs.mkShell {
ROCKSDB = pkgs.rocksdb;
OPENSSL_DEV = pkgs.openssl.dev;
buildInputs = with pkgs; [
# rust toolchain
(toolchain pkgs)
] ++ sysDependencies ++ buildDependencies ++ testDependencies;
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib/";
shellHook = ''
#!/usr/bin/env ${pkgs.bash}
# Export linker flags if on Darwin (macOS)
if [[ "$(${pkgs.stdenv.hostPlatform.system})" =~ "darwin" ]]; then
export LDFLAGS="-L/opt/homebrew/opt/zlib/lib"
export CPPFLAGS="-I/opt/homebrew/opt/zlib/include"
fi
# Add ./target/debug/* to PATH
export PATH="$PATH:$(pwd)/target/debug"
# Add ./target/release/* to PATH
export PATH="$PATH:$(pwd)/target/release"
# Copy over ./githooks/pre-commit to .git/hooks/pre-commit
cp $(pwd)/.githooks/pre-commit $(pwd)/.git/hooks/pre-commit
chmod +x $(pwd)/.git/hooks/pre-commit
cat <<'EOF'
------------
f ------ | |
f ------ | 5e771e3e47 |
5 ------ | |
------------
EOF
echo "FFS, just take a vote!"
'';
};
};
}
);
}