-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
104 lines (88 loc) · 3.07 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
dfinity-sdk = {
url = "github:paulyoung/nixpkgs-dfinity-sdk?rev=28bb54dc1912cd723dc15f427b67c5309cfe851e";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, crane, dfinity-sdk, flake-utils, rust-overlay, ... }:
let
supportedSystems = [
flake-utils.lib.system.aarch64-darwin
# flake-utils.lib.system.x86_64-darwin
];
in
flake-utils.lib.eachSystem supportedSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: (import dfinity-sdk) final prev)
(import rust-overlay)
];
};
# icfs uses #[feature] which can only be used on the nightly release channel.
rustWithWasmTarget = pkgs.rust-bin.nightly."2022-06-01".default.override {
targets = [ "wasm32-unknown-unknown" ];
};
# NB: we don't need to overlay our custom toolchain for the *entire*
# pkgs (which would require rebuidling anything else which uses rust).
# Instead, we just want to update the scope that crane will use by appending
# our specific toolchain there.
craneLib = (crane.mkLib pkgs).overrideToolchain rustWithWasmTarget;
dfinitySdk = (pkgs.dfinity-sdk {
acceptLicenseAgreement = true;
sdkSystem = system;
}).makeVersion {
systems = {
"x86_64-darwin" = {
sha256 = "sha256-nLocFGJ5pI1KG7ZdWjFpWwd7ZP+Ed4TjfBLLSKkq2/o=";
};
};
version = "0.12.0-beta.1";
};
buildRustPackage = options: craneLib.buildPackage ({
TARGET_CC = "${pkgs.stdenv.cc.nativePrefix}cc";
src = ./.;
# crane tries to run the Wasm file as if it were a binary
doCheck = false;
} // options);
ic-sqlite = buildRustPackage {
cargoExtraArgs = "--package ic-sqlite";
};
ic-sqlite-example = buildRustPackage {
cargoExtraArgs = "--package ic-sqlite-example";
};
in
{
checks = {
inherit ic-sqlite ic-sqlite-example;
};
packages = {
inherit ic-sqlite ic-sqlite-example;
};
defaultPackage = ic-sqlite-example;
devShell = pkgs.mkShell {
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc;
TARGET_CC = "${pkgs.stdenv.cc.nativePrefix}cc";
inputsFrom = builtins.attrValues self.checks;
nativeBuildInputs = with pkgs; [
dfinitySdk
rustWithWasmTarget
];
};
});
}