-
Notifications
You must be signed in to change notification settings - Fork 37
/
default.nix
153 lines (126 loc) · 4.16 KB
/
default.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# 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 {};
packageSet = 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;};
})
# First overlay simply picks the package versions from Tezos'
# opam-repository.
overlays.pick-latest-packages
# Tweak common packages.
overlays.common-overlay
# Overlays for MacOS
(
if pkgs.stdenv.isDarwin
then overlays.darwin-overlay
else final: prev: {}
)
# Tweak the dependencies.
overlays.fix-rust-packages
]);
packages =
builtins.filter
pkgs.lib.attrsets.isDerivation
(builtins.attrValues packageSet);
packageLibDirs = builtins.filter builtins.pathExists (
builtins.map (package: "${package}/lib/${package.pname}") packages
);
packageIncludeArgs = builtins.map (dir: "-I${dir}") packageLibDirs;
fakeOpamSwitchPrefix =
pkgs.runCommand
"fake-opam-switch-prefix"
{
inherit (pkgs.callPackage ./nix/dal-files.nix {}) g1 g2;
}
''
mkdir -p $out/share/zcash-params $out/share/dal-trusted-setup
cp ${./images/ci/zcash-params}/* $out/share/zcash-params
cp $g1 $out/share/dal-trusted-setup/srsu_zcash_g1
cp $g2 $out/share/dal-trusted-setup/srsu_zcash_g2
'';
mkFrameworkFlags = frameworks:
pkgs.lib.concatStringsSep " " (
pkgs.lib.concatMap
(
framework: [
"-F${pkgs.darwin.apple_sdk.frameworks.${framework}}/Library/Frameworks"
"-framework ${framework}"
]
)
frameworks
);
llvmPackages = pkgs.llvmPackages_16;
libtoolAliasDarwin =
# On Darwin we need a little help to bring `libtool` into scope.
pkgs.runCommand "libtool-alias" {} ''
mkdir -p $out/bin
ln -s ${llvmPackages.bintools-unwrapped}/bin/llvm-libtool-darwin $out/bin/libtool
'';
in
pkgs.stdenv.mkDerivation {
name = "tezos";
NIX_LDFLAGS = pkgs.lib.optional pkgs.stdenv.isDarwin (
mkFrameworkFlags [
"CoreFoundation"
"IOKit"
"AppKit"
"Security"
]
);
NIX_CFLAGS_COMPILE =
# Silence errors (-Werror) for unsupported flags on MacOS.
pkgs.lib.optionals
pkgs.stdenv.isDarwin
["-Wno-unused-command-line-argument"]
++
# Make sure headers files are in scope.
packageIncludeArgs;
hardeningDisable = ["stackprotector"];
buildInputs =
packages
++ (with pkgs; [
makeWrapper
cacert
# Bring Clang into scope in case the stdenv doesn't come with it already.
llvmPackages.clang
# This brings in things like llvm-ar which are needed for Rust WebAssembly
# compilation on Mac. It isn't used by default. Configure the AR environment variable to
# make rustc use it.
# This package also brings objcopy, libtoool and ranlib which are used.
llvmPackages.bintools
])
++ pkgs.lib.optional pkgs.stdenv.isDarwin libtoolAliasDarwin;
# Disable OPAM usage in Makefile.
TEZOS_WITHOUT_OPAM = true;
# $OPAM_SWITCH_PREFIX is used to find the ZCash parameters.
OPAM_SWITCH_PREFIX = fakeOpamSwitchPrefix;
src = pkgs.lib.sources.cleanSourceWith {
filter = name: type:
if type == "directory"
then name != "_build" && name != "target" && name != ".direnv"
else true;
src = pkgs.lib.sources.cleanSource ./.;
};
dontConfigure = true;
dontCheck = true;
buildPhase = ''
CARGO_HOME=$TMPDIR/.cargo make experimental-release
'';
installPhase = ''
mkdir -p $out/bin
find . -maxdepth 1 -iname 'octez-*' -type f -executable -exec cp {} $out/bin \;
'';
postFixup = ''
for file in $(find $out/bin -type f); do
wrapProgram $file --set OPAM_SWITCH_PREFIX ${fakeOpamSwitchPrefix}
done
'';
passthru = {
ocamlVersion = packageSet.ocaml.version;
};
}