-
Notifications
You must be signed in to change notification settings - Fork 9
/
flake.nix
103 lines (101 loc) · 3 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
{
description = "Simfony";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs =
{ self
, nixpkgs
, flake-utils
, rust-overlay
, ...
}:
flake-utils.lib.eachSystem [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
] (system:
let
overlays = [
(import rust-overlay)
];
pkgs = import nixpkgs {
inherit system overlays;
};
mkRust = stable: version: profile: targets: extensions: pkgs.rust-bin.${stable}.${version}.${profile}.override {
inherit targets;
inherit extensions;
};
defaultRust = mkRust "stable" "latest" "default" ["wasm32-unknown-unknown"] ["rust-src"];
elementsd-simplicity = pkgs.callPackage ./bitcoind-tests/elementsd-simplicity.nix {};
CC_wasm32_unknown_unknown = "${pkgs.llvmPackages_16.clang-unwrapped}/bin/clang-16";
AR_wasm32_unknown_unknown = "${pkgs.llvmPackages_16.libllvm}/bin/llvm-ar";
CFLAGS_wasm32_unknown_unknown = "-I ${pkgs.llvmPackages_16.libclang.lib}/lib/clang/16/include/";
default_shell = with_elements: pkgs.mkShell {
buildInputs = [
defaultRust
pkgs.just
pkgs.gdb
pkgs.cargo-hack
pkgs.mdbook
] ++ (
if with_elements then [ elementsd-simplicity ] else []
);
inherit CC_wasm32_unknown_unknown;
inherit AR_wasm32_unknown_unknown;
inherit CFLAGS_wasm32_unknown_unknown;
# Constants for IDE
RUST_TOOLCHAIN = "${defaultRust}/bin";
RUST_STDLIB = "${defaultRust}/lib/rustlib/src/rust";
DEBUGGER = "${pkgs.gdb}";
};
in
{
devShells = {
default = default_shell false;
elements = default_shell true;
# Temporary shells until CI has its nix derivations
ci = pkgs.mkShell {
buildInputs = [
(mkRust "stable" "latest" "default" [] [])
pkgs.just
pkgs.cargo-hack
];
};
msrv = pkgs.mkShell {
buildInputs = [
(mkRust "stable" "1.63.0" "minimal" [] [])
pkgs.just
];
};
fuzz = pkgs.mkShell.override {
stdenv = pkgs.clang16Stdenv;
} {
buildInputs = [
(mkRust "nightly" "2024-07-01" "minimal" [] ["llvm-tools-preview"])
pkgs.just
pkgs.cargo-fuzz
pkgs.cargo-binutils
pkgs.rustfilt
];
};
wasm = pkgs.mkShell {
buildInputs = [
(mkRust "stable" "latest" "default" ["wasm32-unknown-unknown"] [])
pkgs.just
];
inherit CC_wasm32_unknown_unknown;
inherit AR_wasm32_unknown_unknown;
inherit CFLAGS_wasm32_unknown_unknown;
};
book = pkgs.mkShell {
buildInputs = [
pkgs.mdbook
];
};
};
}
);
}