-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
129 lines (106 loc) · 3.34 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
# WARNING!
# This file is provided as a courtesy and comes with no guarantees that it will
# continue to work in the future.
let
sources = import ./nix/sources.nix;
pkgs = sources.pkgs;
overlays = pkgs.callPackage ./nix/overlays.nix {};
mavryk-opam-repository = pkgs.callPackage ./nix/mavryk-opam-repo.nix {};
opam-repository = pkgs.callPackage ./nix/opam-repo.nix {};
packageSet = pkgs.opamPackages.overrideScope' (pkgs.lib.composeManyExtensions [
# Set the opam-repository which has the package descriptions.
(final: prev: {
repository = prev.repository.override {src = 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"
{}
''
mkdir -p $out/share/zcash-params
cp ${mavryk-opam-repository}/zcash-params/sapling-output.params $out/share/zcash-params
cp ${mavryk-opam-repository}/zcash-params/sapling-spend.params $out/share/zcash-params
'';
mkFrameworkFlags = frameworks:
pkgs.lib.concatStringsSep " " (
pkgs.lib.concatMap
(
framework: [
"-F${pkgs.darwin.apple_sdk.frameworks.${framework}}/Library/Frameworks"
"-framework ${framework}"
]
)
frameworks
);
in
pkgs.stdenv.mkDerivation {
name = "mavryk";
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 ++ [pkgs.makeWrapper];
# Disable OPAM usage in Makefile.
MAVRYK_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"
else true;
src = pkgs.lib.sources.cleanSource ./.;
};
dontConfigure = true;
dontCheck = true;
buildPhase = ''
make experimental-release
'';
installPhase = ''
mkdir -p $out/bin
find . -maxdepth 1 -iname 'mavkit-*' -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;
};
}