-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathflake.nix
More file actions
151 lines (134 loc) · 5.6 KB
/
flake.nix
File metadata and controls
151 lines (134 loc) · 5.6 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
crane = {
url = "github:ipetkov/crane";
};
electrs-flake = {
url = "github:blockstream/electrs";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
crane.follows = "crane";
rust-overlay.follows = "rust-overlay";
};
};
waterfalls-flake = {
url = "github:RCasatta/waterfalls";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.rust-overlay.follows = "rust-overlay";
inputs.crane.follows = "crane";
};
registry-flake = {
url = "github:blockstream/asset_registry/flake";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
crane.follows = "crane";
rust-overlay.follows = "rust-overlay";
};
};
nexus_relay = {
url = "github:RCasatta/nexus_relay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
# TODO: Remove nixpkgs-mdbook once MSRV reach 1.88+ and we can upgrade mdbook dependency in docs/snippets/processor
nixpkgs-mdbook.url = "github:NixOS/nixpkgs/566e53c2ad750c84f6d31f9ccb9d00f823165550";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, electrs-flake, waterfalls-flake, registry-flake, nexus_relay, nixpkgs-mdbook }:
flake-utils.lib.eachDefaultSystem
(system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
pkgs-mdbook = import nixpkgs-mdbook {
inherit system;
};
inherit (pkgs) lib;
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
electrs = electrs-flake.apps.${system}.blockstream-electrs-liquid;
registry = registry-flake.packages.${system};
waterfalls = waterfalls-flake.packages.${system}.default;
# When filtering sources, we want to allow assets other than .rs files
src = lib.cleanSourceWith {
src = ./.; # The original, unfiltered source
filter = path: type:
(lib.hasSuffix "\.elf" path) ||
(lib.hasSuffix "\.json" path) ||
(lib.hasSuffix "\.md" path) ||
(lib.hasInfix "/test_data/" path) ||
(lib.hasInfix "/test/data/" path) ||
(lib.hasInfix "/tests/data/" path) || # TODO unify these dir names
# Default filter from crane (allow .rs files)
(craneLib.filterCargoSources path type)
;
};
nativeBuildInputs = with pkgs; [ rustToolchain pkg-config ]; # required only at build time
buildInputs = [ pkgs.openssl pkgs.udev ]; # also required at runtime
commonArgs = {
inherit src buildInputs nativeBuildInputs;
# the following must be kept in sync with the ones in ./lwk_cli/Cargo.toml
# note there should be a way to read those from there with
# craneLib.crateNameFromCargoToml { cargoToml = ./path/to/Cargo.toml; }
# but I can't make it work
pname = "lwk_cli";
version = "0.16.0";
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# remember, `set1 // set2` does a shallow merge:
bin = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
cargoTestExtraArgs = "--lib"; # only unit testing, integration testing has more requirements (docker and other executables)
# Without the following also libs are included in the package, and we need to produce only the executable.
# There should probably a way to avoid creating it in the first place, but for now this works.
postInstall = ''
rm -r $out/lib
'';
});
# Build mdbook-snippets from local source
mdbook-snippets = craneLib.buildPackage {
src = lib.cleanSource ./docs/snippets/processor;
inherit nativeBuildInputs;
buildInputs = [ ];
pname = "mdbook-snippets";
version = "0.1.0";
};
in
{
packages =
{
# that way we can build `bin` specifically,
# but it's also the default.
inherit bin;
default = bin;
inherit mdbook-snippets;
};
devShells.default = pkgs.mkShell {
inputsFrom = [ bin ];
buildInputs = [ registry.bin rustToolchain pkgs.websocat pkgs.heaptrack pkgs-mdbook.mdbook pkgs-mdbook.mdbook-mermaid mdbook-snippets pkgs.cargo-depgraph pkgs.cargo-bloat ];
ELEMENTSD_EXEC = "${pkgs.elementsd}/bin/elementsd";
BITCOIND_EXEC = "${pkgs.bitcoind}/bin/bitcoind";
ELECTRS_LIQUID_EXEC = electrs.program;
WATERFALLS_EXEC = "${waterfalls}/bin/waterfalls";
ASSET_REGISTRY_EXEC = "${registry.default}/bin/server";
NEXUS_RELAY_EXEC = "${nexus_relay.packages.${system}.default}/bin/nexus_relay";
WEBSOCAT_EXEC = "${pkgs.websocat}/bin/websocat";
SKIP_VERIFY_DOMAIN_LINK = "1"; # the registry server skips validation
};
}
);
}