-
Notifications
You must be signed in to change notification settings - Fork 21
/
flake.nix
170 lines (131 loc) · 5.72 KB
/
flake.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# SPDX-FileCopyrightText: 2022 Oxhead Alpha
# SPDX-License-Identifier: LicenseRef-MIT-OA
{
description = "The tezos-packaging flake";
nixConfig.flake-registry = "https://github.com/serokell/flake-registry/raw/master/flake-registry.json";
inputs = {
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:serokell/nixpkgs";
nix.url = "github:nixos/nix";
opam-nix.url = "github:tweag/opam-nix";
rust-overlay.url = "github:oxalica/rust-overlay";
crane.url = "github:ipetkov/crane";
flake-compat.flake = false;
opam-repository.url = "github:ocaml/opam-repository";
opam-repository.flake = false;
tezos.url = "gitlab:tezos/tezos";
tezos.flake = false;
};
outputs = inputs@{ self, nixpkgs, nixpkgs-unstable, flake-utils, serokell-nix, nix, rust-overlay, crane, ... }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
pkgs-unstable = import nixpkgs-unstable { system = "x86_64-linux"; overlays = [ rust-overlay.overlays.default ]; };
pkgs-darwin = nixpkgs-unstable.legacyPackages."aarch64-darwin";
protocols = nixpkgs.lib.importJSON ./protocols.json;
meta = nixpkgs.lib.importJSON ./meta.json;
tezos = builtins.path {
path = inputs.tezos;
name = "tezos";
# we exclude optional development packages
filter = path: _: !(builtins.elem (baseNameOf path) [ "octez-dev-deps.opam" "tezos-time-measurement.opam" ]);
};
toolchain-version = pkgs-unstable.lib.strings.trim (builtins.readFile "${tezos}/rust-toolchain");
rust-toolchain = pkgs-unstable.rust-bin.stable.${toolchain-version}.default;
craneLib = (crane.mkLib pkgs-unstable).overrideToolchain (p: p.rust-bin.stable.${toolchain-version}.default);
opam-repository = pkgs.stdenv.mkDerivation {
name = "opam-repository";
src = inputs.opam-repository;
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
patchPhase = ''
mkdir -p packages/octez-deps/octez-deps.dev
cp ${tezos}/opam/virtual/octez-deps.opam.locked packages/octez-deps/octez-deps.dev/opam
# This package adds some constraints to the solution found by the opam solver.
dummy_pkg=octez-dummy
dummy_opam_dir="packages/$dummy_pkg/$dummy_pkg.dev"
dummy_opam="$dummy_opam_dir/opam"
mkdir -p "$dummy_opam_dir"
echo 'opam-version: "2.0"' > "$dummy_opam"
echo "depends: [ \"ocaml\" { = \"$ocaml_version\" } ]" >> "$dummy_opam"
echo 'conflicts:[' >> "$dummy_opam"
grep -r "^flags: *\[ *avoid-version *\]" -l packages |
LC_COLLATE=C sort -u |
while read -r f; do
f=$(dirname "$f")
f=$(basename "$f")
p=$(echo "$f" | cut -d '.' -f '1')
v=$(echo "$f" | cut -d '.' -f '2-')
echo "\"$p\" {= \"$v\"}" >> $dummy_opam
done
# FIXME: https://gitlab.com/tezos/tezos/-/issues/5832
# opam unintentionally picks up a windows dependency. We add a
# conflict here to work around it.
echo '"ocamlbuild" {= "0.14.2+win" }' >> $dummy_opam
echo ']' >> "$dummy_opam"
OPAMSOLVERTIMEOUT=600 ${pkgs.opam}/bin/opam admin filter --yes --resolve \
"octez-deps,ocaml,ocaml-base-compiler,odoc<2.3.0,ledgerwallet-tezos,caqti-driver-postgresql,$dummy_pkg" \
--environment "os=linux,arch=x86_64,os-family=debian"
rm -rf packages/"$dummy_pkg" packages/octez-deps
'';
installPhase = ''
mkdir -p $out
cp -Lpr * $out
'';
};
sources = { inherit tezos opam-repository; };
ocaml-overlay = import ./nix/build/ocaml-overlay.nix (inputs // { inherit sources protocols meta craneLib rust-toolchain; });
in pkgs-darwin.lib.recursiveUpdate
{
nixosModules = {
tezos-node = import ./nix/modules/tezos-node.nix;
tezos-accuser = import ./nix/modules/tezos-accuser.nix;
tezos-baker = import ./nix/modules/tezos-baker.nix;
tezos-signer = import ./nix/modules/tezos-signer.nix;
};
devShells."aarch64-darwin".autorelease-macos =
import ./scripts/macos-shell.nix { pkgs = pkgs-darwin; };
overlays.default = final: prev: nixpkgs.lib.composeManyExtensions [
ocaml-overlay
(final: prev: { inherit (inputs) serokell-nix; })
] final prev;
} (flake-utils.lib.eachSystem [
"x86_64-linux"
] (system:
let
overlay = final: prev: {
inherit (inputs) serokell-nix;
nix = nix.packages.${system}.default;
zcash-params = callPackage ./nix/build/zcash.nix {};
};
pkgs = import nixpkgs {
inherit system;
overlays = [
overlay
serokell-nix.overlay
ocaml-overlay
];
};
unstable = import nixpkgs-unstable {
inherit system;
overlays = [(_: _: { nix = nix.packages.${system}.default; })];
};
callPackage = pkg: input:
import pkg (inputs // { inherit sources protocols meta pkgs; } // input);
inherit (callPackage ./nix {}) octez-binaries tezos-binaries;
release = callPackage ./release.nix {};
in {
legacyPackages = unstable;
inherit release;
packages = octez-binaries // tezos-binaries
// { default = pkgs.linkFarmFromDrvs "binaries" (builtins.attrValues octez-binaries); };
devShells = {
buildkite = callPackage ./.buildkite/shell.nix {};
autorelease = callPackage ./scripts/shell.nix {};
docker-tezos-packages = callPackage ./shell.nix {};
};
checks = {
tezos-nix-binaries = callPackage ./tests/tezos-nix-binaries.nix {};
tezos-modules = callPackage ./tests/tezos-modules.nix {};
};
binaries-test = callPackage ./tests/tezos-binaries.nix {};
}));
}