-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.nix
132 lines (115 loc) · 3.62 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# WARNING!
# This file is provided as a courtesy and comes with no guarantees that it will
# continue to work in the future.
{sources ? import ./nix/sources.nix {}}: let
pkgs = sources.pkgs;
overlays = pkgs.callPackage ./nix/overlays.nix {};
kernelPackageSet =
[
# Packages required to build & develop kernels
pkgs.rustup
pkgs.wabt
# Cross-compilation for RISC-V
sources.riscv64Pkgs.clangStdenv.cc
# Formatter/LSP for Cargo manifests (and TOML in general)
pkgs.taplo
]
# On Mac, Rust's standard library needs libiconv
++ pkgs.lib.optional pkgs.stdenv.isDarwin pkgs.libiconv;
mainPackage = (import ./default.nix {inherit sources;}).overrideAttrs (old: {
# This makes the shell load faster.
# Usually Nix will try to load the package's source, which in this case
# is the entire repository. Given the repository is fairly large, and we
# don't actually need the source to build the development dependencies,
# we just remove the dependency on the source entirely.
src = null;
});
devPackageSet = pkgs.opamPackages.overrideScope' (
pkgs.lib.composeManyExtensions [
# Set the opam-repository which has the package descriptions.
(final: prev: {
repository = prev.repository.override {
src = sources.opam-repository;
};
})
# Specify the constraints we have.
(final: prev:
prev.repository.select {
opams = [
{
name = "octez-deps";
opam = ./opam/virtual/octez-deps.opam.locked;
}
{
name = "octez-dev-deps";
opam = ./opam/virtual/octez-dev-deps.opam;
}
];
packageConstraints = [
"ocamlformat-rpc"
];
})
# Tweak common packages.
overlays.common-overlay
# Overlays for MacOS
(
if pkgs.stdenv.isDarwin
then overlays.darwin-overlay
else final: prev: {}
)
]
);
clangNoArch =
if pkgs.stdenv.isDarwin
then
pkgs.clang.overrideAttrs (old: {
postFixup = ''
${old.postFixup or ""}
# On macOS this contains '-march' and '-mcpu' flags. These flags
# would be used for any invocation of Clang.
# Removing those makes the resulting Clang wrapper usable when
# cross-compiling where passing '-march' and '-mcpu' would not
# make sense.
echo > $out/nix-support/cc-cflags-before
'';
})
else pkgs.clang;
in
pkgs.mkShell {
name = "tezos-shell";
hardeningDisable = ["stackprotector"];
inherit (mainPackage) NIX_LDFLAGS NIX_CFLAGS_COMPILE TEZOS_WITHOUT_OPAM OPAM_SWITCH_PREFIX;
inputsFrom = [mainPackage];
buildInputs = with pkgs;
kernelPackageSet
++ [
nodejs
cacert
curl
shellcheck
shfmt
poetry
kaitai-struct-compiler
devPackageSet.ocaml-lsp-server
devPackageSet.ocamlformat-rpc
devPackageSet.ocp-indent
devPackageSet.merlin
devPackageSet.utop
devPackageSet.odoc
]
++ (
if pkgs.stdenv.isDarwin
then [
fswatch
]
else [
inotify-tools
]
);
# This tells the 'cc' Rust crate to build using this C compiler when
# targeting other architectures.
CC_wasm32_unknown_unknown = "${clangNoArch}/bin/clang";
CC_riscv64gc_unknown_linux_gnu = "${clangNoArch}/bin/clang";
CC_riscv64gc_unknown_none_elf = "${clangNoArch}/bin/clang";
CC_riscv64gc_unknown_hermit = "${clangNoArch}/bin/clang";
}